Remove l10n from RFC dates

svn: r3578
This commit is contained in:
Alex Roitman 2004-09-27 04:55:39 +00:00
parent be471c8276
commit 0bc3d3e285

View File

@ -42,30 +42,22 @@ class DateParser:
# determine the code set returned by nl_langinfo # determine the code set returned by nl_langinfo
_codeset = locale.nl_langinfo(locale.CODESET) _codeset = locale.nl_langinfo(locale.CODESET)
_rfc_mons = ( # RFC-2822 only uses capitalized English abbreviated names, no locales.
unicode(locale.nl_langinfo(locale.ABMON_1),_codeset), _rfc_days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')
unicode(locale.nl_langinfo(locale.ABMON_2),_codeset), _rfc_mons_to_int = {
unicode(locale.nl_langinfo(locale.ABMON_3),_codeset), 'Jan' : 1,
unicode(locale.nl_langinfo(locale.ABMON_4),_codeset), 'Feb' : 2,
unicode(locale.nl_langinfo(locale.ABMON_5),_codeset), 'Mar' : 3,
unicode(locale.nl_langinfo(locale.ABMON_6),_codeset), 'Apr' : 4,
unicode(locale.nl_langinfo(locale.ABMON_7),_codeset), 'May' : 5,
unicode(locale.nl_langinfo(locale.ABMON_8),_codeset), 'Jun' : 6,
unicode(locale.nl_langinfo(locale.ABMON_9),_codeset), 'Jul' : 7,
unicode(locale.nl_langinfo(locale.ABMON_10),_codeset), 'Aug' : 8,
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset), 'Sep' : 9,
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset), 'Oct' : 10,
) 'Nov' : 11,
'Dec' : 12,
_rfc_days = ( }
unicode(locale.nl_langinfo(locale.ABDAY_1),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_2),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_3),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_4),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_5),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_6),_codeset),
unicode(locale.nl_langinfo(locale.ABDAY_7),_codeset),
)
month_to_int = { month_to_int = {
unicode(locale.nl_langinfo(locale.MON_1),_codeset).lower() : 1, unicode(locale.nl_langinfo(locale.MON_1),_codeset).lower() : 1,
@ -174,7 +166,7 @@ class DateParser:
'calculated' : Date.QUAL_CALCULATED, 'calculated' : Date.QUAL_CALCULATED,
} }
_rfc_mon_str = '(' + '|'.join(_rfc_mons) + ')' _rfc_mon_str = '(' + '|'.join(_rfc_mons_to_int.keys()) + ')'
_rfc_day_str = '(' + '|'.join(_rfc_days) + ')' _rfc_day_str = '(' + '|'.join(_rfc_days) + ')'
_qual_str = '(' + '|'.join( _qual_str = '(' + '|'.join(
@ -334,7 +326,7 @@ class DateParser:
if match: if match:
groups = match.groups() groups = match.groups()
d = self._get_int(groups[1]) d = self._get_int(groups[1])
m = self.month_to_int[groups[2].lower()] m = self._rfc_mons_to_int[groups[2]]
y = self._get_int(groups[3]) y = self._get_int(groups[3])
return (d,m,y,False) return (d,m,y,False)