Explorar el Código

Fix: out-of-range timestamp on 32-bit systems

Peter Bieringer hace 5 meses
padre
commit
120fbb7328
Se han modificado 1 ficheros con 1 adiciones y 4 borrados
  1. 1 4
      radicale/utils.py

+ 1 - 4
radicale/utils.py

@@ -280,10 +280,7 @@ def format_ut(unixtime: int) -> str:
         # TODO check how to support this better
         return str(unixtime)
     if unixtime < DATETIME_MAX_UNIXTIME:
-        if sys.version_info < (3, 11):
-            dt = datetime.datetime.utcfromtimestamp(unixtime)
-        else:
-            dt = datetime.datetime.fromtimestamp(unixtime, datetime.UTC)
+        dt = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc) + datetime.timedelta(seconds=unixtime)
         r = str(unixtime) + "(" + dt.strftime('%Y-%m-%dT%H:%M:%SZ') + ")"
     else:
         r = str(unixtime) + "(>MAX:" + str(DATETIME_MAX_UNIXTIME) + ")"