--- a/src/pyams_utils/date.py Mon Jun 29 22:32:45 2020 +0200
+++ b/src/pyams_utils/date.py Mon Sep 28 15:19:28 2020 +0200
@@ -257,6 +257,18 @@
return result
+def get_timestamp(context, formatting=None):
+ """Get timestamp matching context modification time"""
+ if formatting == 'iso':
+ format_func = datetime.isoformat
+ else:
+ format_func = datetime.timestamp
+ zdc = IZopeDublinCore(context, None)
+ if zdc is not None:
+ return format_func(tztime(zdc.modified))
+ return format_func(tztime(datetime.utcnow()))
+
+
@adapter_config(name='timestamp', context=(Interface, Interface, Interface),
provides=ITALESExtension)
class TimestampTalesAdapter(ContextRequestViewAdapter):
@@ -269,11 +281,4 @@
"""Render TALES extension"""
if context is None:
context = self.request.context
- if formatting == 'iso':
- format_func = datetime.isoformat
- else:
- format_func = datetime.timestamp
- zdc = IZopeDublinCore(context, None)
- if zdc is None:
- return format_func(tztime(zdc.modified))
- return format_func(tztime(datetime.utcnow()))
+ return get_timestamp(context, formatting)