Skip to content
This repository was archived by the owner on Oct 15, 2022. It is now read-only.

Commit f73dd07

Browse files
committed
Stricter filtering of date queries
1 parent 6244a1a commit f73dd07

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/DDG/Goodie/ChineseZodiac.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ handle remainder => sub {
3939
#Figure out what year the user is interested in
4040
my $year_gregorian;
4141

42+
#Return if more than one number has been included;
43+
# this IA only supports years (for now)
44+
return if /\d+[^\d]+\d+/;
45+
4246
#Parse out a relative year expression if it was supplied
4347
if (/this\syear('s)?/) {
4448
$year_gregorian = DateTime->now(time_zone => 'Asia/Shanghai') or return;

t/ChineseZodiac.t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ ddg_goodie_test(
6161
'what is my zodiac sign' => undef,
6262
'what is the chinese word for duck' => undef,
6363
'buy an inflatable zodiac chinese online store' => undef,
64+
'chinese zodiac 20 march 1997' => undef,
65+
'chinese zodiac 1997-03-20' => undef,
66+
'what was the chinese zodiac animal on the 3rd of april 1945' => undef,
6467

6568
#No support currently for years outside 1900--2069
6669
'chinese zodiac 1899' => undef,

0 commit comments

Comments
 (0)