Date manipulation: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|REBOL}}: Remove vanity tags) |
(Add Factor example) |
||
Line 877: | Line 877: | ||
12 hours later in local time: 08.03.2009 13:30:00 |
12 hours later in local time: 08.03.2009 13:30:00 |
||
12 hours later in EST : 08.03.2009 07:30:00</pre> |
12 hours later in EST : 08.03.2009 07:30:00</pre> |
||
=={{header|Factor}}== |
|||
<lang factor>USING: calendar calendar.english calendar.format calendar.parser |
|||
combinators io kernel math math.parser sequences splitting |
|||
unicode ; |
|||
IN: rosetta-code.date-manipulation |
|||
: 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@</lang> |
|||
{{out}} |
|||
<pre> |
|||
Sat, 7 Mar 2009 19:30:00 -0500 |
|||
Sun, 8 Mar 2009 07:30:00 -0500 |
|||
</pre> |
|||
=={{header|Fantom}}== |
=={{header|Fantom}}== |