Fix DST fall-back repeated hour skipped in Arrow.range() (#1162)#1282
Open
Abdu-Ahmed wants to merge 1 commit into
Open
Fix DST fall-back repeated hour skipped in Arrow.range() (#1162)#1282Abdu-Ahmed wants to merge 1 commit into
Abdu-Ahmed wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1282 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2324 +9
Branches 358 361 +3
=========================================
+ Hits 2315 2324 +9 ☔ View full report in Codecov by Sentry. |
….range()
When arrow.get() was called with an offset-aware string and a named
tzinfo kwarg (e.g. arrow.get('2021-11-07T01:00:00-05:00', tzinfo='US/Eastern')),
the tzinfo was replaced rather than used for conversion. This caused
the UTC moment to change and the fold to be lost, so Arrow.range()
would skip the repeated hour during DST fall-back.
Fix 1 (factory.py): When a string with offset info is parsed and a
tzinfo kwarg is provided, convert using .to() instead of replacing,
preserving the original UTC moment.
Fix 2 (arrow.py): In fromdatetime(), when replacing tzinfo, infer
the correct fold by comparing the original UTC offset against what
fold=1 produces in the new timezone.
a880b2c to
9f060d0
Compare
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.
Closes #1162
When
arrow.get()was called with an offset-aware string and a namedtzinfokwarg (e.g.arrow.get("2021-11-07T01:00:00-05:00", tzinfo="US/Eastern")),the tzinfo was replaced rather than used for conversion. This caused
the UTC moment to shift and fold information to be lost, so
Arrow.range()skipped the repeated hour during DST fall-back (returning 2 hours instead of 3).
Fix 1 (
factory.py): When a parsed string already has offset info anda
tzinfokwarg is provided, convert using.to()instead of replacing,preserving the original UTC moment.
Fix 2 (
arrow.py): Infromdatetime(), when replacingtzinfo, inferthe correct
foldby comparing the original UTC offset against whatfold=1produces in the new timezone.
All 1901 tests pass (99.93% coverage).