Skip to content

Instantly share code, notes, and snippets.

@eliask
Created August 9, 2018 16:19
Show Gist options
  • Save eliask/f5b157567030864cf7da1cd15413dd8f to your computer and use it in GitHub Desktop.
Save eliask/f5b157567030864cf7da1cd15413dd8f to your computer and use it in GitHub Desktop.
Get the most recent timestamp from a ZIP file
#! /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