From 36e0db7ab5ea9a4c9b15ac990ee1fe890d5d642e Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 18 Feb 2020 16:39:36 +0000 Subject: [PATCH] weeks and days should be absolute (divmod of days) --- src/utils/datetime/format.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/datetime/format.py b/src/utils/datetime/format.py index acee5f6d..987d44f2 100644 --- a/src/utils/datetime/format.py +++ b/src/utils/datetime/format.py @@ -62,10 +62,11 @@ def to_pretty_time(total_seconds: int, minimum_unit: int=UNIT_SECOND, out.append("%dy" % relative.years) if relative.months and minimum_unit >= UNIT_MONTH and len(out) < max_units: out.append("%dmo" % relative.months) - if relative.weeks and minimum_unit >= UNIT_WEEK and len(out) < max_units: - out.append("%dw" % relative.weeks) - if relative.days and minimum_unit >= UNIT_DAY and len(out) < max_units: - out.append("%dd" % relative.days) + weeks, days = divmod(relative.days, 7) + if weeks and minimum_unit >= UNIT_WEEK and len(out) < max_units: + out.append("%dw" % weeks) + 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: out.append("%dh" % relative.hours) if relative.minutes and minimum_unit >= UNIT_MINUTE and len(out) < max_units: