Skip to content

Commit 9ff98f7

Browse files
eldipanuztalgia
authored andcommitted
Propagate days to seconds and from there compute hours and minutes
1 parent 2473d6d commit 9ff98f7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/humanize/time.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,8 @@ def precisedelta(
526526
years, days = _quotient_and_remainder(days, 365, YEARS, min_unit, suppress_set)
527527
months, days = _quotient_and_remainder(days, 30.5, MONTHS, min_unit, suppress_set)
528528

529-
# If DAYS is not in suppress, we can represent the days but
530-
# if it is a suppressed unit, we need to carry it to a lower unit,
531-
# seconds in this case.
532-
#
533-
# The same applies for secs and usecs below
534-
days, secs = _carry(days, secs, 24 * 3600, DAYS, min_unit, suppress_set)
529+
secs = days * 24 * 3600 + secs
530+
days, secs = _quotient_and_remainder(secs, 24 * 3600, DAYS, min_unit, suppress_set)
535531

536532
hours, secs = _quotient_and_remainder(secs, 3600, HOURS, min_unit, suppress_set)
537533
minutes, secs = _quotient_and_remainder(secs, 60, MINUTES, min_unit, suppress_set)

0 commit comments

Comments
 (0)