Created
August 9, 2018 16:19
-
-
Save eliask/f5b157567030864cf7da1cd15413dd8f to your computer and use it in GitHub Desktop.
Get the most recent timestamp from a ZIP file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Prints the most recent timestamp for a file in a ZIP file (RFC-3339 format without timezone) | |
import datetime as dt | |
import sys | |
import zipfile | |
if not sys.argv[1:]: | |
print ('Usage: {} foo.zip'.format(sys.argv[0])) | |
exit(1) | |
z = zipfile.ZipFile(sys.argv[1]) | |
t = dt.datetime(*max(a.date_time for a in z.infolist())) | |
print (t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment