Skip to content

Count elapsed time across DST in timesince - #56

Draft
pralav-25 wants to merge 1 commit into
wolph:developfrom
pralav-25:fix-timesince-dst-elapsed-time
Draft

pralav-25 wants to merge 1 commit into
wolph:developfrom
pralav-25:fix-timesince-dst-elapsed-time

Conversation

@pralav-25

Copy link
Copy Markdown

timesince subtracts the input from datetime.now(input.tzinfo). When both share the same changing timezone, Python ignores UTC-offset changes and fold: the two occurrences of 2026-11-01 01:30 in New York are one hour apart but currently produce just now. Across the spring transition, one elapsed hour can produce 2 hours ago.

Convert the current aware time to UTC before subtraction so elapsed time includes offset changes. Leave the input in its original timezone to preserve valid datetime.min/max values whose equivalent UTC dates would overflow. Naive datetime, timedelta and date-error behavior stay the same. Add past/future fall-back and spring-forward regressions, boundary coverage, and a short guide clarification.

Validation:

  • Four DST regressions fail against the original implementation; the two boundary cases already pass and remain covered.
  • Full tox passes on CPython 3.10–3.14 and PyPy 3.10–3.11: 348 tests per interpreter and 100% statement and branch coverage.
  • Ruff check/format, mypy, basedpyright, pyrefly, codespell, Sphinx with warnings treated as errors, isolated wheel/sdist builds and Twine checks pass.
  • Independent review verified 150 elapsed-time cases, including New York, Berlin, Lord Howe half-hour transitions and Apia's skipped day, plus six extreme date/offset cases and existing naive/date/custom-timezone behavior.

Prepared with OpenAI Codex assistance, including implementation, tests and independent review. Current and historical issues and pull requests, including the aware-datetime support in #54, were checked for duplicates.

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