diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2012-11-08 00:44:52 +0100 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2012-11-08 00:44:52 +0100 |
| commit | 9ab593bcd52fcbe87f1be463ca5f09a757d1128f (patch) | |
| tree | 6e792c98452715e5409af3afc4a23c206f362130 /famille.py | |
| parent | 1ab9d17135c87253d9e1531cc31cf1b4ac94eceb (diff) | |
| download | famille-flask-9ab593bcd52fcbe87f1be463ca5f09a757d1128f.tar.gz | |
Add date formatting filter
Diffstat (limited to 'famille.py')
| -rw-r--r-- | famille.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -7,6 +7,7 @@ from functools import wraps import hashlib from docutils import core from docutils.writers.html4css1 import Writer +from datetime import datetime def rstify(string): w = Writer() @@ -17,6 +18,13 @@ def rstify(string): app = Flask(__name__) app.config.from_envvar('CONF') +@app.template_filter('format_date') +def format_date(datetime_string, format="%a %d %b %Y"): + if not datetime_string: + return "" + return datetime.strptime(datetime_string[:-1], + "%Y-%m-%dT%H:%M:%S").strftime(format) + def query_db(query, args=(), one=False): cur = g.db.execute(query, args) rv = cur.fetchone() if one else cur.fetchall() |
