diff --git a/internal/router/dateparser.go b/internal/router/dateparser.go index 908dfee..fe13e1b 100644 --- a/internal/router/dateparser.go +++ b/internal/router/dateparser.go @@ -49,6 +49,13 @@ try: text = re.sub(r'(\d+)\s+(?:час(?:а|ов)?\s+)?вечера\b', r'\1 pm', text, flags=re.IGNORECASE) text = re.sub(r'(\d+)\s+(?:час(?:а|ов)?\s+)?дня\b', r'\1 pm', text, flags=re.IGNORECASE) text = re.sub(r'(\d+)\s+(?:час(?:а|ов)?\s+)?ночи\b', r'\1 am', text, flags=re.IGNORECASE) + # A bare hour after a preposition is dropped on the floor by dateparser: + # "завтра в 7" resolves to tomorrow at the CURRENT clock, and "завтра в 7 + # часов" is read as seven hours from now. Only a qualifier (already an + # am/pm above) or a colon makes it read the hour, so give it the colon. + # English "at 7" fails identically, so both prepositions are rewritten. + text = re.sub(r'(? 130*time.Minute { + t.Errorf("через 2 часа: got %v from now, want ~2h", d) + } + }, + }, { name: "no date — напомни мне", text: "напомни мне",