parent
dc15d8cb83
commit
5121d7536f
|
@ -10,7 +10,7 @@ use Try::Tiny;
|
|||
zci answer_type => "sun_info";
|
||||
zci is_cached => 0;
|
||||
|
||||
triggers start => 'sunrise', 'sunset';
|
||||
triggers start => 'sunrise', 'sunset', 'what time is sunset', 'what time is sunrise';
|
||||
|
||||
primary_example_queries 'sunrise', 'sunset';
|
||||
secondary_example_queries 'sunrise for aug 30', 'sunset on 2015-01-01';
|
||||
|
@ -25,7 +25,8 @@ my $datestring_regex = datestring_regex();
|
|||
|
||||
handle remainder => sub {
|
||||
|
||||
my $remainder = shift;
|
||||
my $remainder = shift // '';
|
||||
$remainder =~ s/\?//g; # Strip question marks.
|
||||
my ($lat, $lon, $tz) = ($loc->latitude, $loc->longitude, $loc->time_zone);
|
||||
my $where = join(', ', grep { defined $_ } ($loc->city, $loc->region_name, $loc->country_name));
|
||||
return unless (($lat || $lon) && $tz && $where); # We'll need a real location and time zone.
|
||||
|
|
22
t/SunInfo.t
22
t/SunInfo.t
|
@ -20,14 +20,20 @@ ddg_goodie_test([qw(
|
|||
DDG::Goodie::SunInfo
|
||||
)
|
||||
],
|
||||
'sunrise' => test_zci(@now),
|
||||
'sunset' => test_zci(@now),
|
||||
'sunrise for aug 30' => test_zci(@aug),
|
||||
'sunset for aug 30' => test_zci(@aug),
|
||||
'sunset on 2015-01-01' => test_zci(@exact),
|
||||
'sunrise on 2015-01-01' => test_zci(@exact),
|
||||
'sunset for pilly' => undef,
|
||||
'sunrise on mars' => undef,
|
||||
'sunrise' => test_zci(@now),
|
||||
'what time is sunrise' => test_zci(@now),
|
||||
'sunset' => test_zci(@now),
|
||||
'what time is sunset' => test_zci(@now),
|
||||
'sunrise for aug 30' => test_zci(@aug),
|
||||
'sunset for aug 30?' => test_zci(@aug),
|
||||
'sunset on 2015-01-01' => test_zci(@exact),
|
||||
'what time is sunrise on 2015-01-01?' => test_zci(@exact),
|
||||
'sunset for pilly' => undef,
|
||||
'sunrise on mars' => undef,
|
||||
'sunset boulevard' => undef,
|
||||
'tequila sunrise' => undef,
|
||||
'sunrise mall' => undef,
|
||||
'after the sunset' => undef,
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue