Skip to content

Format precise durations without calendar date limits - #448

Open
xiehuanyi wants to merge 1 commit into
python-humanize:mainfrom
xiehuanyi:fix-large-precise-durations
Open

xiehuanyi wants to merge 1 commit into
python-humanize:mainfrom
xiehuanyi:fix-large-precise-durations

Conversation

@xiehuanyi

Copy link
Copy Markdown

precisedelta(timedelta(days=4_000_000)) currently raises OverflowError: date value out of range. The duration itself is valid; the failure comes from constructing a calendar date that this formatter never uses. The same limit affects numeric seconds and timedelta.min/timedelta.max.

Operate directly on absolute timedeltas for duration inputs, retaining the existing relative-date path for datetime inputs. Annotate the unit accumulators as float because unit suppression and minimum-unit rounding can produce fractional counts.

Six regressions cover signed4-million-day timedeltas, the corresponding numeric seconds, and the timedelta bounds. All six fail before the fix. Afterward,735 behavior/doctest cases pass with112 translation-related skips, strict mypy . passes, all repository prek hooks pass, and git diff --check passes. Performance benchmarks were excluded from this behavior run.

Prepared with AI assistance.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 18:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants