line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Holidays::SK; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
223170
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1173
|
use Date::Simple; |
|
1
|
|
|
|
|
19026
|
|
|
1
|
|
|
|
|
36
|
|
9
|
1
|
|
|
1
|
|
797
|
use Date::Easter; |
|
1
|
|
|
|
|
11536
|
|
|
1
|
|
|
|
|
84
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
15
|
use Exporter qw(import); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
642
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(is_sk_holiday sk_holidays); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Fixed-date holidays {'MMDD' => 'NAME'} |
15
|
|
|
|
|
|
|
my $FIX = { |
16
|
|
|
|
|
|
|
'0101' => 'Deň vzniku Slovenskej republiky', |
17
|
|
|
|
|
|
|
'0106' => 'Zjavenie Pána (Traja králi)', |
18
|
|
|
|
|
|
|
'0501' => 'Sviatok práce', |
19
|
|
|
|
|
|
|
'0508' => 'Deň víťazstva nad fašizmom', |
20
|
|
|
|
|
|
|
'0705' => 'Sviatok svätého Cyrila a Metoda', |
21
|
|
|
|
|
|
|
'0829' => 'Výročie SNP', |
22
|
|
|
|
|
|
|
'0901' => 'Deň Ústavy Slovenskej republiky', |
23
|
|
|
|
|
|
|
'0915' => 'Sedembolestná Panna Mária', |
24
|
|
|
|
|
|
|
'1101' => 'Sviatok všetkých svätých', |
25
|
|
|
|
|
|
|
'1117' => 'Deň boja za slobodu a demokraciu', |
26
|
|
|
|
|
|
|
'1224' => 'Štedrý deň', |
27
|
|
|
|
|
|
|
'1225' => 'Prvý sviatok vianočný', |
28
|
|
|
|
|
|
|
'1226' => 'Druhý sviatok vianočný', |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# The only variable-date holiday is Easter Monday and Easter Friday -- we deal with that separately |
32
|
|
|
|
|
|
|
my $EF = 'Veľkonočný piatok'; |
33
|
|
|
|
|
|
|
my $EM = 'Veľkonočný pondelok'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub is_sk_holiday { |
36
|
4
|
|
|
4
|
1
|
204
|
my ($year, $month, $day) = @_; |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
19
|
my $k = sprintf "%02d%02d", $month, $day; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# for fixed dates |
41
|
4
|
100
|
|
|
|
20
|
return $FIX->{$k} |
42
|
|
|
|
|
|
|
if exists $FIX->{$k}; |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
19
|
my $diff = Date::Simple->new($year, $month, $day) - Date::Simple->new($year, easter($year)); |
45
|
|
|
|
|
|
|
# Easter Sunday +1 -> Easter Monday. |
46
|
3
|
100
|
|
|
|
7017
|
return $EM if ( $diff == 1 ); |
47
|
|
|
|
|
|
|
# Easter Sunday -2 -> Easter Friday. |
48
|
2
|
100
|
|
|
|
35
|
return $EF if ( $diff == -2 ); |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
6
|
return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub sk_holidays { |
54
|
|
|
|
|
|
|
|
55
|
6
|
|
|
6
|
1
|
2624
|
my ($year, $month, $day) = @_; |
56
|
|
|
|
|
|
|
|
57
|
6
|
|
|
|
|
23
|
my $easter = Date::Simple->new($year, easter($year)); |
58
|
|
|
|
|
|
|
# Easter Monday is the day after Easter |
59
|
6
|
|
|
|
|
260
|
my $em = $easter + 1; |
60
|
|
|
|
|
|
|
# Easter Friday is 2 days before Easter |
61
|
6
|
|
|
|
|
243
|
my $ef = $easter - 2; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Easter Key ($ek) is a string in the form 'MMDD' |
64
|
6
|
|
|
|
|
149
|
my $emk = sprintf "%02d%02d", $em->month, $em->day; |
65
|
6
|
|
|
|
|
26
|
my $efk = sprintf "%02d%02d", $ef->month, $ef->day; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# $h is a reference to a hash containing the results |
68
|
6
|
|
|
|
|
10
|
my $h; |
69
|
|
|
|
|
|
|
|
70
|
6
|
100
|
|
|
|
23
|
if ( ! $month ) { |
|
|
100
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#print "DEBUG: only year given\n"; |
73
|
1
|
|
|
|
|
29
|
$h = {%$FIX}; |
74
|
1
|
|
|
|
|
5
|
$h->{$emk} = $EM; |
75
|
1
|
|
|
|
|
3
|
$h->{$efk} = $EF; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} elsif ( ! $day ) { |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#print "DEBUG: only year and month given\n"; |
80
|
3
|
|
|
|
|
10
|
my $m = sprintf "%02d", $month; |
81
|
3
|
|
|
|
|
15
|
foreach my $k (keys %$FIX) { |
82
|
39
|
100
|
|
|
|
258
|
$h->{$k} = $FIX->{$k} if $k =~ m/\A$m/; |
83
|
|
|
|
|
|
|
} |
84
|
3
|
100
|
|
|
|
104
|
$h->{$emk} = $EM if $emk =~ m/\A$m/; |
85
|
3
|
100
|
|
|
|
33
|
$h->{$efk} = $EF if $efk =~ m/\A$m/; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} else { |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#print "DEBUG: year, month, and day given\n"; |
90
|
2
|
|
|
|
|
10
|
my $k = sprintf "%02d%02d", $month, $day; |
91
|
2
|
50
|
|
|
|
12
|
$h->{$k} = $FIX->{$k} if exists $FIX->{$k}; |
92
|
2
|
50
|
|
|
|
9
|
$h->{$emk} = $EM if $emk == $k; |
93
|
2
|
100
|
|
|
|
12
|
$h->{$efk} = $EF if $efk == $k; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
6
|
|
|
|
|
29
|
return $h; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |