Date manipulation

From Rosetta Code
Revision as of 19:26, 13 May 2009 by rosettacode>Glennj (new task with Tcl implementation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Date manipulation
You are encouraged to solve this task according to the task description, using any language you may know.

Given the date string "March 7 2009 7:30pm EST", output the time 12 hours later in any human-readable format.

Tcl

Works with: Tcl version 8.5

<lang tcl>set date "March 7 2009 7:30pm EST" set epoch [clock scan $date -format "%B %d %Y %I:%M%p %z"] set later [clock add $epoch 12 hours] puts [clock format $later] ;# Sun Mar 08 08:30:00 EDT 2009</lang>

Note the transition into daylight savings time in the interval (in the Eastern timezone).