SunInfo: Implementing latitude & longitude
parent
903c7cf610
commit
41a0512e59
|
@ -62,11 +62,13 @@ handle remainder => sub {
|
||||||
$dt = parse_datestring_to_date($+{'when'}) if($+{'when'});
|
$dt = parse_datestring_to_date($+{'when'}) if($+{'when'});
|
||||||
|
|
||||||
return unless $dt; # Also going to need to know which day.
|
return unless $dt; # Also going to need to know which day.
|
||||||
$dt->set_time_zone($tz);
|
$dt->set_time_zone($tz) unless ($+{'lat'} && $+{'lon'});
|
||||||
|
|
||||||
$lon = parse_arc($+{'lon'}) if ($+{'lon'});
|
$lon = parse_arc($+{'lon'}) if ($+{'lon'});
|
||||||
$lat = parse_arc($+{'lat'}) if ($+{'lat'});
|
$lat = parse_arc($+{'lat'}) if ($+{'lat'});
|
||||||
|
|
||||||
|
$where = "coordinates ${lat}°N ${lon}°E" if($+{'lat'} && $+{'lon'});
|
||||||
|
|
||||||
my $sun_at_loc = DateTime::Event::Sunrise->new(
|
my $sun_at_loc = DateTime::Event::Sunrise->new(
|
||||||
longitude => $lon,
|
longitude => $lon,
|
||||||
latitude => $lat,
|
latitude => $lat,
|
||||||
|
|
|
@ -30,10 +30,10 @@ ddg_goodie_test(
|
||||||
'sunset on 2015-01-01' => test_zci(@exact),
|
'sunset on 2015-01-01' => test_zci(@exact),
|
||||||
'what time is sunrise on 2015-01-01?' => test_zci(@exact),
|
'what time is sunrise on 2015-01-01?' => test_zci(@exact),
|
||||||
'January 1st, 2015 sunrise' => test_zci(@exact),
|
'January 1st, 2015 sunrise' => test_zci(@exact),
|
||||||
q{sunrise at 39°57'N 75°10'W} => test_zci(""),
|
q{sunrise at 39°57'N 5°10'W} => test_zci(qr"On.*coordinates .*AM.*PM", html => '-ANY-'),
|
||||||
'sunset at 53N 10E' => test_zci(""),
|
'sunset at 1S 1W' => test_zci(qr"On .*, sunrise in coordinates -1°N -1°E is at .*AM; sunset at .*PM.", html => '-ANY-'),
|
||||||
'sunset at 53S 15W' => test_zci(""),
|
'sunset at 53N 2E on 2014-01-01' => test_zci("On 01 Jan 2014, sunrise in coordinates 53°N 2°E is at 8:05 AM; sunset at 3:46 PM.", html => '-ANY-'),
|
||||||
'sunset at 53N 10E on 2014-01-01' => test_zci(""),
|
'sunset at 53N 2W on 2014-01-08' => test_zci("On 08 Jan 2014, sunrise in coordinates 53°N -2°E is at 8:18 AM; sunset at 4:11 PM.", html => '-ANY-'),
|
||||||
'sunset for philly' => undef,
|
'sunset for philly' => undef,
|
||||||
'sunrise on mars' => undef,
|
'sunrise on mars' => undef,
|
||||||
'sunset boulevard' => undef,
|
'sunset boulevard' => undef,
|
||||||
|
|
Loading…
Reference in New Issue