From 631875d9c2518ac33ac59b18dadc4dea393dec3b Mon Sep 17 00:00:00 2001 From: Steve Penrod Date: Wed, 20 Feb 2019 01:56:20 -0600 Subject: [PATCH] Tweak English extract_datetime() parsing Ambiguous times previously used a generally unexpected rule about when to jump 12 hours when parsing times. Now it follows the rule: If a time is spoken without am/pm indicator, assume the next time that hasn't passed was intended. For example: "at 7 o'clock" Would mean 7:00am if spoken at 6:59am, but would mean 7:00pm if spoken at 7:01am. --- mycroft/util/lang/parse_en.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mycroft/util/lang/parse_en.py b/mycroft/util/lang/parse_en.py index 02de1b1be4..2149ec0758 100644 --- a/mycroft/util/lang/parse_en.py +++ b/mycroft/util/lang/parse_en.py @@ -634,7 +634,6 @@ def extract_duration_en(text): not consumed in the parsing. The first value will be None if no duration is found. The text returned will have whitespace stripped from the ends. - """ if not text: return None @@ -1276,7 +1275,8 @@ def extract_datetime_en(string, dateNow, default_time): ((not daySpecified) or dayOffset < 1)): # ambiguous time, detect whether they mean this evening or # the next morning based on whether it has already passed - if dateNow.hour < HH: + if dateNow.hour < HH or (dateNow.hour == HH and + dateNow.minute < MM): pass # No modification needed elif dateNow.hour < HH + 12: HH += 12