You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in reference to: http://code.google.com/p/python-twitter/issues/detail?id=10
Sorry for the confusion, but the current way to parse the date does not
work with alternate locale settings.
calendar.timegm(time.strptime(self.created_at, '%a %b %d %H:%M:%S +0000 %Y'))
Since twitter appears to be using rfc822 dates, parse them as such:
import rfc822
calendar.timegm(rfc822.parsedate(self.created_at))
Example of the problem:
>>> import time
>>> mytime = time.strftime('%a %b %d %H:%M:%S +0000 %Y')
>>> time.strptime(mytime, '%a %b %d %H:%M:%S +0000 %Y')
(2008, 8, 8, 13, 22, 37, 4, 221, -1)
>>> import locale
>>> locale.setlocale(locale.LC_ALL, ('Russian_Russia', '1251'))
'Russian_Russia.1251'
>>> time.strptime(mytime, '%a %b %d %H:%M:%S +0000 %Y')
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "python\lib\_strptime.py", line 330, in strptime
(data_string, format))
ValueError: time data did not match format: data=Fri Aug 08 13:22:37 +0000
2008
fmt=%a %b %d %H:%M:%S +0000 %Y
>>> import rfc822
>>> rfc822.parsedate(mytime)
(2008, 8, 8, 13, 22, 37, 0, 1, 0)
Original issue reported on code.google.com by Stelmina...@gmail.com on 14 Aug 2008 at 11:09
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
Stelmina...@gmail.com
on 14 Aug 2008 at 11:09The text was updated successfully, but these errors were encountered: