Updated TALES 'timestamp' extension to specify ISO output format as option
authorThierry Florac <thierry.florac@onf.fr>
Fri, 19 Oct 2018 17:18:42 +0200
changeset 243 94a457eeaeaa
parent 242 209f64c845d3
child 244 8ef3fd11a05b
Updated TALES 'timestamp' extension to specify ISO output format as option
src/pyams_utils/date.py
--- a/src/pyams_utils/date.py	Thu Oct 18 14:12:11 2018 +0200
+++ b/src/pyams_utils/date.py	Fri Oct 19 17:18:42 2018 +0200
@@ -258,11 +258,15 @@
     A PyAMS TALES extension to get timestamp based on last context modification date.
     """
 
-    def render(self, context=None):
+    def render(self, context=None, formatting=None):
         if context is None:
             context = self.request.context
+        if formatting == 'iso':
+            format_func = datetime.isoformat
+        else:
+            format_func = datetime.timestamp
         dc = IZopeDublinCore(context, None)
         if dc is None:
-            return datetime.utcnow().timestamp()
+            return format_func(datetime.utcnow())
         else:
-            return dc.modified.timestamp()
+            return format_func(dc.modified)