7158: Some filters need a date of today; request to add "today" as a valid date to parser
svn: r23386
This commit is contained in:
parent
17c8be4322
commit
7d67e2bc46
@ -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):
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user