From 99f69c13d205a43e7d1ddaf93ac3079a3da1873b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 5 Nov 2019 15:11:07 -0600 Subject: [PATCH] Allow rendering of "raw" datetime as ISO date sometimes a full timestamp isn't that helpful --- tailbone/util.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tailbone/util.py b/tailbone/util.py index aea29342..85918330 100644 --- a/tailbone/util.py +++ b/tailbone/util.py @@ -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,7 +129,10 @@ def raw_datetime(config, value, verbose=False): # Avoid strftime error when year falls before epoch. if value.year >= 1900: - kwargs['c'] = value.strftime('%Y-%m-%d %I:%M:%S %p') + 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)