Repository navigation
Fix: shift() loses fold, changes UTC offset on ambiguous DST time - #1362
Open
micson-bit wants to merge 2 commits into
Open
micson-bit wants to merge 2 commits into
micson-bit wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1362 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2316 +1
Branches 358 358
=========================================
+ Hits 2315 2316 +1 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1067
Problem
Calling
.shift()on anArrowobject representing an ambiguous local time(e.g. during a DST "fall back" transition) silently changes its UTC offset,
even when the shift amount is zero.
Root cause
In
Arrow.shift(), the line:rebuilds the datetime via
relativedelta, which does not preserve theoriginal
foldvalue.foldis what disambiguates repeated wall-clocktimes during a DST transition. Without it, the reconstructed datetime
defaults to
fold=0, causing Arrow to resolve to the wrong occurrenceof the ambiguous time.
Fix
Re-apply the original
foldvalue immediately after therelativedeltaaddition, before any further processing:
Testing
Added
test_shift_zero_seconds_preserves_offset_on_ambiguous_dst_timeintests/test_arrow.py, which reproduces the bug from #1067. Confirmed itfails before the fix and passes after. Full test suite (226 tests) still
passes.