From f941908f73a8602d72df652271bdb7578776b79f Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Tue, 23 Apr 2019 21:32:48 +0200 Subject: [PATCH] Workaround for #889 --- cps/web.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cps/web.py b/cps/web.py index 095020af..b69f83c5 100644 --- a/cps/web.py +++ b/cps/web.py @@ -407,9 +407,14 @@ def mimetype_filter(val): @app.template_filter('formatdate') def formatdate_filter(val): - conformed_timestamp = re.sub(r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))", '', val) - formatdate = datetime.datetime.strptime(conformed_timestamp[:15], "%Y%m%d %H%M%S") - return format_date(formatdate, format='medium', locale=get_locale()) + try: + conformed_timestamp = re.sub(r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))", '', val) + formatdate = datetime.datetime.strptime(conformed_timestamp[:15], "%Y%m%d %H%M%S") + return format_date(formatdate, format='medium', locale=get_locale()) + except AttributeError as e: + app.logger.error('Babel error: %s, Current user locale: %s, Current User: %s' % (e, current_user.locale, current_user.nickname)) + return formatdate + @app.template_filter('formatdateinput')