From 1916383a284b3d23d3b823e4527bbec05d26ab70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Vejda?= Date: Sun, 15 Dec 2019 13:03:30 +0100 Subject: [PATCH] Update date parsing for czech locale (#968) * Fixes bug ID 0011470: some date variants in CS language are not consider valid --- gramps/gen/datehandler/_date_cs.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gramps/gen/datehandler/_date_cs.py b/gramps/gen/datehandler/_date_cs.py index 6b345f969..d89ff1c08 100644 --- a/gramps/gen/datehandler/_date_cs.py +++ b/gramps/gen/datehandler/_date_cs.py @@ -50,6 +50,15 @@ class DateParserCZ(DateParser): Converts a text string into a Date object """ + quality_to_int = { + 'přibližně' : Date.QUAL_ESTIMATED, + 'odhadem' : Date.QUAL_ESTIMATED, + 'odh.' : Date.QUAL_ESTIMATED, + 'vypočteno' : Date.QUAL_CALCULATED, + 'vypočtené' : Date.QUAL_CALCULATED, + 'vyp.' : Date.QUAL_CALCULATED, + } + bce = ["před naším letopočtem", "před Kristem", "př. n. l.", "př. Kr."] + DateParser.bce @@ -58,6 +67,17 @@ class DateParserCZ(DateParser): # bug 9739 grampslocale.py gets '%-d.%-m.%Y' -- makes it be '%/d.%/m.%Y' self.dhformat = self.dhformat.replace('/', '') # so counteract that + def init_strings(self): + DateParser.init_strings(self) + self._text2 = re.compile(r'(\d+)?\.?\s+?%s\.?\s*((\d+)(/\d+)?)?\s*$' + % self._mon_str, re.IGNORECASE) + self._span = re.compile( + r"(od)\s+(?P.+)\s+(do)\s+(?P.+)", + re.IGNORECASE) + self._range = re.compile( + r"(mezi)\s+(?P.+)\s+(a)\s+(?P.+)", + re.IGNORECASE) + #------------------------------------------------------------------------- # # Czech display