summaryrefslogtreecommitdiffstats
path: root/tests/datetime/test_create_from_timestamp.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-05 10:38:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-05 10:38:34 +0000
commite3bdad36cc3a1a00c1e6772ca1c1898085ab73e0 (patch)
tree34512072a667ae716fd262e7b37e733e60fe4d89 /tests/datetime/test_create_from_timestamp.py
parentAdding upstream version 2.1.2. (diff)
downloadpendulum-e3bdad36cc3a1a00c1e6772ca1c1898085ab73e0.tar.xz
pendulum-e3bdad36cc3a1a00c1e6772ca1c1898085ab73e0.zip
Adding upstream version 3.0.0~a1.upstream/3.0.0_a1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/datetime/test_create_from_timestamp.py')
-rw-r--r--tests/datetime/test_create_from_timestamp.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/datetime/test_create_from_timestamp.py b/tests/datetime/test_create_from_timestamp.py
new file mode 100644
index 0000000..121a7c2
--- /dev/null
+++ b/tests/datetime/test_create_from_timestamp.py
@@ -0,0 +1,24 @@
+from __future__ import annotations
+
+import pendulum
+
+from pendulum import timezone
+from tests.conftest import assert_datetime
+
+
+def test_create_from_timestamp_returns_pendulum():
+ d = pendulum.from_timestamp(pendulum.datetime(1975, 5, 21, 22, 32, 5).timestamp())
+ assert_datetime(d, 1975, 5, 21, 22, 32, 5)
+ assert d.timezone_name == "UTC"
+
+
+def test_create_from_timestamp_with_timezone_string():
+ d = pendulum.from_timestamp(0, "America/Toronto")
+ assert d.timezone_name == "America/Toronto"
+ assert_datetime(d, 1969, 12, 31, 19, 0, 0)
+
+
+def test_create_from_timestamp_with_timezone():
+ d = pendulum.from_timestamp(0, timezone("America/Toronto"))
+ assert d.timezone_name == "America/Toronto"
+ assert_datetime(d, 1969, 12, 31, 19, 0, 0)