Skip to content

fix(tools): report elapsed datetime differences across DST - #1239

Open
1828703450qqcom-ux wants to merge 1 commit into
volcengine:mainfrom
1828703450qqcom-ux:fix/datetime-dst-diff
Open

1828703450qqcom-ux wants to merge 1 commit into
volcengine:mainfrom
1828703450qqcom-ux:fix/datetime-dst-diff

Conversation

@1828703450qqcom-ux

Copy link
Copy Markdown

Problem

The built-in datetime tool's diff action can report wall-clock time for offset-free inputs in the same named timezone. Python subtraction ignores offset changes when both operands share the same tzinfo. In America/New_York, 01:30 to 03:30 on March 8, 2026 is one elapsed hour. The old code returned two.

Change

Correct for the offset difference when Python uses shared-timezone arithmetic. The returned seconds, days, and display string all use the elapsed duration.

Verification

  • Both new daylight-saving transition cases reproduced on origin/main (d2f186d) on 2026-11-29. They pass with the fix.
  • Pass: native pytest datetime and calculator tool suites, 138 tests.
  • Pass: uv run --no-sync --extra dev pre-commit run --all-files --show-diff-on-failure and git diff --check.

Codex assisted with the investigation, implementation, and verification.

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