Date manipulation: Difference between revisions
Content added Content deleted
(Added Wren) |
(Replaced the program which used Posix functions by a program using the “times” module.) |
||
Line 1,690: | Line 1,690: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
⚫ | |||
Timezones as “EST” are not recognized by the “times” module which follows ISO 8601 standard. So we replace it by a normalized timezone: -05:00. It would be easy to build a table to map these timezone identifiers to normalized timezones (being careful however regarding DST). |
|||
var ts: Ttm |
|||
discard "March 7 2009 7:30pm EST".strptime("%B %d %Y %I:%M%p %Z", ts) |
|||
We output the dates built after parsing in UTC. The module allows also to output in local time. |
|||
ts.tmHour += 12 |
|||
echo ts.mktime</lang> |
|||
⚫ | |||
const Date = "March 7 2009 7:30pm EST" |
|||
echo "Original date is: ", Date |
|||
var dt = Date.replace("EST", "-05:00").parse("MMMM d yyyy h:mmtt zzz") |
|||
echo "Original date in UTC is: ", dt.utc().format("MMMM d yyyy h:mmtt zzz") |
|||
dt = dt + initDuration(hours = 12) |
|||
echo "Date 12 hours later is: ", dt.utc().format("MMMM d yyyy h:mmtt zzz")</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre>Original date is: March 7 2009 7:30pm EST |
||
Original date in UTC is: March 8 2009 12:30AM Z |
|||
Date 12 hours later is: March 8 2009 12:30PM Z</pre> |
|||
=={{header|ooRexx}}== |
=={{header|ooRexx}}== |