blob: e10cf676125287c9c09d40b506adce7d6c65b85a (
plain)
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
|
# Test: perl6 ch1.p6 2019
use v6.d;
sub MAIN(Int $year = 2019) {
show-weekdays-per-year($year);
}
# Weekdays per year
sub show-weekdays-per-year(Int $year) {
my $current = Date.new($year, 1, 1);
my %months{Int};
my @mon = (
'Jan', 'Feb', 'Mar', 'Apr',
'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec'
);
while ($current.year == $year) {
%months{$current.month}++
if ($current.day-of-week == (1 .. 5).any);
$current++;
}
for %months.keys.sort -> $key {
say @mon[$key - 1] ~ ': ' ~
%months{$key} ~ ' days';
}
}
|