add custom filter to format shift durations
parent
8a8c415015
commit
3957c659e6
@ -0,0 +1,12 @@
|
|||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name="duration")
|
||||||
|
def duration(value):
|
||||||
|
secs = value.total_seconds()
|
||||||
|
hours = int(secs // (60 * 60))
|
||||||
|
secs = secs % (hours * 60 * 60)
|
||||||
|
minutes = int(secs // 60)
|
||||||
|
return f"{hours}:{minutes:02d}"
|
Loading…
Reference in New Issue