3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 10:59:29 +01:00

ParseDate: add a couple of more sanitizers

This commit is contained in:
Pragmatic Software 2019-06-07 00:32:06 -07:00
parent bf77f9e3dc
commit 23d20abd59

View File

@ -51,7 +51,9 @@ sub parsedate {
$input =~ s/\byrs?\b/years/g; $input =~ s/\byrs?\b/years/g;
# sanitizers # 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 # 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" # this allows us to parse things like "1 hour and 30 minutes"