From e8eaaf3a25fd4f2b9185b80927f414f2803ad70a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 22 Sep 2019 02:09:39 +0200 Subject: [PATCH] Dateparser: parse future dates by default (closes #89) --- royalnet/commands/royalgames/mm.py | 4 +++- royalnet/commands/royalgames/reminder.py | 4 +++- royalnet/version.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/royalnet/commands/royalgames/mm.py b/royalnet/commands/royalgames/mm.py index df4ed698..55b59b80 100644 --- a/royalnet/commands/royalgames/mm.py +++ b/royalnet/commands/royalgames/mm.py @@ -364,7 +364,9 @@ class MmCommand(Command): except InvalidInputError: timestring, title, description = args.match(r"\s*(.+?)\s*\n\s*([^\n]+)\s*\n?\s*(.+)?\s*", re.DOTALL) try: - dt: typing.Optional[datetime.datetime] = dateparser.parse(timestring) + dt: typing.Optional[datetime.datetime] = dateparser.parse(timestring, settings={ + "PREFER_DATES_FROM": "future" + }) except OverflowError: dt = None if dt is None: diff --git a/royalnet/commands/royalgames/reminder.py b/royalnet/commands/royalgames/reminder.py index df3c156d..c7148b13 100644 --- a/royalnet/commands/royalgames/reminder.py +++ b/royalnet/commands/royalgames/reminder.py @@ -59,7 +59,9 @@ class ReminderCommand(Command): date_str, reminder_text = args.match(r"\s*(.+?)\s*\n\s*([^\n]+)\s*") try: - date: typing.Optional[datetime.datetime] = dateparser.parse(date_str) + date: typing.Optional[datetime.datetime] = dateparser.parse(date_str, settings={ + "PREFER_DATES_FROM": "future" + }) except OverflowError: date = None if date is None: diff --git a/royalnet/version.py b/royalnet/version.py index 48d4e2dc..e8771149 100644 --- a/royalnet/version.py +++ b/royalnet/version.py @@ -1 +1 @@ -semantic = "5.0a56" +semantic = "5.0a57"