line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
83519
|
use warnings; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: The Netherlands official holidays |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Exporter qw(import); |
8
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw( |
10
|
|
|
|
|
|
|
holidays |
11
|
|
|
|
|
|
|
is_holiday |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use base qw(Date::Holidays::Abstract); |
15
|
1
|
|
|
1
|
|
5
|
use DateTime::Event::Easter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
374
|
|
16
|
1
|
|
|
1
|
|
6886
|
use DateTime; |
|
1
|
|
|
|
|
479427
|
|
|
1
|
|
|
|
|
45
|
|
17
|
1
|
|
|
1
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
702
|
|
18
|
|
|
|
|
|
|
my %FIXED_DATES = ( |
19
|
|
|
|
|
|
|
'newyears' => { |
20
|
|
|
|
|
|
|
m => 1, |
21
|
|
|
|
|
|
|
d => 1, |
22
|
|
|
|
|
|
|
nl => 'Nieuwjaarsdag', |
23
|
|
|
|
|
|
|
en => 'New years day', |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
'wimlex' => { |
26
|
|
|
|
|
|
|
m => 4, |
27
|
|
|
|
|
|
|
d => 27, |
28
|
|
|
|
|
|
|
nl => 'Koningsdag', |
29
|
|
|
|
|
|
|
en => 'Kings day', |
30
|
|
|
|
|
|
|
# change day of week if it falls on a sunday |
31
|
|
|
|
|
|
|
dow => { 7 => -1 }, |
32
|
|
|
|
|
|
|
year_started => 2014, |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
'minna-princess' => { |
35
|
|
|
|
|
|
|
m => 8, |
36
|
|
|
|
|
|
|
d => 31, |
37
|
|
|
|
|
|
|
nl => 'Prinsessedag', |
38
|
|
|
|
|
|
|
en => "Princess's day", |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# change day of week if it falls on a sunday |
41
|
|
|
|
|
|
|
dow => { 7 => 1 }, |
42
|
|
|
|
|
|
|
year_started => 1885, |
43
|
|
|
|
|
|
|
year_ended => 1890, |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
'minna-queen' => { |
46
|
|
|
|
|
|
|
m => 8, |
47
|
|
|
|
|
|
|
d => 31, |
48
|
|
|
|
|
|
|
nl => 'Koninginnedag', |
49
|
|
|
|
|
|
|
en => "Queen's day", |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# change day of week if it falls on a sunday |
52
|
|
|
|
|
|
|
dow => { 7 => 1 }, |
53
|
|
|
|
|
|
|
year_started => 1891, |
54
|
|
|
|
|
|
|
year_ended => 1948, |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
'juliana-beatrix' => { |
57
|
|
|
|
|
|
|
m => 4, |
58
|
|
|
|
|
|
|
d => 30, |
59
|
|
|
|
|
|
|
nl => 'Koninginnedag', |
60
|
|
|
|
|
|
|
en => "Queen's day", |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# change day of week if it falls on a sunday |
63
|
|
|
|
|
|
|
dow => { 7 => 1 }, |
64
|
|
|
|
|
|
|
year_started => 1949, |
65
|
|
|
|
|
|
|
year_ended => 1979, |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
'juliana-beatrix-2' => { |
68
|
|
|
|
|
|
|
m => 4, |
69
|
|
|
|
|
|
|
d => 30, |
70
|
|
|
|
|
|
|
nl => 'Koninginnedag', |
71
|
|
|
|
|
|
|
en => "Queen's day", |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# change day of week if it falls on a sunday |
74
|
|
|
|
|
|
|
dow => { 7 => -1 }, |
75
|
|
|
|
|
|
|
year_started => 1980, |
76
|
|
|
|
|
|
|
year_ended => 2013, |
77
|
|
|
|
|
|
|
}, |
78
|
|
|
|
|
|
|
'liberation' => { |
79
|
|
|
|
|
|
|
m => 5, |
80
|
|
|
|
|
|
|
d => 5, |
81
|
|
|
|
|
|
|
nl => 'Bevrijdingsdag', |
82
|
|
|
|
|
|
|
en => 'Liberation day', |
83
|
|
|
|
|
|
|
interval => 5, # Day off every five years |
84
|
|
|
|
|
|
|
gov => 1, # Government works are having a day off tho |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
'xmas' => { |
87
|
|
|
|
|
|
|
m => 12, |
88
|
|
|
|
|
|
|
d => 25, |
89
|
|
|
|
|
|
|
nl => 'Kerst', |
90
|
|
|
|
|
|
|
en => 'Christmas', |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
'boxing' => { |
93
|
|
|
|
|
|
|
m => 12, |
94
|
|
|
|
|
|
|
d => 26, |
95
|
|
|
|
|
|
|
nl => 'Tweede kerstdag', |
96
|
|
|
|
|
|
|
en => 'Boxing day', |
97
|
|
|
|
|
|
|
}, |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my %EASTER_BASED = ( |
101
|
|
|
|
|
|
|
'goodfri' => { |
102
|
|
|
|
|
|
|
d => -2, |
103
|
|
|
|
|
|
|
nl => 'Goede vrijdag', |
104
|
|
|
|
|
|
|
en => 'Good friday', |
105
|
|
|
|
|
|
|
}, |
106
|
|
|
|
|
|
|
'easter' => { |
107
|
|
|
|
|
|
|
d => 0, |
108
|
|
|
|
|
|
|
nl => 'Pasen', |
109
|
|
|
|
|
|
|
en => 'Easter', |
110
|
|
|
|
|
|
|
}, |
111
|
|
|
|
|
|
|
'easter2' => { |
112
|
|
|
|
|
|
|
d => 1, |
113
|
|
|
|
|
|
|
nl => 'Tweede paasdag', |
114
|
|
|
|
|
|
|
en => 'Second day of easter', |
115
|
|
|
|
|
|
|
}, |
116
|
|
|
|
|
|
|
'ascension' => { |
117
|
|
|
|
|
|
|
d => 40, |
118
|
|
|
|
|
|
|
nl => 'Hemelvaartsdag', |
119
|
|
|
|
|
|
|
en => 'Ascension day', |
120
|
|
|
|
|
|
|
}, |
121
|
|
|
|
|
|
|
'pentecost' => { |
122
|
|
|
|
|
|
|
d => 49, |
123
|
|
|
|
|
|
|
nl => 'Pinksteren', |
124
|
|
|
|
|
|
|
en => 'Pentecost', |
125
|
|
|
|
|
|
|
}, |
126
|
|
|
|
|
|
|
'pentecost-2' => { |
127
|
|
|
|
|
|
|
d => 50, |
128
|
|
|
|
|
|
|
nl => 'Pinksteren', |
129
|
|
|
|
|
|
|
en => 'Pentecost', |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my %cache; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $year = shift; |
136
|
|
|
|
|
|
|
my %args = @_; |
137
|
13
|
|
|
13
|
1
|
1836
|
|
138
|
13
|
|
|
|
|
22
|
$year //= DateTime->now()->year; |
139
|
|
|
|
|
|
|
|
140
|
13
|
|
33
|
|
|
27
|
my $key = $year; |
141
|
|
|
|
|
|
|
if ($args{gov}) { |
142
|
13
|
|
|
|
|
19
|
$key .= 'gov'; |
143
|
13
|
100
|
|
|
|
27
|
} |
144
|
2
|
|
|
|
|
4
|
|
145
|
|
|
|
|
|
|
return $cache{$key} if $cache{$key}; |
146
|
|
|
|
|
|
|
|
147
|
13
|
100
|
|
|
|
29
|
my %h; |
148
|
|
|
|
|
|
|
foreach (keys %FIXED_DATES) { |
149
|
9
|
|
|
|
|
11
|
my $holiday = $FIXED_DATES{$_}; |
150
|
9
|
|
|
|
|
33
|
|
151
|
81
|
|
|
|
|
444
|
if (my $int = $holiday->{interval}) { |
152
|
|
|
|
|
|
|
if ($args{gov} && $holiday->{gov}) { |
153
|
81
|
100
|
|
|
|
123
|
# We should have this |
154
|
9
|
100
|
66
|
|
|
28
|
} |
155
|
|
|
|
|
|
|
else { |
156
|
|
|
|
|
|
|
next if $year % $int != 0; |
157
|
|
|
|
|
|
|
} |
158
|
7
|
100
|
|
|
|
17
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
if (my $start = $holiday->{year_started}) { |
161
|
|
|
|
|
|
|
next if $year < $start; |
162
|
75
|
100
|
|
|
|
117
|
} |
163
|
45
|
100
|
|
|
|
74
|
|
164
|
|
|
|
|
|
|
if (my $end = $holiday->{year_ended}) { |
165
|
|
|
|
|
|
|
next if $year > $end; |
166
|
69
|
100
|
|
|
|
108
|
} |
167
|
34
|
100
|
|
|
|
93
|
|
168
|
|
|
|
|
|
|
my $dt = _to_date($holiday->{d}, $holiday->{m}, $year); |
169
|
|
|
|
|
|
|
|
170
|
39
|
|
|
|
|
65
|
if (my $dow = $holiday->{dow}) { |
171
|
|
|
|
|
|
|
my $cur = $dt->dow(); |
172
|
39
|
100
|
|
|
|
10634
|
foreach (keys %$dow) { |
173
|
9
|
|
|
|
|
19
|
next unless $cur == $_; |
174
|
9
|
|
|
|
|
35
|
$dt->add(days => $dow->{$_}); |
175
|
9
|
100
|
|
|
|
25
|
last; |
176
|
3
|
|
|
|
|
11
|
} |
177
|
3
|
|
|
|
|
2154
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
_to_holidays(\%h, $dt, $holiday); |
180
|
|
|
|
|
|
|
} |
181
|
39
|
|
|
|
|
77
|
|
182
|
|
|
|
|
|
|
my $dt = _to_date(1, 1, $year); |
183
|
|
|
|
|
|
|
foreach (keys %EASTER_BASED) { |
184
|
9
|
|
|
|
|
69
|
my $holiday = $EASTER_BASED{$_}; |
185
|
9
|
|
|
|
|
2286
|
my $easter = DateTime::Event::Easter->new( |
186
|
54
|
|
|
|
|
620
|
easter => 'western', |
187
|
|
|
|
|
|
|
day => $holiday->{d} |
188
|
|
|
|
|
|
|
); |
189
|
|
|
|
|
|
|
my $dt = $easter->following($dt); |
190
|
54
|
|
|
|
|
137
|
_to_holidays(\%h, $dt, $holiday); |
191
|
54
|
|
|
|
|
7364
|
} |
192
|
54
|
|
|
|
|
87708
|
|
193
|
|
|
|
|
|
|
$cache{$key} = \%h; |
194
|
|
|
|
|
|
|
|
195
|
9
|
|
|
|
|
143
|
return \%h; |
196
|
|
|
|
|
|
|
} |
197
|
9
|
|
|
|
|
32
|
|
198
|
|
|
|
|
|
|
my ($cache, $dt, $info) = @_; |
199
|
|
|
|
|
|
|
$cache->{ sprintf("%02i", $dt->day) . sprintf("%02i", $dt->month) } |
200
|
|
|
|
|
|
|
= [map { $info->{$_} } qw(nl en)]; |
201
|
93
|
|
|
93
|
|
161
|
} |
202
|
|
|
|
|
|
|
|
203
|
93
|
|
|
|
|
128
|
my ($day, $month, $year) = @_; |
|
186
|
|
|
|
|
497
|
|
204
|
|
|
|
|
|
|
return DateTime->new( |
205
|
|
|
|
|
|
|
day => $day, |
206
|
|
|
|
|
|
|
month => $month, |
207
|
58
|
|
|
58
|
|
87
|
year => $year, |
208
|
58
|
|
|
|
|
144
|
hour => 0, |
209
|
|
|
|
|
|
|
minute => 0, |
210
|
|
|
|
|
|
|
second => 0, |
211
|
|
|
|
|
|
|
time_zone => 'UTC', |
212
|
|
|
|
|
|
|
); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
my $year = shift; |
216
|
|
|
|
|
|
|
my $month = shift; |
217
|
|
|
|
|
|
|
my $day = shift; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
my $dt = _to_date($day, $month, $year); |
220
|
10
|
|
|
10
|
1
|
654
|
return is_holiday_dt($dt, @_); |
221
|
10
|
|
|
|
|
14
|
} |
222
|
10
|
|
|
|
|
15
|
|
223
|
|
|
|
|
|
|
my $dt = shift; |
224
|
10
|
|
|
|
|
16
|
|
225
|
10
|
|
|
|
|
2671
|
my %args = @_; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my $holidays = holidays($dt->year, @_); |
228
|
|
|
|
|
|
|
my $key = sprintf("%02i", $dt->day) . sprintf("%02i", $dt->month); |
229
|
10
|
|
|
10
|
1
|
12
|
|
230
|
|
|
|
|
|
|
if (exists $holidays->{$key}) { |
231
|
10
|
|
|
|
|
23
|
my $lang = lc(delete $args{lang} // 'nl'); |
232
|
|
|
|
|
|
|
if ($lang eq 'en' || $lang eq 'eng') { |
233
|
10
|
|
|
|
|
19
|
return $holidays->{$key}[1]; |
234
|
10
|
|
|
|
|
22
|
} |
235
|
|
|
|
|
|
|
# default to dutch |
236
|
10
|
100
|
|
|
|
86
|
return $holidays->{$key}[0]; |
237
|
8
|
|
100
|
|
|
31
|
} |
238
|
8
|
100
|
66
|
|
|
30
|
return; |
239
|
1
|
|
|
|
|
6
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
'I always get my sin'; |
242
|
7
|
|
|
|
|
44
|
|
243
|
|
|
|
|
|
|
|
244
|
2
|
|
|
|
|
12
|
=pod |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=encoding UTF-8 |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 NAME |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Date::Holidays::NL - The Netherlands official holidays |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 VERSION |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
version 0.005 |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 SYNOPSIS |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
use Date::Holidays::NL; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
if (my $thing = is_holiday(2020, 5, 5, lang => 'en')) { |
261
|
|
|
|
|
|
|
print "It is $thing!", $/; # prints liberation day |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 DESCRIPTION |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
A L<Date::Holidays> family member from the Netherlands |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 METHODS |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
This module implements the C<is_holiday> and C<holiday> functions from |
271
|
|
|
|
|
|
|
L<Date::Holidays::Abstract>. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head2 is_holiday(yyyy, mm, dd, %additional) |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
is_holiday( |
276
|
|
|
|
|
|
|
'2022', '05', '05', |
277
|
|
|
|
|
|
|
gov => 1, # Important for government institutions |
278
|
|
|
|
|
|
|
lang => 'en' # defaults to nl/nld, alternatively en/eng can be used. |
279
|
|
|
|
|
|
|
); |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head2 is_holiday_dt(dt, %additional) |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
is_holiday( |
284
|
|
|
|
|
|
|
DateTime->new( |
285
|
|
|
|
|
|
|
year => 2022, |
286
|
|
|
|
|
|
|
month => 5, |
287
|
|
|
|
|
|
|
day => 5, |
288
|
|
|
|
|
|
|
time_zone => 'Europe/Amsterdam', |
289
|
|
|
|
|
|
|
), |
290
|
|
|
|
|
|
|
gov => 1, # Important for government institutions |
291
|
|
|
|
|
|
|
lang => 'en' # defaults to nl/nld, alternatively en/eng can be used. |
292
|
|
|
|
|
|
|
); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 holidays(yyyy, gov => 1) |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
holidays('2022', gov => 1); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Similar API to the other functions, returns an hashref for the year. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head1 AUTHOR |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
Wesley Schwengle <waterkip@cpan.org> |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Wesley Schwengle. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
This is free software, licensed under: |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
The (three-clause) BSD License |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=cut |