diff --git a/lib/DDG/Goodie/Timer.pm b/lib/DDG/Goodie/Timer.pm index a2319f19d..a1ca149d4 100644 --- a/lib/DDG/Goodie/Timer.pm +++ b/lib/DDG/Goodie/Timer.pm @@ -8,7 +8,7 @@ zci answer_type => 'timer'; zci is_cached => 1; my @triggers = ('timer', 'countdown', 'count down', 'alarm', 'reminder'); -# Triggers that are vaild, but not stripped from the resulting query +# Triggers that are valid, but not stripped from the resulting query my @nonStrippedTriggers = qw(minutes mins seconds secs hours hrs); # Triggers that are valid in start only my @baseTriggers = qw(start begin set run); @@ -20,7 +20,7 @@ push(@startTriggers, @baseTriggers); # Beautifies the trigger can be appended in front/back of trigger my @beautifierTriggers = qw(online); #Joins the Timer Value -my @joiners = qw(for on at to with); +my @joiners = qw(for on at to with of); # StartEndTriggers to trigger on nonStrippedTriggers, startTriggers, beautifierTriggers and triggers my @triggersStartEnd = (@triggers, @nonStrippedTriggers, @startTriggers, @beautifierTriggers); # Ambigous triggers which should not give Timer IA @@ -117,6 +117,13 @@ handle remainder => sub { if($raw =~ /^($ambTrgx)$/){ return; } + + # When query doesn't ask for timer explicitly and just wants time + # calculations, don't invoke IA. + if($raw !~ /($trgx)/ and $raw =~ /[+-]/) { + return; + } + # When the query is empty and we know that the trigger word matches # the trigger exactly (whitespace check) we can return a valid result if($qry eq '') { diff --git a/t/Timer.t b/t/Timer.t index 7b4f0d5c1..9a927f570 100644 --- a/t/Timer.t +++ b/t/Timer.t @@ -104,6 +104,8 @@ ddg_goodie_test( 'timer 60 minutes' => build_test('3600'), 'start a timer for 20 minutes' => build_test('1200'), 'set a timer to 60 minutes' => build_test('3600'), + 'set a timer of 60 minutes' => build_test('3600'), + 'timer of 5:15 mins' => build_test('315'), # Should not trigger 'start 30 minutes for timer' => undef, 'run with timer' => undef, @@ -121,7 +123,9 @@ ddg_goodie_test( '20 minutes' => undef, ' 22 minutes' => undef, '60 minutes' => undef, - '48 hours ' => undef + '48 hours ' => undef, + '5:15 + 32 minutes' => undef, + '3:32 - 8 mins' => undef ); done_testing;