weeks and days should be absolute (divmod of days)

This commit is contained in:
jesopo 2020-02-18 16:39:36 +00:00
parent 329e45e7b9
commit 36e0db7ab5

View file

@ -62,10 +62,11 @@ def to_pretty_time(total_seconds: int, minimum_unit: int=UNIT_SECOND,
out.append("%dy" % relative.years) out.append("%dy" % relative.years)
if relative.months and minimum_unit >= UNIT_MONTH and len(out) < max_units: if relative.months and minimum_unit >= UNIT_MONTH and len(out) < max_units:
out.append("%dmo" % relative.months) out.append("%dmo" % relative.months)
if relative.weeks and minimum_unit >= UNIT_WEEK and len(out) < max_units: weeks, days = divmod(relative.days, 7)
out.append("%dw" % relative.weeks) if weeks and minimum_unit >= UNIT_WEEK and len(out) < max_units:
if relative.days and minimum_unit >= UNIT_DAY and len(out) < max_units: out.append("%dw" % weeks)
out.append("%dd" % relative.days) if days and minimum_unit >= UNIT_DAY and len(out) < max_units:
out.append("%dd" % days)
if relative.hours and minimum_unit >= UNIT_HOUR and len(out) < max_units: if relative.hours and minimum_unit >= UNIT_HOUR and len(out) < max_units:
out.append("%dh" % relative.hours) out.append("%dh" % relative.hours)
if relative.minutes and minimum_unit >= UNIT_MINUTE and len(out) < max_units: if relative.minutes and minimum_unit >= UNIT_MINUTE and len(out) < max_units: