tweak some DateParser comments
This commit is contained in:
parent
829a8bd01d
commit
c632d0f6a9
@ -229,6 +229,7 @@ class DateParserHU(DateParser):
|
||||
|
||||
self._numeric = re.compile(
|
||||
"((\d+)[/\.])?\s*((\d+)[/\.])?\s*(\d+)[/\. ]?$")
|
||||
# this next RE has the (possibly-slashed) year at the string's start
|
||||
self._text2 = re.compile('((\d+)(/\d+)?\.)?\s+?%s\.?\s*(\d+\.)?\s*$'
|
||||
% self._mon_str, re.IGNORECASE)
|
||||
_span_1 = ['-tó\(ő\)l', '-tól', '-től']
|
||||
|
@ -130,6 +130,7 @@ class DateParserLT(DateParser):
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
# this next RE has the (possibly-slashed) year at the string's start
|
||||
self._text2 = re.compile('((\d+)(/\d+)?)?\s+?m\.\s+%s\s*(\d+)?\s*d?\.?$'
|
||||
% self._mon_str, re.IGNORECASE)
|
||||
_span_1 = ['nuo']
|
||||
|
@ -522,7 +522,7 @@ class DateParser:
|
||||
|
||||
def _parse_calendar(self, text, regex1, regex2, mmap, check=None):
|
||||
match = regex1.match(text.lower())
|
||||
if match: # user typed in month-name day year
|
||||
if match: # user typed in 'month-name day year' or 'month-name year'
|
||||
groups = match.groups()
|
||||
if groups[0] is None:
|
||||
m = 0
|
||||
@ -535,10 +535,10 @@ class DateParser:
|
||||
s = False
|
||||
else:
|
||||
d = self._get_int(groups[1])
|
||||
if groups[4] is not None: # slash year "/80"
|
||||
if groups[4] is not None:
|
||||
y = int(groups[3]) + 1 # fullyear + 1
|
||||
s = True
|
||||
else: # regular, non-slash date
|
||||
s = True # slash year
|
||||
else: # regular year
|
||||
y = int(groups[3])
|
||||
s = False
|
||||
value = (d, m, y, s)
|
||||
@ -561,10 +561,10 @@ class DateParser:
|
||||
y = None
|
||||
s = False
|
||||
else:
|
||||
if groups[2] is not None: # slash year digit
|
||||
if groups[2] is not None:
|
||||
y = int(groups[1]) + 1 # fullyear + 1
|
||||
s = True
|
||||
else: # regular, non-slash year
|
||||
s = True # slash year
|
||||
else: # regular year
|
||||
y = int(groups[1])
|
||||
s = False
|
||||
else:
|
||||
@ -577,10 +577,10 @@ class DateParser:
|
||||
y = None
|
||||
s = False
|
||||
else:
|
||||
if groups[4] is not None: # slash year digit
|
||||
if groups[4] is not None:
|
||||
y = int(groups[3]) + 1 # fullyear + 1
|
||||
s = True
|
||||
else: # regular, non-slash year
|
||||
s = True # slash year
|
||||
else: # regular year
|
||||
y = int(groups[3])
|
||||
s = False
|
||||
value = (d, m, y, s)
|
||||
@ -621,8 +621,8 @@ class DateParser:
|
||||
y = self._get_int(groups[0])
|
||||
m = self._get_int(groups[3])
|
||||
d = self._get_int(groups[4])
|
||||
if groups[2] and julian_valid((d, m, y + 1)): # slash year digit
|
||||
return (d, m, y + 1, True)
|
||||
if groups[2] and julian_valid((d, m, y + 1)):
|
||||
return (d, m, y + 1, True) # slash year
|
||||
if check is None or check((d, m, y)):
|
||||
return (d, m, y, False)
|
||||
return Date.EMPTY
|
||||
|
Loading…
Reference in New Issue
Block a user