import time
import htmlentitydefs
import re
+import locale
-def parse_datetime(str):
+def parse_datetime(string):
+ # Set locale for date parsing
+ locale.setlocale(locale.LC_TIME, 'C')
# We must parse datetime this way to work in python 2.4
- return datetime(*(time.strptime(str, '%a %b %d %H:%M:%S +0000 %Y')[0:6]))
+ date = datetime(*(time.strptime(string, '%a %b %d %H:%M:%S +0000 %Y')[0:6]))
+
+ # Reset locale back to the default setting
+ locale.setlocale(locale.LC_TIME, '')
+ return date
def parse_html_value(html):
return atag[start:end]
-def parse_search_datetime(str):
+def parse_search_datetime(string):
+ # Set locale for date parsing
+ locale.setlocale(locale.LC_TIME, 'C')
+
+ # We must parse datetime this way to work in python 2.4
+ date = datetime(*(time.strptime(string, '%a, %d %b %Y %H:%M:%S +0000')[0:6]))
- # python 2.4
- return datetime(*(time.strptime(str, '%a, %d %b %Y %H:%M:%S +0000')[0:6]))
+ # Reset locale back to the default setting
+ locale.setlocale(locale.LC_TIME, '')
+ return date
def unescape_html(text):