From 29d364cf1ba8d00cd755d14f252b4055ee21d323 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 4 Oct 2023 20:09:32 +0200 Subject: [PATCH] Ensure that current IANA names are in the Windows mapping --- CHANGES.txt | 3 ++- tzlocal/unix.py | 1 + tzlocal/windows_tz.py | 38 ++++++++++++++++++++++++++++---------- update_windows_mappings.py | 15 ++++++++++----- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 5eec893..04e5f9d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,7 +4,8 @@ Changes 5.0.2 (unreleased) ------------------ -- Nothing changed yet. +- The Unicode data doesn't change tz names when IANA does, so what is current + in IANA is treated as an alias in Unicode data. This version handles that. 5.0.1 (2023-05-15) diff --git a/tzlocal/unix.py b/tzlocal/unix.py index f510c12..5178e0d 100644 --- a/tzlocal/unix.py +++ b/tzlocal/unix.py @@ -17,6 +17,7 @@ log = logging.getLogger("tzlocal") + def _get_localzone_name(_root="/"): """Tries to find the local timezone configuration. diff --git a/tzlocal/windows_tz.py b/tzlocal/windows_tz.py index ed49c4a..3d47576 100644 --- a/tzlocal/windows_tz.py +++ b/tzlocal/windows_tz.py @@ -206,7 +206,13 @@ "America/Anguilla": "SA Western Standard Time", "America/Antigua": "SA Western Standard Time", "America/Araguaina": "Tocantins Standard Time", + "America/Argentina/Buenos_Aires": "Argentina Standard Time", + "America/Argentina/Catamarca": "Argentina Standard Time", + "America/Argentina/ComodRivadavia": "Argentina Standard Time", + "America/Argentina/Cordoba": "Argentina Standard Time", + "America/Argentina/Jujuy": "Argentina Standard Time", "America/Argentina/La_Rioja": "Argentina Standard Time", + "America/Argentina/Mendoza": "Argentina Standard Time", "America/Argentina/Rio_Gallegos": "Argentina Standard Time", "America/Argentina/Salta": "Argentina Standard Time", "America/Argentina/San_Juan": "Argentina Standard Time", @@ -254,6 +260,7 @@ "America/El_Salvador": "Central America Standard Time", "America/Ensenada": "Pacific Standard Time (Mexico)", "America/Fort_Nelson": "US Mountain Standard Time", + "America/Fort_Wayne": "US Eastern Standard Time", "America/Fortaleza": "SA Eastern Standard Time", "America/Glace_Bay": "Atlantic Standard Time", "America/Godthab": "Greenland Standard Time", @@ -267,6 +274,7 @@ "America/Halifax": "Atlantic Standard Time", "America/Havana": "Cuba Standard Time", "America/Hermosillo": "US Mountain Standard Time", + "America/Indiana/Indianapolis": "US Eastern Standard Time", "America/Indiana/Knox": "Central Standard Time", "America/Indiana/Marengo": "US Eastern Standard Time", "America/Indiana/Petersburg": "Eastern Standard Time", @@ -280,6 +288,7 @@ "America/Jamaica": "SA Pacific Standard Time", "America/Jujuy": "Argentina Standard Time", "America/Juneau": "Alaskan Standard Time", + "America/Kentucky/Louisville": "Eastern Standard Time", "America/Kentucky/Monticello": "Eastern Standard Time", "America/Knox_IN": "Central Standard Time", "America/Kralendijk": "SA Western Standard Time", @@ -314,6 +323,7 @@ "America/North_Dakota/Beulah": "Central Standard Time", "America/North_Dakota/Center": "Central Standard Time", "America/North_Dakota/New_Salem": "Central Standard Time", + "America/Nuuk": "Greenland Standard Time", "America/Ojinaga": "Central Standard Time", "America/Panama": "SA Pacific Standard Time", "America/Pangnirtung": "Eastern Standard Time", @@ -331,6 +341,7 @@ "America/Regina": "Canada Central Standard Time", "America/Resolute": "Central Standard Time", "America/Rio_Branco": "SA Pacific Standard Time", + "America/Rosario": "Argentina Standard Time", "America/Santa_Isabel": "Pacific Standard Time (Mexico)", "America/Santarem": "SA Eastern Standard Time", "America/Santiago": "Pacific SA Standard Time", @@ -367,7 +378,7 @@ "Antarctica/Palmer": "SA Eastern Standard Time", "Antarctica/Rothera": "SA Eastern Standard Time", "Antarctica/South_Pole": "New Zealand Standard Time", - "Antarctica/Syowa": "Arab Standard Time", + "Antarctica/Syowa": "E. Africa Standard Time", "Antarctica/Vostok": "Central Asia Standard Time", "Arctic/Longyearbyen": "W. Europe Standard Time", "Asia/Aden": "Arab Standard Time", @@ -403,6 +414,7 @@ "Asia/Gaza": "West Bank Standard Time", "Asia/Harbin": "China Standard Time", "Asia/Hebron": "West Bank Standard Time", + "Asia/Ho_Chi_Minh": "SE Asia Standard Time", "Asia/Hong_Kong": "China Standard Time", "Asia/Hovd": "W. Mongolia Standard Time", "Asia/Irkutsk": "North Asia East Standard Time", @@ -414,8 +426,10 @@ "Asia/Kamchatka": "Russia Time Zone 11", "Asia/Karachi": "Pakistan Standard Time", "Asia/Kashgar": "Central Asia Standard Time", + "Asia/Kathmandu": "Nepal Standard Time", "Asia/Katmandu": "Nepal Standard Time", "Asia/Khandyga": "Yakutsk Standard Time", + "Asia/Kolkata": "India Standard Time", "Asia/Krasnoyarsk": "North Asia Standard Time", "Asia/Kuala_Lumpur": "Singapore Standard Time", "Asia/Kuching": "Singapore Standard Time", @@ -463,6 +477,7 @@ "Asia/Vientiane": "SE Asia Standard Time", "Asia/Vladivostok": "Vladivostok Standard Time", "Asia/Yakutsk": "Yakutsk Standard Time", + "Asia/Yangon": "Myanmar Standard Time", "Asia/Yekaterinburg": "Ekaterinburg Standard Time", "Asia/Yerevan": "Caucasus Standard Time", "Atlantic/Azores": "Azores Standard Time", @@ -470,6 +485,7 @@ "Atlantic/Canary": "GMT Standard Time", "Atlantic/Cape_Verde": "Cape Verde Standard Time", "Atlantic/Faeroe": "GMT Standard Time", + "Atlantic/Faroe": "GMT Standard Time", "Atlantic/Jan_Mayen": "W. Europe Standard Time", "Atlantic/Madeira": "GMT Standard Time", "Atlantic/Reykjavik": "Greenwich Standard Time", @@ -553,7 +569,7 @@ "Etc/UTC": "UTC", "Etc/Universal": "UTC", "Etc/Zulu": "UTC", - "Europe/Amsterdam": "Romance Standard Time", + "Europe/Amsterdam": "W. Europe Standard Time", "Europe/Andorra": "W. Europe Standard Time", "Europe/Astrakhan": "Astrakhan Standard Time", "Europe/Athens": "GTB Standard Time", @@ -566,7 +582,7 @@ "Europe/Budapest": "Central Europe Standard Time", "Europe/Busingen": "W. Europe Standard Time", "Europe/Chisinau": "E. Europe Standard Time", - "Europe/Copenhagen": "W. Europe Standard Time", + "Europe/Copenhagen": "Romance Standard Time", "Europe/Dublin": "GMT Standard Time", "Europe/Gibraltar": "W. Europe Standard Time", "Europe/Guernsey": "GMT Standard Time", @@ -577,15 +593,16 @@ "Europe/Kaliningrad": "Kaliningrad Standard Time", "Europe/Kiev": "FLE Standard Time", "Europe/Kirov": "Russian Standard Time", + "Europe/Kyiv": "FLE Standard Time", "Europe/Lisbon": "GMT Standard Time", "Europe/Ljubljana": "Central Europe Standard Time", "Europe/London": "GMT Standard Time", - "Europe/Luxembourg": "Romance Standard Time", + "Europe/Luxembourg": "W. Europe Standard Time", "Europe/Madrid": "Romance Standard Time", "Europe/Malta": "W. Europe Standard Time", "Europe/Mariehamn": "FLE Standard Time", "Europe/Minsk": "Belarus Standard Time", - "Europe/Monaco": "Romance Standard Time", + "Europe/Monaco": "W. Europe Standard Time", "Europe/Moscow": "Russian Standard Time", "Europe/Nicosia": "GTB Standard Time", "Europe/Oslo": "W. Europe Standard Time", @@ -596,10 +613,10 @@ "Europe/Rome": "W. Europe Standard Time", "Europe/Samara": "Russia Time Zone 3", "Europe/San_Marino": "W. Europe Standard Time", - "Europe/Sarajevo": "Central Europe Standard Time", + "Europe/Sarajevo": "Central European Standard Time", "Europe/Saratov": "Saratov Standard Time", "Europe/Simferopol": "Russian Standard Time", - "Europe/Skopje": "Central Europe Standard Time", + "Europe/Skopje": "Central European Standard Time", "Europe/Sofia": "FLE Standard Time", "Europe/Stockholm": "W. Europe Standard Time", "Europe/Tallinn": "FLE Standard Time", @@ -613,7 +630,7 @@ "Europe/Vilnius": "FLE Standard Time", "Europe/Volgograd": "Volgograd Standard Time", "Europe/Warsaw": "Central European Standard Time", - "Europe/Zagreb": "Central Europe Standard Time", + "Europe/Zagreb": "Central European Standard Time", "Europe/Zaporozhye": "FLE Standard Time", "Europe/Zurich": "W. Europe Standard Time", "GB": "GMT Standard Time", @@ -630,11 +647,11 @@ "Indian/Cocos": "Myanmar Standard Time", "Indian/Comoro": "E. Africa Standard Time", "Indian/Kerguelen": "West Asia Standard Time", - "Indian/Mahe": "Arabian Standard Time", + "Indian/Mahe": "Mauritius Standard Time", "Indian/Maldives": "West Asia Standard Time", "Indian/Mauritius": "Mauritius Standard Time", "Indian/Mayotte": "E. Africa Standard Time", - "Indian/Reunion": "Arabian Standard Time", + "Indian/Reunion": "Mauritius Standard Time", "Iran": "Iran Standard Time", "Israel": "Israel Standard Time", "Jamaica": "SA Pacific Standard Time", @@ -667,6 +684,7 @@ "Pacific/Guam": "West Pacific Standard Time", "Pacific/Honolulu": "Hawaiian Standard Time", "Pacific/Johnston": "Hawaiian Standard Time", + "Pacific/Kanton": "UTC+13", "Pacific/Kiritimati": "Line Islands Standard Time", "Pacific/Kosrae": "Central Pacific Standard Time", "Pacific/Kwajalein": "UTC+12", diff --git a/update_windows_mappings.py b/update_windows_mappings.py index 3d045ee..0657656 100755 --- a/update_windows_mappings.py +++ b/update_windows_mappings.py @@ -76,12 +76,17 @@ def update_windows_zones(): for tz_name in mapping.getAttribute('type').split(' '): tz_win[tz_name] = mapping.getAttribute('other') - log.info('Adding backwards data') - # Map in the backwards compatible zone names + log.info('Adding backwards and forwards data') + # Map in the backwards (or forwards) compatible zone names for backward_compat_name, standard_name in backward.items(): - win_zone = tz_win.get(standard_name, None) - if win_zone: - tz_win[backward_compat_name] = win_zone + if backward_compat_name not in tz_win: + win_zone = tz_win.get(standard_name, None) + if win_zone: + tz_win[backward_compat_name] = win_zone + if standard_name not in tz_win: + win_zone = tz_win.get(backward_compat_name, None) + if win_zone: + tz_win[standard_name] = win_zone # Etc/UTC is a common but non-standard alias for Etc/GMT: tz_win['Etc/UTC'] = 'UTC'