Created
January 19, 2012 21:15
-
-
Save amdavidson/1642652 to your computer and use it in GitHub Desktop.
A quick python script to convert all dates to unix time.
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 os, sys | |
import dateutil | |
import dateutil.parser | |
import time | |
import calendar | |
import fileinput | |
for line in fileinput.input(inplace=1): | |
if 'date: ' in line: | |
old = line.lstrip("date: ").rstrip("\n") | |
old_mod = old + " PST" | |
d = dateutil.parser.parse(old_mod, fuzzy=True) | |
t = time.strptime(d.ctime()) | |
new = time.mktime(t) | |
line = "date: " + str(new) | |
print line | |
else: | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment