Code cleanups in functions get_sunrise_time and get_sunset_time.
This commit is contained in:
parent
8a560a2086
commit
ae827999bd
1 changed files with 4 additions and 8 deletions
|
@ -80,13 +80,11 @@ sub get_sunrise_time
|
|||
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
|
||||
$Year += 1900;
|
||||
$Month++;
|
||||
|
||||
my $dt = DateTime->new( year => $Year, month => $Month, day => $Day, time_zone => $TIMEZONE, );
|
||||
# Note, localtime returns months 0..11, Datetime->new expects months 1..12.
|
||||
my $dt = DateTime->new( year => $Year, month => $Month+1, day => $Day, time_zone => $TIMEZONE, );
|
||||
my $sunrise = DateTime::Event::Sunrise ->new( longitude => $LONGITUDE, latitude => $LATITUDE, altitude => '-0.833', iteration => '1');
|
||||
|
||||
$Month--;
|
||||
|
||||
my $dt1 = $sunrise->sunrise_datetime($dt);
|
||||
|
||||
($sunrise_time) = $dt1->datetime =~ /T(.*)\:/;
|
||||
|
@ -100,13 +98,11 @@ sub get_sunset_time
|
|||
|
||||
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
|
||||
$Year += 1900;
|
||||
$Month++;
|
||||
|
||||
my $dt = DateTime->new( year => $Year, month => $Month, day => $Day, time_zone => $TIMEZONE, );
|
||||
# Note, localtime returns months 0..11, Datetime->new expects months 1..12.
|
||||
my $dt = DateTime->new( year => $Year, month => $Month+1, day => $Day, time_zone => $TIMEZONE, );
|
||||
my $sunrise = DateTime::Event::Sunrise ->new( longitude => $LONGITUDE, latitude => $LATITUDE, altitude => '-0.833', iteration => '1');
|
||||
|
||||
$Month--;
|
||||
|
||||
my $dt2 = $sunrise->sunset_datetime($dt);
|
||||
|
||||
($sunset_time) = $dt2->datetime =~ /T(.*)\:/;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue