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
|
# GRAMPS modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from ..lib.date import Date, DateError
|
from ..lib.date import Date, DateError, Today
|
||||||
from . import _grampslocale
|
from . import _grampslocale
|
||||||
from ..utils.grampslocale import GrampsLocale
|
from ..utils.grampslocale import GrampsLocale
|
||||||
from ._datestrings import DateStrings
|
from ._datestrings import DateStrings
|
||||||
@ -629,6 +629,10 @@ class DateParser(object):
|
|||||||
value = Date.EMPTY
|
value = Date.EMPTY
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
match = re.match("^\s*%s\s*$" % "today", text, re.IGNORECASE)
|
||||||
|
if match:
|
||||||
|
return Today().get_dmy(get_slash=True)
|
||||||
|
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
|
|
||||||
def match_calendar(self, text, cal):
|
def match_calendar(self, text, cal):
|
||||||
|
@ -1727,6 +1727,15 @@ class Date(object):
|
|||||||
"""
|
"""
|
||||||
return (self.get_year(), self.get_month(), self.get_day())
|
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):
|
def get_stop_ymd(self):
|
||||||
"""
|
"""
|
||||||
Return (year, month, day) of the stop date, or all-zeros if it's not defined.
|
Return (year, month, day) of the stop date, or all-zeros if it's not defined.
|
||||||
|
Loading…
Reference in New Issue
Block a user