From 8f22997ac1d21c2a1c1f0e59cb10e3ee9216010e Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 8 May 2023 12:16:40 +0200 Subject: [PATCH] Append 'h' to shift duration --- shiftregister/app/templates/partials/shift_listitem.html | 1 + shiftregister/app/templates/shift.html | 1 + shiftregister/app/templatetags/shift_extras.py | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/shiftregister/app/templates/partials/shift_listitem.html b/shiftregister/app/templates/partials/shift_listitem.html index bb4ade2..ef64939 100644 --- a/shiftregister/app/templates/partials/shift_listitem.html +++ b/shiftregister/app/templates/partials/shift_listitem.html @@ -1,4 +1,5 @@ {% load shift_extras %} +
diff --git a/shiftregister/app/templates/shift.html b/shiftregister/app/templates/shift.html index 16b67d5..4dffdec 100644 --- a/shiftregister/app/templates/shift.html +++ b/shiftregister/app/templates/shift.html @@ -1,4 +1,5 @@ {% extends "helper_base.html" %} + {% load shift_extras %} {% block title %}Schichtansicht{% endblock %} diff --git a/shiftregister/app/templatetags/shift_extras.py b/shiftregister/app/templatetags/shift_extras.py index 92aaccf..c6e2a42 100644 --- a/shiftregister/app/templatetags/shift_extras.py +++ b/shiftregister/app/templatetags/shift_extras.py @@ -5,8 +5,8 @@ register = template.Library() @register.filter(name="duration") def duration(value): - secs = value.total_seconds() - hours = int(secs // (60 * 60)) + secs = int(value.total_seconds()) + hours = secs // (60 * 60) secs = secs % (hours * 60 * 60) - minutes = int(secs // 60) - return f"{hours}:{minutes:02d}" + minutes = secs // 60 + return f"{hours}:{minutes:02d}h"