Browse Source

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 2 years ago
parent
commit
87e597011a
1 changed files with 1 additions and 1 deletions
  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):
     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=""):