Make datetime customizable across templates

This commit is contained in:
Klaus Alexander Seistrup 2016-01-23 12:52:15 +01:00
parent 91a8ac9189
commit 3d1a130584

View file

@ -183,8 +183,11 @@ def create_app(config=None):
g.assets = dict(css=['main.css'], js=['main.js'])
@app.template_filter('datetime')
def _jinja2_filter_datetime(ts):
return time.strftime('%b %d, %Y %I:%M %p', time.localtime(ts))
def _jinja2_filter_datetime(ts, fmt=None):
return time.strftime(
fmt or app.config.get('DATETIME_FORMAT', '%b %d, %Y %I:%M %p'),
time.localtime(ts)
)
@app.template_filter('b64encode')
def _jinja2_filter_b64encode(s):