Updated dates formatting ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Wed, 24 Jan 2024 13:54:47 +0100
branchZTK-1.1
changeset 284 90f42ae4f155
parent 283 47b725e97017
child 285 73d215ccd5df
Updated dates formatting
src/ztfy/utils/date.py
--- a/src/ztfy/utils/date.py	Mon Apr 03 14:47:40 2023 +0200
+++ b/src/ztfy/utils/date.py	Wed Jan 24 13:54:47 2024 +0100
@@ -15,7 +15,7 @@
 
 
 # import standard packages
-from datetime import datetime
+from datetime import date, datetime, time
 
 # import Zope3 interfaces
 
@@ -87,7 +87,10 @@
     if request is None:
         request = queryRequest()
     if value.year >= 1900:
-        return datetime.strftime(tztime(value), translate(format, context=request).encode('utf-8')).decode('utf-8')
+        if isinstance(value, date):
+            value = datetime.combine(value, time())
+        return datetime.strftime(tztime(value),
+                                 translate(format, context=request).encode('utf-8')).decode('utf-8')
     else:
         return format.replace('%d', str(value.day)) \
                      .replace('%m', str(value.month)) \