Skip to content

Instantly share code, notes, and snippets.

@harrtho
Created November 14, 2017 18:08
Show Gist options
  • Save harrtho/313363e1eb2faecf858f384665657c62 to your computer and use it in GitHub Desktop.
Save harrtho/313363e1eb2faecf858f384665657c62 to your computer and use it in GitHub Desktop.
# Python 2
import datetime
def getFiletime(dt):
microseconds = int(dt, 16) / 10
seconds, microseconds = divmod(microseconds, 1000000)
days, seconds = divmod(seconds, 86400)
return datetime.datetime(1601, 1, 1) + datetime.timedelta(days, seconds, microseconds)
print format(getFiletime(hex(13024882639633631*10)[2:17]), '%a, %d %B %Y %H:%M:%S %Z')
# Python 3
import datetime
def getFiletime(dtms):
seconds, micros = divmod(dtms, 1000000)
days, seconds = divmod(seconds, 86400)
return datetime.datetime(1601, 1, 1) + datetime.timedelta(days, seconds, micros)
print( getFiletime(13024882639633631).strftime( '%a, %d %B %Y %H:%M:%S %Z' ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment