Skip to content

Commit f220b67

Browse files
eldipaDaniel Gillet
authored andcommitted
Propagate days to seconds and from there compute hours and minutes
1 parent 9cd65dc commit f220b67

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
@@ -577,12 +577,8 @@ def precisedelta(
577577
years, days = _quotient_and_remainder(days, 365, YEARS, min_unit, suppress_set)
578578
months, days = _quotient_and_remainder(days, 30.5, MONTHS, min_unit, suppress_set)
579579

580-
# If DAYS is not in suppress, we can represent the days but
581-
# if it is a suppressed unit, we need to carry it to a lower unit,
582-
# seconds in this case.
583-
#
584-
# The same applies for secs and usecs below
585-
days, secs = _carry(days, secs, 24 * 3600, DAYS, min_unit, suppress_set)
580+
secs = days * 24 * 3600 + secs
581+
days, secs = _quotient_and_remainder(secs, 24 * 3600, DAYS, min_unit, suppress_set)
586582

587583
hours, secs = _quotient_and_remainder(secs, 3600, HOURS, min_unit, suppress_set)
588584
minutes, secs = _quotient_and_remainder(secs, 60, MINUTES, min_unit, suppress_set)

0 commit comments

Comments
 (0)