소스 검색

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 년 전
부모
커밋
87e597011a
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  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=""):