Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,22 @@
USING: calendar calendar.english calendar.format calendar.parser
combinators io kernel math math.parser sequences splitting
unicode ;
IN: rosetta-code.date-manipulation
! e.g. "7:30pm" -> 19 30
: parse-hm ( str -- hours minutes )
":" split first2 [ digit? ] partition
[ [ string>number ] bi@ ] dip "pm" = [ [ 12 + ] dip ] when ;
! Parse a date in the format "March 7 2009 7:30pm EST"
: parse-date ( str -- timestamp )
" " split {
[ first month-names index 1 + ]
[ second string>number ]
[ third string>number -rot ]
[ fourth parse-hm 0 ]
[ last parse-rfc822-gmt-offset ]
} cleave <timestamp> ;
"March 7 2009 7:30pm EST" parse-date dup 12 hours time+
[ timestamp>rfc822 print ] bi@