humantime: convert datetime to current timezone in template tags
This commit is contained in:
parent
1bcca4496d
commit
ab06cb99d5
|
@ -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)))
|
||||
|
|
Reference in New Issue