Message3169
Support localized date formats by:
Creating a dictionary of
date formats. Select with
us, uk etc country code. E.G.
local_date_re={
'us': ( re.compile(r'''
((?P<m>\d\d?)/(?P<d>\d\d?)(/(?P<y>\d\d\d\d))?)? #
mm/dd/yyyy
(?P<n>[. ])? # . space
(((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d))?)? #
hh:mm:ss
(?P<o>.+)? # offset
''', re.VERBOSE),
_("format mm/dd/yyyy not found") ),
'uk': (re.compile(r'''
((?P<m>\d\d?)\.(?P<d>\d\d?)(\.(?P<y>\d\d))?)? #
mm.dd.yyyy
(?P<n>[. ])? # . space
(((?P<H>\d?\d):(?P<M>\d\d))?(:(?P<S>\d\d))?)? #
hh:mm:ss
(?P<o>.+)? # offset
''', re.VERBOSE),
_("format mm/dd/yy not found") )
}
Each value of the
dictionar is a list of
[ re, "error message"]
where the
error message is used if the pattern doesn't match.
then
after applying the serial date regexp, but before applying the
standard yyy-mm-dd.hh:mm:ss regexp
loop using something
like:
if config != None :
date_match_error = ''
for
country in
config.COUNTRY_DATE_FORMATS:
m=local_date_re[country][0].match(spec)
if
m is not None:
break
date_match_error =
date_match_error + local_date_re[country][1]
where
config is the tracker's self.db.config
onject.
COUNTRY_DATE_FORMATS is in config.py and
looks like:
COUNTRY_DATE_FORMATS = ['us', 'uk'
...]
So dates are first matched using serial format,
then
matched using the COUNTRY_DATE_FORMAT table (and
errors are generated if they don't match)
and the last format is
roundup's standard format. This allows multiple ways of
specifying the date format. The local_date_re could even be a
property of the date class and be extended at the tracker level.
|
|
Date |
User |
Action |
Args |
2009-02-03 14:23:38 | admin | link | issue691438 messages |
2009-02-03 14:23:38 | admin | create | |
|