Skip to content

Fix tzrange default DST offset when standard offset is omitted - #1614

Open
AryanRG wants to merge 2 commits into
dateutil:masterfrom
AryanRG:fix/tzrange-default-dst-offset
Open

AryanRG wants to merge 2 commits into
dateutil:masterfrom
AryanRG:fix/tzrange-default-dst-offset

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026 •

Copy link
Copy Markdown

Summary of changes

tzrange("STD", dstabbr="DST") currently loses the documented default one-hour DST offset when the optional standard offset is omitted. Use the already-normalized standard offset when computing that default, and cover omitted, None, explicit-zero, and explicit-DST-offset cases, plus checks around both default transitions.

With datetime(2014, 7, 15, 12, tzinfo=tzrange("STD", dstabbr="DST")), the current result is 2014-07-15T12:00:00+00:00 with zero DST; the documented default is 2014-07-15T12:00:00+01:00 with one hour of DST. The equivalent call with an explicit zero standard offset already produces the latter result. This PR is the bug report; there is no separate issue to close.

Tests

  • Before the fix: 5 new cases failed, 11 passed.
  • After the fix: 16 targeted cases passed.
  • TZ=America/New_York .venv/bin/python -m pytest -q -p no:cacheprovider tests --tb=short: 2,047 passed, 47 skipped, 17 xfailed (Python 3.13.12, macOS arm64).
  • Darker/isort and git diff --check: passed.

Other Python versions and platforms remain for hosted CI.

Pull Request Checklist

  • Changes have tests
  • Authors have been added to AUTHORS.md
  • News fragment added in changelog.d/1614.bugfix.rst

AI assistance was used to prepare the implementation and tests.

@AryanRG
AryanRG marked this pull request as ready for review October 17, 2026 07:59

This branch has not been deployed

No deployments
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.

1 participant