humantime: convert datetime to current timezone in template tags

This commit is contained in:
Benjamin Dauvergne 2014-01-21 21:42:06 +01:00
parent 1bcca4496d
commit ab06cb99d5
1 changed files with 2 additions and 0 deletions

View File

@ -1,4 +1,5 @@
from django import template
from django.utils.timezone import localtime, get_default_timezone
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.template.defaultfilters import date
@ -16,6 +17,7 @@ def humandate(dt):
@register.filter
def humantime(dt):
dt = localtime(dt)
full_dt = date(dt, 'SHORT_DATETIME_FORMAT')
s = u'<span title="{0}">{1}</span>'.format(
escape(full_dt), escape(utils.datetime2human(dt, include_time=True)))