diff options
author | Ben Sima <ben@bsima.me> | 2018-06-13 21:36:56 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2018-06-13 21:36:56 -0700 |
commit | 77c9a177b2b595d4ce25095b58e2388fe33cc97a (patch) | |
tree | 0853d5c92d67538760005b9c4635a90115bd7ba4 /sun |
init
Diffstat (limited to 'sun')
-rwxr-xr-x | sun | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +#!/usr/bin/env perl + +use strict; +use utf8; + +use DateTime; +use DateTime::Event::Sunrise; + + +# Location +my $lat = "33.020833"; +my $lon = "-117.279167"; + + +# Current date +my $now = DateTime->now; +$now->set_time_zone("local"); + +my $fmt = "%H:%M"; + +# Get sunrise and sunset data +my $sun = DateTime::Event::Sunrise->new ( + longitude => $lon, + latitude => $lat, + precise => 1 +); + +print "Sunrise: ", $sun->sunrise_datetime($now)->strftime($fmt); +print "\n"; +print "Sunset: ", $sun->sunset_datetime($now)->strftime($fmt); +print "\n"; + |