Sujet : Re: Parsing timestamps?
De : oh2aun (at) *nospam* gmail.com (FFmike)
Groupes : comp.lang.forthDate : 07. Oct 2024, 06:23:16
Autres entêtes
Organisation : novaBBS
Message-ID : <0c8c1eb4a2b5fbd9e4451be2c6f13402@www.novabbs.com>
References : 1 2 3 4 5 6
User-Agent : Rocksolid Light
On Mon, 7 Oct 2024 3:58:28 +0000, dxf wrote:
That treats '12' as hours and '12:13' as hours/min when it should be
secs and min/secs respectively.
I did not see that. It can be fixed by comparing source and >in. Maybe
not elegant, but it works.
variable cnt
: (/t) ( addr len -- hrs mins secs)
1 cnt !
3 for
[char] : word number?
dup 1 = if
drop 'source 2+ @ >in @ <> if 1 cnt +! then
else
2 = if 2drop else drop then 0
then
next
cnt @ for rot next ( fixup)
;
: /t ( addr len -- hrs mins secs )
['] (/t) execute-parsing
;
: t. rot . swap . . ;
s" 30" /t t. 0 0 30 ok<$,ram>
s" 29:30" /t t. 0 29 30 ok<$,ram>
s" 1:29:30" /t t. 1 29 30 ok<$,ram>