Allow rendering of "raw" datetime as ISO date

sometimes a full timestamp isn't that helpful
This commit is contained in:
Lance Edgar 2019-11-05 15:11:07 -06:00
parent 93a44d83d2
commit 99f69c13d2

View file

@ -100,7 +100,7 @@ def pretty_datetime(config, value):
c=humanize.naturaltime(time_ago))
def raw_datetime(config, value, verbose=False):
def raw_datetime(config, value, verbose=False, as_date=False):
"""
Formats a datetime as a "raw" human-readable string, with a tooltip
showing the more human-friendly "time since" equivalent.
@ -129,6 +129,9 @@ def raw_datetime(config, value, verbose=False):
# Avoid strftime error when year falls before epoch.
if value.year >= 1900:
if as_date:
kwargs['c'] = value.strftime('%Y-%m-%d')
else:
kwargs['c'] = value.strftime('%Y-%m-%d %I:%M:%S %p')
else:
kwargs['c'] = six.text_type(value)