aboutsummaryrefslogtreecommitdiffstats
path: root/famille.py
diff options
context:
space:
mode:
Diffstat (limited to 'famille.py')
-rw-r--r--famille.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/famille.py b/famille.py
index d026bfe..1c2cdfc 100644
--- a/famille.py
+++ b/famille.py
@@ -19,20 +19,22 @@ app = Flask(__name__)
app.config.from_envvar('CONF')
@app.template_filter('format_date')
-def format_date(datetime_string, format="%a %d %b %Y"):
+def format_date(datetime_string, format=u"%a %d %b %Y à %Hh%M".encode("utf8")):
if not datetime_string:
return ""
- return datetime.strptime(datetime_string[:-1],
- "%Y-%m-%dT%H:%M:%S").strftime(format)
+ return datetime.strptime(datetime_string[:-1],
+ "%Y-%m-%dT%H:%M:%S").strftime(format).decode("utf8")
@app.template_filter('pluralize')
-def pluralize(ncomments):
- if ncomments==0:
- return "Aucun Commentaire"
- elif ncomments==1:
- return "1 Commentaire"
+def pluralize(word, count, plural=None):
+ if count == 0:
+ return "Aucun {}".format(word)
+ elif count == 1:
+ return "1 {}".format(word)
+ elif plural:
+ return "{} {}".format(count, plural)
else:
- return "{0} Commentaires".format(ncomments)
+ return "{} {}s".format(count, word)
def query_db(query, args=(), one=False):
cur = g.db.execute(query, args)