Created
May 6, 2009 07:20
-
-
Save k0001/107415 to your computer and use it in GitHub Desktop.
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
def utc_datetime_from_twitter_timestamp(s): | |
"""Parses as datetime.datetime in UTC a string formated Twitter timestamp""" | |
# we must parse the date in an english locale (due to %a and %b) | |
prev_loc = locale.getlocale() | |
try: | |
locale.setlocale(locale.LC_ALL, 'C') | |
return datetime.datetime.strptime(s, '%a %b %d %H:%M:%S +0000 %Y') | |
finally: | |
locale.setlocale(locale.LC_ALL, prev_loc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment