diff MoinMoin/themes/__init__.py @ 2944:afe523052a7f

rework global history styling for modernized and basic themes, add user and comment fields, partial fix #471
author RogerHaase <haaserd@gmail.com>
date Sun, 10 May 2015 13:51:39 -0700
parents 456c68761e96
children
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Wed May 06 13:38:38 2015 -0700
+++ b/MoinMoin/themes/__init__.py	Sun May 10 13:51:39 2015 -0700
@@ -9,6 +9,7 @@
 
 
 import urllib
+import datetime
 
 from json import dumps
 
@@ -651,6 +652,14 @@
     return CONTENTTYPES_MAP.get(contenttype, "Unknown")
 
 
+def time_hh_mm(dt):
+    """
+    Convert a datetime object into a short string of the form HH:MM
+    where HH varies from 0 to 23.
+    """
+    return datetime.datetime.fromtimestamp(dt).strftime('%H:%M')
+
+
 def setup_jinja_env():
     app.jinja_env.filters['shorten_fqname'] = shorten_fqname
     app.jinja_env.filters['shorten_item_name'] = shorten_item_name
@@ -658,6 +667,7 @@
     app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
     app.jinja_env.filters['json_dumps'] = dumps
     app.jinja_env.filters['shorten_ctype'] = shorten_ctype
+    app.jinja_env.filters['time_hh_mm'] = time_hh_mm
     # please note that these filters are installed by flask-babel:
     # datetimeformat, dateformat, timeformat, timedeltaformat