template (filters): don't crash on invalid date in date_fmt

This commit is contained in:
Goffi 2017-11-30 20:59:24 +01:00
commit 5aec6ed680

View file

@ -353,6 +353,13 @@ class Renderer(object):
return value if not current else u"{}_{}".format(value, current)
def _date_fmt(self, timestamp, fmt='short', date_only=False, auto_limit=None, auto_old_fmt=None):
try:
return self.date_fmt(timestamp, fmt, date_only, auto_limit, auto_old_fmt)
except Exception as e:
log.warning(_(u"Can't parse date: {msg}").format(msg=e))
return timestamp
def date_fmt(self, timestamp, fmt='short', date_only=False, auto_limit=None, auto_old_fmt=None):
"""format date according to locale
@param timestamp(basestring, int): unix time