Created
February 26, 2013 20:35
-
-
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
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/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