Date input: allow yyyy-mm for iso format
This commit is contained in:
parent
6d24ab7d75
commit
30a58130a5
@ -407,6 +407,9 @@ class DateDisplay:
|
||||
if date_val[0] == date_val[1] == 0:
|
||||
# No month and no day -> year
|
||||
value = year
|
||||
elif date_val[0] == 0:
|
||||
# No day -> yyyy-mm
|
||||
value = "%s-%02d" % (year, date_val[1])
|
||||
else:
|
||||
value = "%s-%02d-%02d" % (year, date_val[1], date_val[0])
|
||||
if date_val[2] < 0:
|
||||
|
@ -481,7 +481,7 @@ class DateParser:
|
||||
% self._smon_str, re.IGNORECASE)
|
||||
self._numeric = re.compile(
|
||||
r"((\d+)[/\.]\s*)?((\d+)[/\.]\s*)?(\d+)\s*$")
|
||||
self._iso = re.compile(r"(\d+)(/(\d+))?-(\d+)-(\d+)\s*$")
|
||||
self._iso = re.compile(r"(\d+)(/(\d+))?-(\d+)(-(\d+))?\s*$")
|
||||
self._isotimestamp = re.compile(
|
||||
r"^\s*?(\d{4})([01]\d)([0123]\d)(?:(?:[012]\d[0-5]\d[0-5]\d)|"
|
||||
r"(?:\s+[012]\d:[0-5]\d(?::[0-5]\d)?))?\s*?$")
|
||||
@ -630,7 +630,7 @@ class DateParser:
|
||||
groups = match.groups()
|
||||
y = self._get_int(groups[0])
|
||||
m = self._get_int(groups[3])
|
||||
d = self._get_int(groups[4])
|
||||
d = self._get_int(groups[5])
|
||||
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)):
|
||||
|
Loading…
Reference in New Issue
Block a user