Repository navigation
Conversation
There was a problem hiding this comment.
The new month/year branches include seconds but still discard delta.microseconds before formatting. At higher requested precision, a fractional remainder is therefore lost:
delta = timedelta(days=30.5, microseconds=999999)
precisedelta(delta, minimum_unit="months", format="%.12f")
# actual: "1 month"
# numeric duration / (30.5 * 86400): 1.000000379477The analogous 365-day year case renders “1 year” instead of retaining the numeric 1.000000031710 remainder. Half-day extra-seconds controls correctly render 1.016393 months and 1.001370 years at six decimals. I used Python 3.12.14 against commit 9e3f2fc.
Could both new numerators include usecs / 1e6 before setting days/secs/usecs to zero, with high-precision regressions? This is a remaining sub-day precision case, not a claim about default two-decimal output. I used English-locale standalone checks against fetched PR source with only build-generated version metadata stubbed, not the full pytest suite.
|
Thanks for checking. The other coarse units also drop microseconds when they are the minimum unit: on main, |
Changes proposed in this pull request:
precisedeltato a minimum unit of months or years.Before and after
Validation
Linux, CPython 3.12.14:
humanize.timestatement coverage: 100%.No Windows/macOS/other-Python matrix or hosted-CI result is claimed. Benchmark functions execute with timing disabled, so this is not a performance measurement.
AI assistance: implementation, tests, and this description were prepared with OpenAI assistance.