Date manipulation: Difference between revisions

Line 1,797:
 
<syntaxhighlight lang="langur">val .input = "March 7 2009 7:30pm -05:00"
val .iformat = "January 2 2006 3:04pm -07:00" # input format
val .formatoformat = "January 2 2006 3:04pm MST" # output format
 
val .d1 = toDateTimedatetime .input, .iformat
val .d2 = .d1 + dtdr/PT12H/
val .d3 = toDateTimedatetime .d2, "US/Arizona"
val .d4 = toDateTimedatetime .d2, ZLSzls
val .d5 = toDateTimedatetime .d2, "Z"
val .d6 = toDateTimedatetime .d2, "+02:30"
val .d7 = toDateTimedatetime .d2, "EST"
 
writeln "input string: ", .input
writeln "input format string: ", .iformat
writeln "output format string: ", .formatoformat
writeln()
 
writeln $"original: \.d1; (\.d1:dt.formatoformat;)"
writeln $"+12 hours: \.d2; (\.d2:dt.formatoformat;)"
writeln $"in Arizona: \.d3; (\.d3:dt.formatoformat;)"
writeln $"in local time zone: \.d4; (\.d4:dt.formatoformat;)"
writeln $"in UTC: \.d5; (\.d5:dt.formatoformat;)"
writeln $"+02:30 time zone: \.d6; (\.d6:dt.formatoformat;)"
writeln $"in EST: \.d7; (\.d7:dt.formatoformat;)"</syntaxhighlight>
 
{{out}}
995

edits