From 7d67e2bc4682e1ba7547becb103c33a30c65b28b Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Thu, 24 Oct 2013 22:27:14 +0000 Subject: [PATCH] 7158: Some filters need a date of today; request to add "today" as a valid date to parser svn: r23386 --- gramps/gen/datehandler/_dateparser.py | 8 ++++++-- gramps/gen/lib/date.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gramps/gen/datehandler/_dateparser.py b/gramps/gen/datehandler/_dateparser.py index d4f38fe95..a1350ecde 100644 --- a/gramps/gen/datehandler/_dateparser.py +++ b/gramps/gen/datehandler/_dateparser.py @@ -49,7 +49,7 @@ log = logging.getLogger(".DateParser") # GRAMPS modules # #------------------------------------------------------------------------- -from ..lib.date import Date, DateError +from ..lib.date import Date, DateError, Today from . import _grampslocale from ..utils.grampslocale import GrampsLocale from ._datestrings import DateStrings @@ -628,7 +628,11 @@ class DateParser(object): if check and not check((d, m, y)): value = Date.EMPTY return value - + + match = re.match("^\s*%s\s*$" % "today", text, re.IGNORECASE) + if match: + return Today().get_dmy(get_slash=True) + return Date.EMPTY def match_calendar(self, text, cal): diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index a7b4bf919..7fff65444 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -1727,6 +1727,15 @@ class Date(object): """ return (self.get_year(), self.get_month(), self.get_day()) + def get_dmy(self, get_slash=False): + """ + Return (day, month, year, [slash]). + """ + if get_slash: + return (self.get_day(), self.get_month(), self.get_year(), self.get_slash()) + else: + return (self.get_day(), self.get_month(), self.get_year()) + def get_stop_ymd(self): """ Return (year, month, day) of the stop date, or all-zeros if it's not defined.