Add workarounds for certain display bugs when rendering datetimes
This commit is contained in:
parent
74f02ebb0d
commit
c7c2fecec0
|
@ -91,6 +91,16 @@ def raw_datetime(config, value):
|
||||||
local = timezone(config)
|
local = timezone(config)
|
||||||
value = local.normalize(value.astimezone(local))
|
value = local.normalize(value.astimezone(local))
|
||||||
|
|
||||||
return HTML.tag('span',
|
kwargs = {}
|
||||||
title=humanize.naturaltime(time_ago),
|
|
||||||
c=value.strftime('%Y-%m-%d %I:%M:%S %p'))
|
# Avoid strftime error when year falls before epoch.
|
||||||
|
if value.year >= 1900:
|
||||||
|
kwargs['c'] = value.strftime('%Y-%m-%d %I:%M:%S %p')
|
||||||
|
else:
|
||||||
|
kwargs['c'] = unicode(value)
|
||||||
|
|
||||||
|
# Avoid humanize error when calculating huge time diff.
|
||||||
|
if abs(time_ago.days) < 100000:
|
||||||
|
kwargs['title'] = humanize.naturaltime(time_ago)
|
||||||
|
|
||||||
|
return HTML.tag('span', **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue