From 3d1a13058481acc80e7f91175459ae4fc4176753 Mon Sep 17 00:00:00 2001 From: Klaus Alexander Seistrup Date: Sat, 23 Jan 2016 12:52:15 +0100 Subject: [PATCH] Make `datetime` customizable across templates --- realms/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/realms/__init__.py b/realms/__init__.py index 27b2ce7..57779ac 100644 --- a/realms/__init__.py +++ b/realms/__init__.py @@ -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):