changeset 2453:84e84a46b014

template (filters): don't crash on invalid date in date_fmt
author Goffi <goffi@goffi.org>
date Thu, 30 Nov 2017 20:59:24 +0100
parents 7aa863cbc47f
children 06ff33052354
files src/tools/common/template.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/common/template.py	Thu Nov 30 20:58:34 2017 +0100
+++ b/src/tools/common/template.py	Thu Nov 30 20:59:24 2017 +0100
@@ -353,6 +353,13 @@
         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