@@ -65,17 +65,15 @@ def write_zip(
65
65
# Python2 expects bytes filenames
66
66
zip_name = zip_name .encode (encoding , "replace" )
67
67
68
- if info .has_namespace ("stat" ):
69
- # If the file has a stat namespace, get the
70
- # zip time directory from the stat structure
71
- st_mtime = info .get ("stat" , "st_mtime" , None )
72
- _mtime = time .localtime (st_mtime )
73
- zip_time = _mtime [0 :6 ] # type: ZipTime
74
- else :
75
- # Otherwise, use the modified time from details
76
- # namespace.
77
- mt = info .modified or datetime .utcnow ()
78
- zip_time = (mt .year , mt .month , mt .day , mt .hour , mt .minute , mt .second )
68
+ # If the file has a stat namespace, get the
69
+ # zip time directory from the stat structure
70
+ st_mtime = info .get ("stat" , "st_mtime" )
71
+ # Otherwise, use the modified time from details namespace.
72
+ if st_mtime is None :
73
+ st_mtime = info .get ("details" , "modified" )
74
+
75
+ # If st_mtime is still None this will default to current time
76
+ zip_time = time .localtime (st_mtime )[:6 ] # type: ZipTime
79
77
80
78
# NOTE(@althonos): typeshed's `zipfile.py` on declares
81
79
# ZipInfo.__init__ for Python < 3 ?!
0 commit comments