Skip to content

Replace pytz with ZoneInfo + misc datetime fixes#13

Merged
thombashi merged 2 commits intothombashi:masterfrom
JYOuyang:jyo-tz
May 9, 2026
Merged

Replace pytz with ZoneInfo + misc datetime fixes#13
thombashi merged 2 commits intothombashi:masterfrom
JYOuyang:jyo-tz

Conversation

@JYOuyang
Copy link
Copy Markdown
Contributor

@JYOuyang JYOuyang commented May 5, 2026

Hi!

Big one is using zoneinfo.ZoneInfo in place of pytz since this library is 3.9+. Mostly just .localize to .replace but I added a test for the PEP 495 / default fold=0 behaviour. Technically this is a behaviour change since pytz defaults to is_dst=False but this would align more consistently with the current stdlib semantics / PEP 495. See test_normal_datetime_dst_ambiguous_default_fold

Smaller fixes:

Simplified __from_timestamp; datetime.fromtimestamp() accepts a float (and preserves microseconds) so we test Integer/RealNumber against timestamp and then a single fromtimestamp(float(...)) call. (Adjusted the guards to is not None since technically 0 / 0.0 are valid timestamps 🤷)

Simplified __get_timedelta_sec: Just use the timedelta.total_seconds(). No behaviour change.

Copy link
Copy Markdown
Owner

@thombashi thombashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request.

@thombashi thombashi merged commit f65a5b3 into thombashi:master May 9, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants