Stricter filtering of date queries

This commit is contained in:
David Wilkins 2014-06-21 11:15:25 +08:00
parent 6244a1ada7
commit f73dd0721e
2 changed files with 7 additions and 0 deletions

View File

@ -39,6 +39,10 @@ handle remainder => sub {
#Figure out what year the user is interested in #Figure out what year the user is interested in
my $year_gregorian; my $year_gregorian;
#Return if more than one number has been included;
# this IA only supports years (for now)
return if /\d+[^\d]+\d+/;
#Parse out a relative year expression if it was supplied #Parse out a relative year expression if it was supplied
if (/this\syear('s)?/) { if (/this\syear('s)?/) {
$year_gregorian = DateTime->now(time_zone => 'Asia/Shanghai') or return; $year_gregorian = DateTime->now(time_zone => 'Asia/Shanghai') or return;

View File

@ -61,6 +61,9 @@ ddg_goodie_test(
'what is my zodiac sign' => undef, 'what is my zodiac sign' => undef,
'what is the chinese word for duck' => undef, 'what is the chinese word for duck' => undef,
'buy an inflatable zodiac chinese online store' => undef, 'buy an inflatable zodiac chinese online store' => undef,
'chinese zodiac 20 march 1997' => undef,
'chinese zodiac 1997-03-20' => undef,
'what was the chinese zodiac animal on the 3rd of april 1945' => undef,
#No support currently for years outside 1900--2069 #No support currently for years outside 1900--2069
'chinese zodiac 1899' => undef, 'chinese zodiac 1899' => undef,