Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/docs/duration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ It has many improvements over the base class.

```python
>>> import pendulum
>>> from datetime import datetime
>>> import datetime

>>> d1 = datetime(2012, 1, 1, 1, 2, 3, tzinfo=pytz.UTC)
>>> d2 = datetime(2011, 12, 31, 22, 2, 3, tzinfo=pytz.UTC)
>>> d1 = datetime.datetime(2012, 1, 1, 1, 2, 3, tzinfo=datetime.UTC)
>>> d2 = datetime.datetime(2011, 12, 31, 22, 2, 3, tzinfo=datetime.UTC)
>>> delta = d2 - d1
>>> delta.days
-1
Expand Down
46 changes: 11 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Repository = "https://github.com/sdispater/pendulum"

[tool.poetry.group.test.dependencies]
pytest = "^7.1.2"
pytz = ">=2022.1"
time-machine = ">=2.16.0"
pytest-benchmark = "^4.0.0"

Expand All @@ -51,7 +50,6 @@ pre-commit = "^3.0.0"
[tool.poetry.group.typing.dependencies]
mypy = "^1.3.0"
types-python-dateutil = "^2.8.19"
types-pytz = ">=2022.7.1.2"

[tool.poetry.group.dev.dependencies]
babel = "^2.10.3"
Expand Down
20 changes: 10 additions & 10 deletions tests/datetime/test_comparison.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

from datetime import datetime
import zoneinfo

import pytz
from datetime import datetime

import pendulum

Expand Down Expand Up @@ -99,7 +99,7 @@ def test_greater_than_false():
def test_greater_than_with_timezone_true():
d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d2 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 8, 59, 59))
d3 = datetime(2000, 1, 1, 8, 59, 59, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))

assert d1 > d2
assert d1 > d3
Expand All @@ -108,7 +108,7 @@ def test_greater_than_with_timezone_true():
def test_greater_than_with_timezone_false():
d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d2 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 9, 0, 1))
d3 = datetime(2000, 1, 1, 9, 0, 1, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))

assert not d1 > d2
assert not d1 > d3
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_greater_than_or_equal_false():
def test_greater_than_or_equal_with_timezone_true():
d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d2 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 8, 59, 59))
d3 = datetime(2000, 1, 1, 8, 59, 59, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))

assert d1 >= d2
assert d1 >= d3
Expand All @@ -153,7 +153,7 @@ def test_greater_than_or_equal_with_timezone_true():
def test_greater_than_or_equal_with_timezone_false():
d1 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d2 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
d3 = pytz.timezone("America/Vancouver").localize(datetime(2000, 1, 1, 9, 0, 1))
d3 = datetime(2000, 1, 1, 9, 0, 1, tzinfo=zoneinfo.ZoneInfo("America/Vancouver"))

assert not d1 >= d2
assert not d1 >= d3
Expand All @@ -180,7 +180,7 @@ def test_less_than_false():
def test_less_than_with_timezone_true():
d1 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))

assert d1 < d2
assert d1 < d3
Expand All @@ -189,7 +189,7 @@ def test_less_than_with_timezone_true():
def test_less_than_with_timezone_false():
d1 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))

assert not d1 < d2
assert not d1 < d3
Expand Down Expand Up @@ -225,7 +225,7 @@ def test_less_than_or_equal_false():
def test_less_than_or_equal_with_timezone_true():
d1 = pendulum.datetime(2000, 1, 1, 8, 59, 59, tz="America/Vancouver")
d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))

assert d1 <= d2
assert d1 <= d3
Expand All @@ -234,7 +234,7 @@ def test_less_than_or_equal_with_timezone_true():
def test_less_than_or_equal_with_timezone_false():
d1 = pendulum.datetime(2000, 1, 1, 9, 0, 1, tz="America/Vancouver")
d2 = pendulum.datetime(2000, 1, 1, 12, 0, 0, tz="America/Toronto")
d3 = pytz.timezone("America/Toronto").localize(datetime(2000, 1, 1, 12, 0, 0))
d3 = datetime(2000, 1, 1, 12, 0, 0, tzinfo=zoneinfo.ZoneInfo("America/Toronto"))

assert not d1 <= d2
assert not d1 <= d3
Expand Down
14 changes: 7 additions & 7 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

import zoneinfo

from datetime import datetime

import pytest
import pytz

import pendulum

Expand Down Expand Up @@ -102,18 +103,17 @@ def test_precise_diff_timezone() -> None:
assert_diff(diff, days=1, hours=5)
assert diff.total_days == 1

# pytz
paris_pytz = pytz.timezone("Europe/Paris")
toronto_pytz = pytz.timezone("America/Toronto")
paris_tz = zoneinfo.ZoneInfo("Europe/Paris")
toronto_tz = zoneinfo.ZoneInfo("America/Toronto")

dt1 = paris_pytz.localize(datetime(2013, 3, 31, 1, 30))
dt2 = paris_pytz.localize(datetime(2013, 4, 1, 1, 30))
dt1 = datetime(2013, 3, 31, 1, 30, tzinfo=paris_tz)
dt2 = datetime(2013, 4, 1, 1, 30, tzinfo=paris_tz)

diff = precise_diff(dt1, dt2)
assert_diff(diff, days=1, hours=0)
assert diff.total_days == 1

dt2 = toronto_pytz.localize(datetime(2013, 4, 1, 1, 30))
dt2 = datetime(2013, 4, 1, 1, 30, tzinfo=toronto_tz)

diff = precise_diff(dt1, dt2)
assert_diff(diff, days=1, hours=5)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

import zoneinfo

from datetime import date
from datetime import datetime
from datetime import time

import pytz

from dateutil import tz

import pendulum
Expand All @@ -25,8 +25,8 @@ def test_instance_with_aware_datetime() -> None:
assert now.timezone_name == "Europe/Paris"


def test_instance_with_aware_datetime_pytz() -> None:
now = pendulum.instance(datetime.now(pytz.timezone("Europe/Paris")))
def test_instance_with_aware_datetime_zoneinfo() -> None:
now = pendulum.instance(datetime.now(zoneinfo.ZoneInfo("Europe/Paris")))
assert now.timezone_name == "Europe/Paris"


Expand Down Expand Up @@ -57,7 +57,7 @@ def test_instance_with_aware_time() -> None:


def test_safe_timezone_with_tzinfo_objects() -> None:
tz = _safe_timezone(pytz.timezone("Europe/Paris"))
tz = _safe_timezone(zoneinfo.ZoneInfo("Europe/Paris"))

assert isinstance(tz, Timezone)
assert tz.name == "Europe/Paris"
5 changes: 3 additions & 2 deletions tests/time/test_sub.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

import zoneinfo

from datetime import time
from datetime import timedelta

import pytest
import pytz

import pendulum

Expand Down Expand Up @@ -87,7 +88,7 @@ def test_subtract_time():
t = Time(12, 34, 56)
t1 = Time(1, 1, 1)
t2 = time(1, 1, 1)
t3 = time(1, 1, 1, tzinfo=pytz.timezone("Europe/Paris"))
t3 = time(1, 1, 1, tzinfo=zoneinfo.ZoneInfo("Europe/Paris"))

diff = t - t1
assert isinstance(diff, pendulum.Duration)
Expand Down
Loading