Skip to content

Fix span()/ceil() when the next frame boundary falls in a DST gap - #1364

Open
uditjainstjis wants to merge 1 commit into
arrow-py:masterfrom
uditjainstjis:fix-span-dst-gap
Open

uditjainstjis wants to merge 1 commit into
arrow-py:masterfrom
uditjainstjis:fix-span-dst-gap

Conversation

@uditjainstjis

Copy link
Copy Markdown

Pull Request Checklist

  • 🧪 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.

Description of Changes

span() builds the ceiling by shifting the floor forward one frame with check_imaginary=True. When that next boundary does not exist because it falls in a DST gap, the shift moves it forward. America/Santiago skips 2022-09-11 00:00–01:00, so:

>>> arrow.Arrow(2022, 9, 10, 12, tzinfo="America/Santiago").ceil("day")
<Arrow [2022-09-11T01:59:59.999999-03:00]>   # before
<Arrow [2022-09-10T23:59:59.999999-04:00]>   # after

The shift now keeps the exact boundary (check_imaginary=False), and one microsecond before it is the last real instant of the frame. Boundaries that exist are unaffected.

Tests: test_span_day_before_dst_gap_at_midnight fails without the change and passes with it; test_span_day_of_dst_gap_at_midnight covers the day of the gap. Full suite: 1904 passed; pre-commit hooks pass.

Closes: #1124

span() built the ceiling by shifting the floor with check_imaginary=True, which
moves a nonexistent boundary (e.g. America/Santiago skips 2022-09-11 00:00-01:00)
forward, so ceil("day") on 2022-09-10 returned 2022-09-11T01:59:59.999999-03:00.
Keep the exact boundary; one microsecond before it is the frame's last instant.

Closes arrow-py#1124
@codecov

codecov Bot commented Sep 27, 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 (beeda38).
✅ All tests successful. No failed tests found.

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

☔ 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.

ceil("day") incorrect on the day before DST switch

1 participant