add a few comments to the date parser (since I keep forgetting)
This commit is contained in:
parent
b9b4d2e175
commit
4657f91116
@ -451,6 +451,7 @@ class DateParser:
|
|||||||
self._abt2 = re.compile('<(.*)>', re.IGNORECASE)
|
self._abt2 = re.compile('<(.*)>', re.IGNORECASE)
|
||||||
self._text = re.compile('%s\.?\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?\s*$' % self._mon_str,
|
self._text = re.compile('%s\.?\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?\s*$' % self._mon_str,
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
|
# this next RE has the (possibly-slashed) year at the string's end
|
||||||
self._text2 = re.compile('(\d+)?\s+?%s\.?\s*((\d+)(/\d+)?)?\s*$' % self._mon_str,
|
self._text2 = re.compile('(\d+)?\s+?%s\.?\s*((\d+)(/\d+)?)?\s*$' % self._mon_str,
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
self._jtext = re.compile('%s\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?\s*$' % self._jmon_str,
|
self._jtext = re.compile('%s\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?\s*$' % self._jmon_str,
|
||||||
@ -521,7 +522,7 @@ class DateParser:
|
|||||||
|
|
||||||
def _parse_calendar(self, text, regex1, regex2, mmap, check=None):
|
def _parse_calendar(self, text, regex1, regex2, mmap, check=None):
|
||||||
match = regex1.match(text.lower())
|
match = regex1.match(text.lower())
|
||||||
if match:
|
if match: # user typed in month-name day year
|
||||||
groups = match.groups()
|
groups = match.groups()
|
||||||
if groups[0] is None:
|
if groups[0] is None:
|
||||||
m = 0
|
m = 0
|
||||||
@ -546,7 +547,7 @@ class DateParser:
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
match = regex2.match(text.lower())
|
match = regex2.match(text.lower())
|
||||||
if match:
|
if match: # user typed in day month-name year or year month-name day
|
||||||
groups = match.groups()
|
groups = match.groups()
|
||||||
if self.ymd:
|
if self.ymd:
|
||||||
if groups[3] is None:
|
if groups[3] is None:
|
||||||
@ -906,8 +907,6 @@ class DateParser:
|
|||||||
if subdate == Date.EMPTY and text != "":
|
if subdate == Date.EMPTY and text != "":
|
||||||
date.set_as_text(text)
|
date.set_as_text(text)
|
||||||
return
|
return
|
||||||
#else:
|
|
||||||
# print 'valid subdate', text, subdate
|
|
||||||
except:
|
except:
|
||||||
date.set_as_text(text)
|
date.set_as_text(text)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user