Explorar el Código

bugfix: file timestamps should use tz-aware utc datetime objs

the UNIX time used for timestamp is seconds since 1.1.1970,
in UTC. thus, the natural way to represent it is with a
tz-aware utc datetime object.

but previously (in borg 1.x), they used naive datetime
objects and localtime.
Thomas Waldmann hace 2 años
padre
commit
87e597011a
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      src/borg/helpers/time.py

+ 1 - 1
src/borg/helpers/time.py

@@ -83,7 +83,7 @@ def safe_ns(ts):
 
 
 def safe_timestamp(item_timestamp_ns):
 def safe_timestamp(item_timestamp_ns):
     t_ns = safe_ns(item_timestamp_ns)
     t_ns = safe_ns(item_timestamp_ns)
-    return datetime.fromtimestamp(t_ns / 1e9)
+    return datetime.fromtimestamp(t_ns / 1e9, timezone.utc)  # return tz-aware utc datetime obj
 
 
 
 
 def format_time(ts: datetime, format_spec=""):
 def format_time(ts: datetime, format_spec=""):