Working with zipfile module I found something weird about how it works.
I'm zipping one file, which last modified attr time is: 13:40:31 (HH:MM:SS) When I zip and unzip the file, its last mod time is 13:40:30 (lost 1 second)
Doing some tests around this, I used ZipInfo object to manually set the last modified time to 13:40:31 but still get 13:40:30.
I also tried setting to 13:40:41 and then I got 13:40:40.
Trying any other value to seconds, it works fine, so if I set it to 13:40:32, it's ok when unzip the file.
Any clue about this? Am I missing something?
OS: Windows 10 (64 bits) Python: 3.7
Test Just compress any file and then unzip it and compare last modified time
file = 'testfile.txt'
zf = zipfile.ZipFile(file='test.zip', mode='w', compression=zipfile.ZIP_DEFLATED)
info = zipfile.ZipInfo(file,
date_time=(2020, 9, 23, 13, 40, 31))
zf.writestr(info, open(file, 'r').read(), zipfile.ZIP_DEFLATED, 6)
zf.close()