Date manipulation: Difference between revisions

added langur language example
m (→‎{{header|Raku}}: Fix comments: Perl 6 --> Raku)
(added langur language example)
Line 1,466:
March 08 2009 7:30am EST
March 08 2009 5:30am MST
</pre>
 
=={{header|langur}}==
Testing with Go 1.14.1 on Linux, the time package doesn't seem to parse "EST" correctly, and it seems to fail silently. Given these conditions, I use "-05:00" instead of "EST" in the input string.
 
{{works with|langur|0.10.1}}
<lang langur>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;)"</lang>
 
{{out}}
<pre>input string: March 7 2009 7:30pm -05:00
input format string: January 2 2006 3:04pm -07:00
output format string: January 2 2006 3:04pm MST
 
original: 2009-03-07T19:30:00-05:00 (March 7 2009 7:30pm -0500)
+12 hours: 2009-03-08T07:30:00-05:00 (March 8 2009 7:30am -0500)
in Arizona: 2009-03-08T05:30:00-07:00 (March 8 2009 5:30am MST)
in local time zone: 2009-03-08T07:30:00-05:00 (March 8 2009 7:30am CDT)
in UTC: 2009-03-08T12:30:00Z (March 8 2009 12:30pm UTC)
+02:30 time zone: 2009-03-08T15:00:00+02:30 (March 8 2009 3:00pm +0230)
in EST: 2009-03-08T07:30:00-05:00 (March 8 2009 7:30am EST)
</pre>
 
1,006

edits