Anonymous user
Date manipulation: Difference between revisions
Replaced the program which used Posix functions by a program using the “times” module.
(Added Wren) |
(Replaced the program which used Posix functions by a program using the “times” module.) |
||
Line 1,690:
=={{header|Nim}}==
<lang nim>import posix, times▼
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).
We output the dates built after parsing in UTC. The module allows also to output in local time.
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}}
<pre>
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}}==
|