Date manipulation: Difference between revisions

(One intermediate revision by the same user not shown)
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.format oformat;)"
writeln $"+12 hours: \.d2; (\.d2:dt.format oformat;)"
writeln $"in Arizona: \.d3; (\.d3:dt.format oformat;)"
writeln $"in local time zone: \.d4; (\.d4:dt.format oformat;)"
writeln $"in UTC: \.d5; (\.d5:dt.format oformat;)"
writeln $"+02:30 time zone: \.d6; (\.d6:dt.format oformat;)"
writeln $"in EST: \.d7; (\.d7:dt.format oformat;)"</syntaxhighlight>
 
{{out}}
990

edits