From ac00bd18430269247889a9402e453be3e32a19c1 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Wed, 12 Oct 2016 13:16:13 -0700 Subject: [PATCH] 9739: Wrong parsing Numeric date format for cs_CZ locale --- gramps/gen/datehandler/_date_cs.py | 3 +++ gramps/gen/datehandler/_dateparser.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gramps/gen/datehandler/_date_cs.py b/gramps/gen/datehandler/_date_cs.py index 431a50f69..cb92bafd9 100644 --- a/gramps/gen/datehandler/_date_cs.py +++ b/gramps/gen/datehandler/_date_cs.py @@ -171,6 +171,9 @@ class DateParserCZ(DateParser): 'vyp.' : Date.QUAL_CALCULATED, } + # bug 9739 _grampslocale.py gets '%-d.%-m.%Y' and makes it be '%/d.%/m.%Y' + fmt = DateParser.fmt.replace('/', '') # so counteract that + def init_strings(self): DateParser.init_strings(self) self._text2 = re.compile('(\d+)?\.?\s+?%s\.?\s*((\d+)(/\d+)?)?\s*$' diff --git a/gramps/gen/datehandler/_dateparser.py b/gramps/gen/datehandler/_dateparser.py index 104ce1872..a81f8539d 100644 --- a/gramps/gen/datehandler/_dateparser.py +++ b/gramps/gen/datehandler/_dateparser.py @@ -194,6 +194,7 @@ class DateParser(object): _locale = GrampsLocale(lang='en', languages='en') + fmt = _grampslocale.tformat _fmt_parse = re.compile(".*%(\S).*%(\S).*%(\S).*") # RFC-2822 only uses capitalized English abbreviated names, no locales. @@ -343,8 +344,7 @@ class DateParser(object): Date.CAL_SWEDISH : self._parse_swedish, } - fmt = _grampslocale.tformat - match = self._fmt_parse.match(fmt.lower()) + match = self._fmt_parse.match(self.fmt.lower()) if match: self.dmy = (match.groups() == ('d', 'm', 'y') or \ match.groups() == ('d', 'b', 'y'))