Update date parsing for czech locale (#968)

* Fixes bug ID 0011470: some date variants in CS language are not consider valid
This commit is contained in:
Jiří Vejda 2019-12-15 13:03:30 +01:00 committed by romjerome
parent 379c96ee6a
commit 1916383a28

View File

@ -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<start>.+)\s+(do)\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile(
r"(mezi)\s+(?P<start>.+)\s+(a)\s+(?P<stop>.+)",
re.IGNORECASE)
#-------------------------------------------------------------------------
#
# Czech display