Skip to content

Preserve microsecond precision in is_between - #1369

Open
FanWu-ai wants to merge 1 commit into
arrow-py:masterfrom
FanWu-ai:fix/preserve-is-between-precision
Open

FanWu-ai wants to merge 1 commit into
arrow-py:masterfrom
FanWu-ai:fix/preserve-is-between-precision

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 6, 2026

Copy link
Copy Markdown

Pull Request Checklist

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass locally on Python 3.12.14.
  • 🧹 All configured linting checks pass locally.
  • 📚 Updated documentation for changed code. No public API change.
  • ⏩ Code is up-to-date with master.

Description of Changes

is_between converts all three dates to floating-point timestamps. Distinct microseconds can collapse for early or late years. For example, a date one microsecond after Arrow(2500, 1, 1) is incorrectly considered outside the open interval ending two microseconds after it. Inclusive bounds can also admit a target outside an interval when its timestamp rounds to an endpoint.

Compare exact timedeltas relative to a fixed UTC-aware epoch instead. This preserves microseconds and UTC-instant ordering, including DST folds, without constructing out-of-range UTC datetimes at year 1 or 9999.

Add 28 regression/compatibility cases covering six years, all four bounds, mixed offsets, UTC datetime boundaries, and both DST fold values.

Validation

  • Untouched base: 1,904 tests passed
  • New tests on original source: 19 failed, 9 compatibility cases passed
  • Final full suite: 1,932 passed, no skips or xfails; 99.93% coverage
  • All 23 configured pre-commit hooks, including Black, Flake8 and mypy, passed
  • doc8 and warnings-as-errors Sphinx HTML build passed
  • git diff --check passed
  • Independent integer-reference checks: 40,000 comparisons across years 1–9999, offsets ±23:59 and every bounds mode passed

Tested on Linux with Python 3.12.14. No hosted Python/OS matrix result is claimed yet. Prepared with OpenAI Codex assistance.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 6, 2026 21:57

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.

1 participant