diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-05 10:38:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-01-05 10:39:17 +0000 |
commit | d6d80a17444c90259c5bfdacb84c61e6bfece655 (patch) | |
tree | 157bff98bd572acf0b64cd5d478b0bdac87a37ae /tests/datetime/test_timezone.py | |
parent | Releasing debian version 2.1.2-4. (diff) | |
download | pendulum-d6d80a17444c90259c5bfdacb84c61e6bfece655.tar.xz pendulum-d6d80a17444c90259c5bfdacb84c61e6bfece655.zip |
Merging upstream version 3.0.0~a1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/datetime/test_timezone.py')
-rw-r--r-- | tests/datetime/test_timezone.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/datetime/test_timezone.py b/tests/datetime/test_timezone.py new file mode 100644 index 0000000..343435d --- /dev/null +++ b/tests/datetime/test_timezone.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +import pendulum + +from tests.conftest import assert_datetime + + +def test_in_timezone(): + d = pendulum.datetime(2015, 1, 15, 18, 15, 34) + now = pendulum.datetime(2015, 1, 15, 18, 15, 34) + assert d.timezone_name == "UTC" + assert_datetime(d, now.year, now.month, now.day, now.hour, now.minute) + + d = d.in_timezone("Europe/Paris") + assert d.timezone_name == "Europe/Paris" + assert_datetime(d, now.year, now.month, now.day, now.hour + 1, now.minute) + + +def test_in_tz(): + d = pendulum.datetime(2015, 1, 15, 18, 15, 34) + now = pendulum.datetime(2015, 1, 15, 18, 15, 34) + assert d.timezone_name == "UTC" + assert_datetime(d, now.year, now.month, now.day, now.hour, now.minute) + + d = d.in_tz("Europe/Paris") + assert d.timezone_name == "Europe/Paris" + assert_datetime(d, now.year, now.month, now.day, now.hour + 1, now.minute) + + +def test_astimezone(): + d = pendulum.datetime(2015, 1, 15, 18, 15, 34) + now = pendulum.datetime(2015, 1, 15, 18, 15, 34) + assert d.timezone_name == "UTC" + assert_datetime(d, now.year, now.month, now.day, now.hour, now.minute) + + d = d.astimezone(pendulum.timezone("Europe/Paris")) + assert d.timezone_name == "Europe/Paris" + assert_datetime(d, now.year, now.month, now.day, now.hour + 1, now.minute) |