Repository navigation
Conversation
Check UTC offsets before collapsing equal wall-clock datetimes with different fold values.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1501 +/- ##
=======================================
Coverage 94.43% 94.44%
=======================================
Files 27 27
Lines 5051 5055 +4
=======================================
+ Hits 4770 4774 +4
Misses 281 281
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The test seems to be a contrived example. Can you think of a real life situation where someone would format an interval of the same instant across DST folds? |
|
They aren't the same instant — A real-world case is a 1-hour scheduled event (maintenance window, on-call shift, or calendar meeting) spanning the autumn DST fall-back night in I updated the test to construct the endpoints via |
10a5f63 to
f2bf034
Compare
Fixes #1500.
Summary
During a DST fall-back, two
datetimevalues can have identical wall-clock fields and share atzinfoobject while representing different instants. Python's equality comparison ignoresfoldin that case, soformat_interval()can take its single-instant shortcut before applying the requested display timezone.When equal datetime endpoints share a timezone and have different folds, compare their UTC offsets before treating them as one instant. Distinct offsets now take the existing interval-formatting path.
Verification
01:15in New York. With UTC as the display timezone, the expected output is5:15 – 6:15 AM.394f91a, the new test was the only failure intests/test_date_intervals.pybefore applying the fix.git diff --checkpassed.Investigation, implementation, tests, and drafting were developed with Codex assistance.