Browse Source

Fix timezone issue on python 3.2

Jonas Borgström 11 năm trước cách đây
mục cha
commit
87749e413e
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      attic/helpers.py

+ 2 - 2
attic/helpers.py

@@ -8,7 +8,7 @@ import re
 import stat
 import sys
 import time
-from datetime import datetime
+from datetime import datetime, timezone
 from fnmatch import fnmatchcase
 from operator import attrgetter
 import fcntl
@@ -138,7 +138,7 @@ def get_cache_dir():
 
 def to_localtime(ts):
     """Convert datetime object from UTC to local time zone"""
-    return datetime(*time.localtime(ts.timestamp())[:6])
+    return datetime(*time.localtime((ts - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds())[:6])
 
 
 def adjust_patterns(paths, excludes):