From 30a58130a5f19a6e43e850f4ba8f3120c7d97fce Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Tue, 12 Jan 2021 11:12:54 +0100 Subject: [PATCH] Date input: allow yyyy-mm for iso format --- gramps/gen/datehandler/_datedisplay.py | 3 +++ gramps/gen/datehandler/_dateparser.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gramps/gen/datehandler/_datedisplay.py b/gramps/gen/datehandler/_datedisplay.py index 5913dff9d..01d4a99ec 100644 --- a/gramps/gen/datehandler/_datedisplay.py +++ b/gramps/gen/datehandler/_datedisplay.py @@ -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: diff --git a/gramps/gen/datehandler/_dateparser.py b/gramps/gen/datehandler/_dateparser.py index 4dc5ea8b0..d07c6a877 100644 --- a/gramps/gen/datehandler/_dateparser.py +++ b/gramps/gen/datehandler/_dateparser.py @@ -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)):