| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Date::Holidays::DK; |
|
2
|
1
|
|
|
1
|
|
124277
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use base qw(Exporter); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
132
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
545
|
use Date::Simple; |
|
|
1
|
|
|
|
|
10970
|
|
|
|
1
|
|
|
|
|
92
|
|
|
6
|
1
|
|
|
1
|
|
685
|
use Date::Easter; |
|
|
1
|
|
|
|
|
5847
|
|
|
|
1
|
|
|
|
|
122
|
|
|
7
|
1
|
|
|
1
|
|
14
|
use utf8; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
54
|
use vars qw($VERSION @EXPORT); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
866
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.05'; |
|
11
|
|
|
|
|
|
|
@EXPORT = qw(is_dk_holiday dk_holidays); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Fixed-date holidays |
|
14
|
|
|
|
|
|
|
my $FIX = {'0101' => "Nytårsdag", |
|
15
|
|
|
|
|
|
|
'0605' => "Grundlovsdag", |
|
16
|
|
|
|
|
|
|
'1224' => "Juleaftensdag", |
|
17
|
|
|
|
|
|
|
'1225' => "Juledag", |
|
18
|
|
|
|
|
|
|
'1226' => "2. Juledag", |
|
19
|
|
|
|
|
|
|
}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $VAR; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Holidays relative to Easter |
|
24
|
|
|
|
|
|
|
my $VAR_PRE2024 = {-7 => "Palmesøndag", |
|
25
|
|
|
|
|
|
|
-3 => "Skærtorsdag", |
|
26
|
|
|
|
|
|
|
-2 => "Langfredag", |
|
27
|
|
|
|
|
|
|
0 => "Påskedag", |
|
28
|
|
|
|
|
|
|
1 => "2. Påskedag", |
|
29
|
|
|
|
|
|
|
26 => "Store Bededag", |
|
30
|
|
|
|
|
|
|
39 => "Kristi Himmelfartsdag", |
|
31
|
|
|
|
|
|
|
49 => "Pinsedag", |
|
32
|
|
|
|
|
|
|
50 => "2. Pinsedag", |
|
33
|
|
|
|
|
|
|
}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# "Store Bededag" no longer a holiday after 2023 |
|
36
|
|
|
|
|
|
|
my $VAR_POST2023 = {-7 => "Palmesøndag", |
|
37
|
|
|
|
|
|
|
-3 => "Skærtorsdag", |
|
38
|
|
|
|
|
|
|
-2 => "Langfredag", |
|
39
|
|
|
|
|
|
|
0 => "Påskedag", |
|
40
|
|
|
|
|
|
|
1 => "2. Påskedag", |
|
41
|
|
|
|
|
|
|
39 => "Kristi Himmelfartsdag", |
|
42
|
|
|
|
|
|
|
49 => "Pinsedag", |
|
43
|
|
|
|
|
|
|
50 => "2. Pinsedag", |
|
44
|
|
|
|
|
|
|
}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub is_dk_holiday { |
|
47
|
21
|
|
|
21
|
1
|
191572
|
my ($year, $month, $day) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
21
|
100
|
|
|
|
51
|
if ($year >= 2024) { |
|
50
|
1
|
|
|
|
|
5
|
$VAR = $VAR_POST2023; |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
20
|
|
|
|
|
26
|
$VAR = $VAR_PRE2024; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $holiday = $FIX->{sprintf "%02d%02d", $month, $day} || |
|
56
|
21
|
|
100
|
|
|
153
|
$VAR->{Date::Simple->new($year, $month, $day) - |
|
57
|
|
|
|
|
|
|
Date::Simple->new($year, easter($year))} || |
|
58
|
|
|
|
|
|
|
undef; |
|
59
|
|
|
|
|
|
|
|
|
60
|
21
|
|
|
|
|
1164
|
return $holiday; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub dk_holidays { |
|
64
|
2
|
|
|
2
|
1
|
1269
|
my ($year) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# get the fixed dates |
|
67
|
2
|
|
|
|
|
12
|
my $h = {%$FIX}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
2
|
100
|
|
|
|
10
|
if ($year >= 2024) { |
|
70
|
1
|
|
|
|
|
3
|
$VAR = $VAR_POST2023; |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
1
|
|
|
|
|
2
|
$VAR = $VAR_PRE2024; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
2
|
|
|
|
|
8
|
my $easter = Date::Simple->new($year, easter($year)); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# build the relative dates |
|
78
|
2
|
|
|
|
|
104
|
foreach my $diff (keys %$VAR) { |
|
79
|
17
|
|
|
|
|
93
|
my $date = $easter + $diff; |
|
80
|
17
|
|
|
|
|
334
|
$h->{sprintf "%02d%02d", $date->month, $date->day} = $VAR->{$diff}; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
11
|
return $h; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Date::Holidays::DK - Determine Danish public holidays |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use Date::Holidays::DK; |
|
95
|
|
|
|
|
|
|
my ($year, $month, $day) = (localtime)[ 5, 4, 3 ]; |
|
96
|
|
|
|
|
|
|
$year += 1900; |
|
97
|
|
|
|
|
|
|
$month += 1; |
|
98
|
|
|
|
|
|
|
print "Woohoo" if is_dk_holiday( $year, $month, $day ); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $h = dk_holidays($year); |
|
101
|
|
|
|
|
|
|
printf "Dec. 25th is named '%s'\n", $h->{'1225'}; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Determines whether a given date is a Danish public holiday or not. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This module is based on the simple API of Date::Holidays::UK, but |
|
108
|
|
|
|
|
|
|
implements a generalised date mechanism, that will work for all |
|
109
|
|
|
|
|
|
|
years since 1700, when Denmark adopted the Gregorian calendar. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 Functions |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over 4 |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item is_dk_holiday($year, $month, $date) |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns the name of the Holiday that falls on the given day, or undef |
|
118
|
|
|
|
|
|
|
if there is none. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item dk_holidays($year) |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns a hashref of all defined holidays in the year. Keys in the |
|
123
|
|
|
|
|
|
|
hashref are in 'mmdd' format, the values are the names of the |
|
124
|
|
|
|
|
|
|
holidays. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 EXPORTS |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Exports is_dk_holiday() and dk_holidays() by default. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 BUGS |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Please report issues via CPAN RT: |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Holidays-DK |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
or by sending mail to |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
bug-Date-Holidays-DK@rt.cpan.org |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHORS |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Lars Thegler . Originally inspired by |
|
145
|
|
|
|
|
|
|
Date::Holidays::UK by Richard Clamp. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
dk_holidays() concept by Jonas B. Nielsen. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright (c) 2004-2025 Lars Thegler. All rights reserved. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
154
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|