Created
June 14, 2012 05:46
-
-
Save robertklep/2928188 to your computer and use it in GitHub Desktop.
Convert RFC822 timestamp string to datetime object in Python
This file contains 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
from datetime import datetime | |
import email | |
# convert RFC822 timestamp string to datetime object | |
def rfc822(timestamp): | |
return datetime.fromtimestamp(email.Utils.mktime_tz(email.Utils.parsedate_tz(timestamp))) | |
if __name__ == '__main__': | |
import sys | |
print rfc822(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment