Skip to content

Preserve fold when removing timezone information - #1099

Open
FFspiky wants to merge 1 commit into
python-pendulum:masterfrom
FFspiky:fix/preserve-naive-fold
Open

FFspiky wants to merge 1 commit into
python-pendulum:masterfrom
FFspiky:fix/preserve-naive-fold

Conversation

@FFspiky

@FFspiky FFspiky commented Nov 24, 2026

Copy link
Copy Markdown

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

DateTime.naive() loses fold when it removes the timezone. Detaching and reattaching the timezone to the second 01:30 on November 3, 2024 in New York therefore gives a timestamp an hour earlier. Lord Howe’s half-hour rollback gives a 30-minute difference.

Pass the original fold to the constructor. The regression tests exercise both occurrences in each zone, check the wall time and microseconds, and verify that restoring the original timezone recovers the timestamp. #1056 covers the separate DateTime.time() method.

Both regressions fail on master. The full test suite passes in pure Python and with the published 3.3.0 Rust extension, with 1,874 passed and 3 skipped in each mode on CPython 3.13.2/macOS arm64. Ruff and mypy also pass.

OpenAI Codex assisted with the implementation and validation.

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