From 417dd97a9ba2c5884b8637487782e6d5a967b320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C5=8Dan?= Date: Fri, 1 May 2026 05:03:12 -0600 Subject: [PATCH] feat: add 13 commonly-used timezone abbreviations Add timezone abbreviations that are widely used in real-world date strings but were missing from Time::Zone, causing str2time() to return undef: Standard zones: - ACST (Australian Central Standard, UTC+9:30) - AWST (Australian Western Standard, UTC+8, alias for WST) - SAST (South African Standard, UTC+2) - EAT (East Africa, UTC+3) - TRT (Turkey, UTC+3) - IRST (Iran Standard, UTC+3:30) - AFT (Afghanistan, UTC+4:30) - PKT (Pakistan Standard, UTC+5) - NPT (Nepal, UTC+5:45) Daylight zones: - ACDT (Australian Central Daylight, UTC+10:30) - AWDT (Australian Western Daylight, UTC+9) - WEST (Western European Summer, UTC+1) - IRDT (Iran Daylight, UTC+4:30) Co-Authored-By: Claude Opus 4.6 --- lib/Time/Zone.pm | 16 +++++++++++++--- t/zone.t | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/Time/Zone.pm b/lib/Time/Zone.pm index 072169e..4859e66 100644 --- a/lib/Time/Zone.pm +++ b/lib/Time/Zone.pm @@ -206,9 +206,12 @@ CONFIG: { "fst" => +2*3600, # French Summer "eest" => +3*3600, # Eastern European Summer "msd" => +4*3600, # Moscow Daylight (historical; Russia abolished DST permanently in Oct 2014) + "west" => +1*3600, # Western European Summer + "irdt" => +4*3600+1800,# Iran Daylight "wadt" => +8*3600, # West Australian Daylight + "awdt" => +9*3600, # Australian Western Daylight "kdt" => +10*3600, # Korean Daylight - # "cadt" => +10*3600+1800, # Central Australian Daylight + "acdt" => +10*3600+1800,# Australian Central Daylight "aedt" => +11*3600, # Eastern Australian Daylight "eadt" => +11*3600, # Eastern Australian Daylight "nzd" => +13*3600, # New Zealand Daylight @@ -252,13 +255,19 @@ CONFIG: { "swt" => +1*3600, # Swedish Winter "set" => +1*3600, # Seychelles "fwt" => +1*3600, # French Winter + "sast" => +2*3600, # South African Standard "eet" => +2*3600, # Eastern Europe, USSR Zone 1 "ukr" => +2*3600, # Ukraine "bt" => +3*3600, # Baghdad, USSR Zone 2 + "eat" => +3*3600, # East Africa "msk" => +3*3600, # Moscow (UTC+3; was UTC+4 in 2011-2014 when Russia used permanent DST, reverted Oct 2014) - # "it" => +3*3600+1800,# Iran + "trt" => +3*3600, # Turkey + "irst" => +3*3600+1800,# Iran Standard + "aft" => +4*3600+1800,# Afghanistan "zp4" => +4*3600, # USSR Zone 3 + "pkt" => +5*3600, # Pakistan Standard "zp5" => +5*3600, # USSR Zone 4 + "npt" => +5*3600+2700,# Nepal (+5:45) "ist" => +5*3600+1800,# Indian Standard "zp6" => +6*3600, # USSR Zone 5 # For completeness. NST is also Newfoundland Stanard, and SST is also Swedish Summer. @@ -267,12 +276,13 @@ CONFIG: { "ict" => +7*3600, # Indochina Time # "jt" => +7*3600+1800,# Java (3pm in Cronusland!) "wst" => +8*3600, # West Australian Standard + "awst" => +8*3600, # Australian Western Standard "pht" => +8*3600, # Philippine Time "hkt" => +8*3600, # Hong Kong "cct" => +8*3600, # China Coast, USSR Zone 7 "jst" => +9*3600, # Japan Standard, USSR Zone 8 "kst" => +9*3600, # Korean Standard - # "cast" => +9*3600+1800,# Central Australian Standard + "acst" => +9*3600+1800,# Australian Central Standard "aest" => +10*3600, # Eastern Australian Standard "east" => +10*3600, # Eastern Australian Standard "gst" => +10*3600, # Guam Standard, USSR Zone 9 diff --git a/t/zone.t b/t/zone.t index e3c5cf4..17c75a6 100644 --- a/t/zone.t +++ b/t/zone.t @@ -40,6 +40,29 @@ is(tz_offset("PHT"), 28800, "tz_offset PHT = 28800 (Philippine Time, UTC+8)"); is(tz_offset("ict"), 25200, "tz_offset ict case insensitive"); is(tz_offset("pht"), 28800, "tz_offset pht case insensitive"); +# tz_offset: Australian timezone abbreviations +is(tz_offset("ACST"), 34200, "tz_offset ACST = 34200 (Australian Central Standard, UTC+9:30)"); +is(tz_offset("ACDT"), 37800, "tz_offset ACDT = 37800 (Australian Central Daylight, UTC+10:30)"); +is(tz_offset("AEST"), 36000, "tz_offset AEST = 36000 (Australian Eastern Standard, UTC+10)"); +is(tz_offset("AEDT"), 39600, "tz_offset AEDT = 39600 (Australian Eastern Daylight, UTC+11)"); +is(tz_offset("AWST"), 28800, "tz_offset AWST = 28800 (Australian Western Standard, UTC+8)"); +is(tz_offset("AWDT"), 32400, "tz_offset AWDT = 32400 (Australian Western Daylight, UTC+9)"); + +# tz_offset: African timezone abbreviations +is(tz_offset("SAST"), 7200, "tz_offset SAST = 7200 (South African Standard, UTC+2)"); +is(tz_offset("EAT"), 10800, "tz_offset EAT = 10800 (East Africa, UTC+3)"); + +# tz_offset: Middle East and South Asian timezone abbreviations +is(tz_offset("TRT"), 10800, "tz_offset TRT = 10800 (Turkey, UTC+3)"); +is(tz_offset("IRST"), 12600, "tz_offset IRST = 12600 (Iran Standard, UTC+3:30)"); +is(tz_offset("IRDT"), 16200, "tz_offset IRDT = 16200 (Iran Daylight, UTC+4:30)"); +is(tz_offset("AFT"), 16200, "tz_offset AFT = 16200 (Afghanistan, UTC+4:30)"); +is(tz_offset("PKT"), 18000, "tz_offset PKT = 18000 (Pakistan Standard, UTC+5)"); +is(tz_offset("NPT"), 20700, "tz_offset NPT = 20700 (Nepal, UTC+5:45)"); + +# tz_offset: European DST abbreviations +is(tz_offset("WEST"), 3600, "tz_offset WEST = 3600 (Western European Summer, UTC+1)"); + # tz_offset: unknown zone returns undef is(tz_offset("BOGUS"), undef, "tz_offset unknown zone returns undef");