From 23d20abd59a2fb040b90e40371b13928f8b5b523 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 7 Jun 2019 00:32:06 -0700 Subject: [PATCH] ParseDate: add a couple of more sanitizers --- PBot/Utils/ParseDate.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PBot/Utils/ParseDate.pm b/PBot/Utils/ParseDate.pm index 23c2f997..8396efb2 100644 --- a/PBot/Utils/ParseDate.pm +++ b/PBot/Utils/ParseDate.pm @@ -51,7 +51,9 @@ sub parsedate { $input =~ s/\byrs?\b/years/g; # sanitizers - $input =~ s/(\d+)\s+(am?|pm?)/$1$2/; # remove leading spaces from am/pm + $input =~ s/\b(\d+)\s+(am?|pm?)\b/$1$2/; # remove leading spaces from am/pm + $input =~ s/ (\d+)(am?|pm?)\b/ $1:00:00$2/; # convert 3pm to 3:00:00pm + $input =~ s/ (\d+:\d+)(am?|pm?)\b/ $1:00:00$2/; # convert 3:00pm to 3:00:00pm # split input on "and" or comma, then we'll add up the results # this allows us to parse things like "1 hour and 30 minutes"