Fixes #2697: 12:00 now parsed as Noon if am not specified

master
rsilvola 2016-03-04 14:07:39 +00:00
parent e538617f48
commit f0f10e2428
2 changed files with 10 additions and 2 deletions

View File

@ -97,7 +97,7 @@ handle query => sub {
# Optional spaces between tokens
\s*
# AM/PM
(?<american>(?:A|(?<pm>P))\.?M\.?)?
(?<american>(?:(?<am>A)|(?<pm>P))\.?M\.?)?
# Spaces between tokens
\s* \b
# Optional "from" indicator for input timezone
@ -117,7 +117,7 @@ handle query => sub {
my ($hours, $minutes, $seconds) = map { $_ // 0 } ($+{'h'}, $+{'m'}, $+{'s'});
my $american = $+{'american'};
my $pm = ($+{'pm'} && $hours != 12) ? 12 : (!$+{'pm'} && $hours == 12) ? -12 : 0;
my $pm = ($+{'pm'} && $hours != 12) ? 12 : ($+{'am'} && $hours == 12) ? -12 : 0;
my $input = {};
my $output = {};

View File

@ -173,6 +173,14 @@ ddg_goodie_test(
result => '17:00 BST',
},
),
'12:00 GMT in PST' =>
test_zci('4:00 PST',
structured_answer => {
input => ['12:00 GMT to PST (UTC-8)'],
operation => 'Convert Timezone',
result => '4:00 PST',
},
),
# Intentional non-answers
'12 in binary' => undef,