diff sat/tools/utils.py @ 3878:32087d7c25d4

tools (datetime, utils): fix incorrect use of naive object: `tools.datetime.format_datetime` was expecting aware datetime objects while `tools.utils.xmpp_date` was returning naive datetime objects. A check has been added to the former one, and latter one has been modified to return aware datetime objects.
author Goffi <goffi@goffi.org>
date Wed, 31 Aug 2022 13:11:26 +0200
parents 00212260f659
children 46930301f0c1
line wrap: on
line diff
--- a/sat/tools/utils.py	Tue Aug 23 12:04:11 2022 +0200
+++ b/sat/tools/utils.py	Wed Aug 31 13:11:26 2022 +0200
@@ -152,8 +152,9 @@
     @param with_time(bool): if True include the time
     @return(unicode): XEP-0082 formatted date and time
     """
-    dtime = datetime.datetime.utcfromtimestamp(
-        time.time() if timestamp is None else timestamp
+    dtime = datetime.datetime.fromtimestamp(
+        time.time() if timestamp is None else timestamp,
+        datetime.timezone.utc
     )
 
     return format_datetime(dtime) if with_time else format_date(dtime.date())