From 9e0736d80034a3722dbfe07b0f3a29c52c5b61bd Mon Sep 17 00:00:00 2001 From: jamesboi951 <45056053+jamesboi951@users.noreply.github.com> Date: Mon, 18 Apr 2022 15:48:37 -0400 Subject: [PATCH 1/2] Update arrow.py --- arrow/arrow.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/arrow/arrow.py b/arrow/arrow.py index 1ede107f..590eff95 100644 --- a/arrow/arrow.py +++ b/arrow/arrow.py @@ -4,7 +4,6 @@ """ - import calendar import re import sys @@ -1828,6 +1827,32 @@ def _get_datetime( else: raise ValueError(f"{expr!r} not recognized as a datetime or timestamp.") + @classmethod + def iana_timezone(cls, time_zone: str) -> str: + iana_time_zone_map = { + "ACDT": "Austrailian Central Daylight Time", + "ACST": "Australian Central Standard Time", + "ADT": "Atlantic Daylight Time", + "AEDT": "Australian Eastern Daylight Time", + "AEST": "Australian Eastern Standard Time", + "AHDT": "Alaska-Hawaii Daylight Time", + "AHST": "Alaska-Hawaii Standard Time", + "AKDT": "Alaska Daylight Time", + "AKST": "Alaska Standard Time", + "AMT": "Armenia Time", + "AST": "Atlantic Standard Time", + "AWDT": "Australian Western Daylight Time", + "AWST": "Australian Western Standard Time", + "AWT": "Australian Western Standard Time", + "BDST": "British Double Summer Time", + "BDT": "Brunei Time", + "BMT": "Biel Mean Time", + "BST": "British Summer Time", + } + if iana_time_zone_map.get(time_zone) == None: + raise ValueError(f"not a recognized iana timezone!") + return iana_time_zone_map[time_zone] + @classmethod def _get_frames(cls, name: _T_FRAMES) -> Tuple[str, str, int]: """Finds relevant timeframe and steps for use in range and span methods. From 0df342cd06b649b483da4fd04e37608857fbd6ab Mon Sep 17 00:00:00 2001 From: jamesboi951 <45056053+jamesboi951@users.noreply.github.com> Date: Mon, 18 Apr 2022 15:49:11 -0400 Subject: [PATCH 2/2] Update test_arrow.py --- tests/test_arrow.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_arrow.py b/tests/test_arrow.py index 38d5000a..5a1f1ce7 100644 --- a/tests/test_arrow.py +++ b/tests/test_arrow.py @@ -3080,6 +3080,28 @@ def test_value_error_exception(self): target.span("week", week_start=55) +class TestIanaTimeZone: + def test_acdt(self): + sample_string = "Austrailian Central Daylight Time" + test_string = arrow.Arrow.iana_timezone("ACDT") + assert sample_string == test_string + + def test_acst(self): + sample_string = "Australian Central Standard Time" + test_string = arrow.Arrow.iana_timezone("ACST") + assert sample_string == test_string + + def test_adt(self): + sample_string = "Atlantic Daylight Time" + test_string = arrow.Arrow.iana_timezone("ADT") + assert sample_string == test_string + + def test_aedt(self): + sample_string = "Australian Eastern Daylight Time" + test_string = arrow.Arrow.iana_timezone("AEDT") + assert sample_string == test_string + + class TestArrowUtil: def test_get_datetime(self):