Task

Given the date string "March 7 2009 7:30pm EST", 

output the time 12 hours later in any human-readable format.

As extra credit, display the resulting time in a time zone different from your own.




val .input = "March 7 2009 7:30pm -05:00"
val .iformat = "January 2 2006 3:04pm -07:00"   # input format
val .format = "January 2 2006 3:04pm MST"       # output format
 
val .d1 = toDateTime .input, .iformat
val .d2 = .d1 + dt/PT12H/
val .d3 = toDateTime .d2, "US/Arizona"
val .d4 = toDateTime .d2, ZLS
val .d5 = toDateTime .d2, "Z"
val .d6 = toDateTime .d2, "+02:30"
val .d7 = toDateTime .d2, "EST"
 
writeln "input string: ", .input
writeln "input format string: ", .iformat
writeln "output format string: ", .format
writeln()
 
writeln $"original: \.d1; (\.d1:dt.format;)"
writeln $"+12 hours: \.d2; (\.d2:dt.format;)"
writeln $"in Arizona: \.d3; (\.d3:dt.format;)"
writeln $"in local time zone: \.d4; (\.d4:dt.format;)"
writeln $"in UTC: \.d5; (\.d5:dt.format;)"
writeln $"+02:30 time zone: \.d6; (\.d6:dt.format;)"
writeln $"in EST: \.d7; (\.d7:dt.format;)"