diff --git a/cps/db.py b/cps/db.py index 1296c84a..01d50605 100644 --- a/cps/db.py +++ b/cps/db.py @@ -269,7 +269,7 @@ class Books(Base): sort = Column(String(collation='NOCASE')) author_sort = Column(String(collation='NOCASE')) timestamp = Column(TIMESTAMP, default=datetime.utcnow) - pubdate = Column(String) # , default=datetime.utcnow) + pubdate = Column(TIMESTAMP, default=DEFAULT_PUBDATE) series_index = Column(String, nullable=False, default="1.0") last_modified = Column(TIMESTAMP, default=datetime.utcnow) path = Column(String, default="", nullable=False) diff --git a/cps/jinjia.py b/cps/jinjia.py index 28c2621a..b1b42939 100644 --- a/cps/jinjia.py +++ b/cps/jinjia.py @@ -76,22 +76,18 @@ def mimetype_filter(val): @jinjia.app_template_filter('formatdate') def formatdate_filter(val): 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()) + return format_date(val, format='medium', locale=get_locale()) except AttributeError as e: log.error('Babel error: %s, Current user locale: %s, Current User: %s', e, current_user.locale, current_user.nickname ) - return formatdate + return val @jinjia.app_template_filter('formatdateinput') def format_date_input(val): - conformed_timestamp = re.sub(r"[:]|([-](?!((\d{2}[:]\d{2})|(\d{4}))$))", '', val) - date_obj = datetime.datetime.strptime(conformed_timestamp[:15], "%Y%m%d %H%M%S") - input_date = date_obj.isoformat().split('T', 1)[0] # Hack to support dates <1900 + input_date = val.isoformat().split('T', 1)[0] # Hack to support dates <1900 return '' if input_date == "0101-01-01" else input_date diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 6edf1677..4a0fbe02 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -160,7 +160,7 @@ {% endif %} - {% if entry.pubdate[:10] != '0101-01-01' %} + {% if (entry.pubdate|string)[:10] != '0101-01-01' %}
{{_('Published')}}: {{entry.pubdate|formatdate}}