Repository navigation
Preserve subsecond rounding for minutes, hours and days - #509
Open
liugedragon wants to merge 1 commit into
Open
liugedragon wants to merge 1 commit into
liugedragon wants to merge 1 commit into
Conversation
Ekko82
reviewed
Nov 10, 2026
Ekko82
left a comment
There was a problem hiding this comment.
I replayed the 40 added parameter combinations in a focused public-API harness on Windows/Python 3.13.9 at 0485b3d. All pass, along with 48 further calls covering one-microsecond steps at half-unit thresholds, %.12f, suppression, both signs and numeric/timedelta inputs. Against base d16e635, 36 of the original combinations and 32 of the additional calls fail.
For example, timedelta(seconds=3630, microseconds=1) now gives 1 hour and 1 minute with minimum_unit="minutes", format="%.0f", while the exact-half control remains 1 hour.
The full pytest suite, localization tests and lint were not run. The pytest file requires freezegun, which is unavailable in this environment.
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.
Changes proposed in this pull request:
precisedelta()to a minimum unit of minutes, hours or days.For example:
This intentionally improves an existing documented limitation. The old expectation for
precisedelta(3630.99, minimum_unit="minutes", format="%.0f")changes from"1 hour"to"1 hour and 1 minute": the remaining 30.99 seconds is above half a minute. An exact 3630-second control preserves the half-even tie, and the existing 90.0001-second documentation example still produces"1.50 minutes".Month/year decomposition and the default seconds/subsecond path retain their existing behavior. Related #436 addresses sub-day seconds for months/years; #500 addresses exact large integer microsecond counts.
Validation on Windows / Python 3.13.4:
git diff --check: passed.