-
Notifications
You must be signed in to change notification settings - Fork 319
/
ch-2.pl
51 lines (41 loc) · 1.51 KB
/
ch-2.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
## Please see file perltidy.ERR
#!/usr/bin/perl
#===============================================================================
#
# FILE: ch-2.pl
#
# USAGE: ./ch-2.pl
#
# DESCRIPTION: Perl weekly challenge 37 task 2
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: YOUR NAME (),
# ORGANIZATION:
# VERSION: 1.0
# CREATED: 12/06/2019 04:49:02 PM
# REVISION: ---
#===============================================================================
use strict;
use warnings;
use feature qw/say/;
use DateTime::Event::Sunrise;
my $sun_London = DateTime::Event::Sunrise->new( longitude => -0.118092, latitude => +51.509865 );
my $diff;
for my $day ( 1 .. 30 ) {
# there is no 31.11...
my $dt_nov = DateTime->new(year => 2019,
month => 11,
day => $day,
time_zone => 'Europe/London');
my $dt_dec = DateTime->new(year => 2019,
month => 12,
day => $day,
time_zone => 'Europe/London');
my $daylight_nov = $sun_London->sunset_datetime ($dt_nov)->epoch - $sun_London->sunrise_datetime($dt_nov)->epoch;
my $daylight_dec = $sun_London->sunset_datetime ($dt_dec)->epoch - $sun_London->sunrise_datetime($dt_dec)->epoch;
$diff += ($daylight_dec-$daylight_nov)/3600;
}
say "$diff hours";