Skip to content

Fix inconsistent shift() behavior across DST transitions (#1170) - #1365

Open
IDEAS247 wants to merge 3 commits into
arrow-py:masterfrom
IDEAS247:master
Open

IDEAS247 wants to merge 3 commits into
arrow-py:masterfrom
IDEAS247:master

Conversation

@IDEAS247

@IDEAS247 IDEAS247 commented Oct 1, 2026

Copy link
Copy Markdown

Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

Description of Changes

Closes: #1170

Problem

Arrow.shift() applies hour/minute/second shifts as wall-clock arithmetic,
so results become inconsistent across a Daylight Saving Time transition.
For example, on the US spring-forward date:

x = arrow.Arrow(2023, 3, 12, tzinfo="America/Los_Angeles")
x.shift(hours=2) == x.shift(hours=3)  # True — should never happen

@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2224255) to head (94c4416).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1365   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines         2315      2325   +10     
  Branches       358       361    +3     
=========================================
+ Hits          2315      2325   +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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.

incorrect behavior WRT daylight savings for shift/adding timedelta

1 participant