blob: 09c5b331100ffabdd27cb05025d396de7d6f5765 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from django import template
register = template.Library()
@register.filter
def duration(value):
if not value:
return u'\u221e'
# does not take microseconds into account
total_secs = value.seconds + value.days * 24 * 3600
mins, secs = divmod(total_secs, 60)
hrs, mins = divmod(mins, 60)
return '%d:%02d' % (hrs, mins)
# vim: set ts=4 sw=4 et:
|