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