summaryrefslogtreecommitdiff
path: root/sun
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
committerBen Sima <ben@bsima.me>2018-06-13 21:36:56 -0700
commit77c9a177b2b595d4ce25095b58e2388fe33cc97a (patch)
tree0853d5c92d67538760005b9c4635a90115bd7ba4 /sun
init
Diffstat (limited to 'sun')
-rwxr-xr-xsun32
1 files changed, 32 insertions, 0 deletions
diff --git a/sun b/sun
new file mode 100755
index 0000000..ada17ba
--- /dev/null
+++ b/sun
@@ -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";
+