diff --git a/core/templatetags/renderer.py b/core/templatetags/renderer.py index 62f9f730..927acf54 100644 --- a/core/templatetags/renderer.py +++ b/core/templatetags/renderer.py @@ -55,31 +55,17 @@ def phonenumber( return value -@register.filter(name="truncate_time") -def truncate_time(value, time_unit): - """Remove everything in the time format lower than the specified unit. - - Args: - value: the value to truncate - time_unit: the lowest unit to display - """ - value = str(value) - return { - "millis": lambda: value.split(".")[0], - "seconds": lambda: value.rsplit(":", maxsplit=1)[0], - "minutes": lambda: value.split(":", maxsplit=1)[0], - "hours": lambda: value.rsplit(" ")[0], - }[time_unit]() - - @register.filter(name="format_timedelta") def format_timedelta(value: datetime.timedelta) -> str: + value = value - datetime.timedelta(microseconds=value.microseconds) days = value.days if days == 0: return str(value) remainder = value - datetime.timedelta(days=days) return ngettext( - "%(nb_days)d day, %(remainder)s", "%(nb_days)d days, %(remainder)s", days + "%(nb_days)d day, %(remainder)s", + "%(nb_days)d days, %(remainder)s", + days, ) % {"nb_days": days, "remainder": str(remainder)} diff --git a/counter/templates/counter/stats.jinja b/counter/templates/counter/stats.jinja index 5534175a..ccea341b 100644 --- a/counter/templates/counter/stats.jinja +++ b/counter/templates/counter/stats.jinja @@ -51,7 +51,7 @@ {{ loop.index }} {{ barman.name }} {% if barman.nickname %}({{ barman.nickname }}){% endif %} {{ barman.promo or '' }} - {{ barman.perm_sum|format_timedelta|truncate_time("millis") }} + {{ barman.perm_sum|format_timedelta }} {% endfor %} @@ -73,7 +73,7 @@ {{ loop.index }} {{ barman.name }} {% if barman.nickname %}({{ barman.nickname }}){% endif %} {{ barman.promo or '' }} - {{ barman.perm_sum|format_timedelta|truncate_time("millis") }} + {{ barman.perm_sum|format_timedelta }} {% endfor %} diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 6be36d8f..a9197f75 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-19 21:00+0100\n" +"POT-Creation-Date: 2025-11-24 11:05+0100\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Maréchal \n" @@ -2819,8 +2819,8 @@ msgstr "Outils Trombi" #, python-format msgid "%(nb_days)d day, %(remainder)s" msgid_plural "%(nb_days)d days, %(remainder)s" -msgstr[0] "" -msgstr[1] "" +msgstr[0] "%(nb_days)d jour, %(remainder)s" +msgstr[1] "%(nb_days)d jours, %(remainder)s" #: core/views/files.py msgid "Add a new folder" diff --git a/sith/settings.py b/sith/settings.py index 6a266eba..313722e0 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -177,7 +177,6 @@ TEMPLATES = [ "filters": { "markdown": "core.templatetags.renderer.markdown", "phonenumber": "core.templatetags.renderer.phonenumber", - "truncate_time": "core.templatetags.renderer.truncate_time", "format_timedelta": "core.templatetags.renderer.format_timedelta", "add_attr": "core.templatetags.renderer.add_attr", },