Perform conversion and arithmetic on dates
based on Time Zone Database Parser
similar project: time-and-number
carbon | cocoa | win32 | win64 |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
Note: The timezone database and windowsZones.xml are preinstalled locally in Resources/tzdata
.
zones:=TZ Get zones
Parameter | Type | Description |
---|---|---|
zones | TEXT | json |
result:=TZ Convert (time;fmt_in;zone_out;fmt_out)
Parameter | Type | Description |
---|---|---|
time | TEXT | |
fmt_in | TEXT | strftime |
zone_out | TEXT | |
fmt_out | TEXT | strftime |
offset | LONGINT | seconds |
//RFC to ISO conversion (specify format only)
$time:="Sun Sep 16 01:03:52 -0500 1973"
$fmt_in:="%a %b %d %T %z %Y"
$zone_out:=""
$fmt_out:="%FT%TZ"
$utc:=TZ Convert ($time;$fmt_in;$zone_out;$fmt_out)
//1973-09-16T06:03:52.000Z
//RFC to ISO conversion in zone (specify format and zone)
$time:="Sun Sep 16 01:03:52 -0500 1973"
$fmt_in:="%a %b %d %T %z %Y"
$zone_out:="Australia/Sydney"
$fmt_out:="%FT%T %Z"
$aest:=TZ Convert ($time;$fmt_in;$zone_out;$fmt_out)
//1973-09-16 16:03:52.000 AEST
//duration over time zone change
$departure:="1978-12-30 12:01:00 -0500"
$fmt_in:="%F %T %z"
$fmt_out:="%F %T %z"
$zone_out:="Asia/Tehran"
$flight:=?14:44:00?
$arrival:=TZ Convert ($departure;\
$fmt_in;\
$zone_out;\
$fmt_out;\
$flight+0)
//1978-12-31 11:45:00.000 +0400
//day later...
$departure:=TZ Convert ($departure;\
$fmt_in;\
"America/New_York";\
$fmt_out;\
?24:00:00?+0)
//1978-12-31 12:01:00.000 -0500
$arrival:=TZ Convert ($departure;\
$fmt_in;\
$zone_out;\
$fmt_out;\
$flight+0)
//1979-01-01 11:15:00.000 +0330