Skip to content

Instantly share code, notes, and snippets.

@jnyryan
Created February 26, 2013 20:35
Show Gist options
  • Select an option

  • Save jnyryan/5041918 to your computer and use it in GitHub Desktop.

Select an option

Save jnyryan/5041918 to your computer and use it in GitHub Desktop.
DateTime converter for WebKit format to Epoch format. For use with SqlLite, e.g. echo "SELECT visits.visit_time, urls.url FROM urls, visits WHERE urls.id = visits.url;" | sqlite3 History | chrometime.py
#!/usr/bin/python
import sys
import time
#
# For every line in stdin
#
for line in sys.stdin:
try :
# Find the first field (the time)
fields = line.split("|")
gtime = int(fields[0])
# Convert the time to human readable sortable format
structtime = time.gmtime((gtime - 11644473600000000)/1000000)
t = time.strftime("%y-%m-%d %H:%M:%S", structtime)
# print the time and the full line
print t, line.strip()
except ValueError:
print "Error: ", line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment