1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from django import template
from dateutil import tz
import datetime
register = template.Library()
@register.filter
def timeto(value):
now = datetime.datetime.now(tz.tzutc())
diff = value.astimezone(tz.tzutc()) - now
minutes = diff.seconds / 60
hours = minutes / 60
mins = minutes - (hours * 60)
return '%dhr %dmin' % (hours, mins)
|
More like this
- JSON encode ISO UTC datetime by japerk 3 years, 1 month ago
- isoutc template filter by japerk 3 years, 1 month ago
- Fuzzy Time of Day by waylan 4 years, 11 months ago
- JSON decode datetime by japerk 3 years, 1 month ago
- FuzzyDateTimeField by japerk 3 years, 1 month ago
Comments