line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Holidays::UK::EnglandAndWales; |
2
|
2
|
|
|
2
|
|
36910
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2353
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.04'; # Colin Hart |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
require Tie::Hash ; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw( Exporter Tie::StdHash ); |
11
|
|
|
|
|
|
|
our @EXPORT = qw( is_uk_holiday ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Date::Holidays::UK::EnglandAndWales - Public Holidays in England and Wales |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Date::Holidays::UK::EnglandAndWales; |
20
|
|
|
|
|
|
|
my ($year, $month, $day) = (localtime)[ 5, 4, 3 ]; |
21
|
|
|
|
|
|
|
$year += 1900; |
22
|
|
|
|
|
|
|
$month += 1; |
23
|
|
|
|
|
|
|
warn "Holiday" if is_uk_holiday( $year, $month, $day ); |
24
|
|
|
|
|
|
|
warn "Holiday" if Date::Holidays::UK::EnglandAndWales->is_holiday( $year, $month, $day ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
These bank and public holidays are holidays in England and Wales, |
29
|
|
|
|
|
|
|
and not necessarily for Scotland and Northern Ireland. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 MODULE HISTORY |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This module is based on L |
34
|
|
|
|
|
|
|
by Richard Clamp, Amelie Guyot, Jerome Parfant, which did not contain |
35
|
|
|
|
|
|
|
the dates needed by my clients. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
As Msrs Clamp et al note in the L, |
38
|
|
|
|
|
|
|
Naming modules is a tricky thing: I've named this C because |
39
|
|
|
|
|
|
|
the C module cannot include holidays for Northern Ireland and Scotland, |
40
|
|
|
|
|
|
|
and maintain its API, since the dates vary across the UK for events of the same name. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 USE |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 is_uk_holiday( $year, $month, $day ) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head3 is_holiday( $year, $month, $day ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head3 Date::Holidays::UK::EnglandAndWales->is_holiday( $year, $month, $day ) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
May be called as class method or subroutine. |
51
|
|
|
|
|
|
|
Returns the name of the Holiday that falls on the given day, or undef |
52
|
|
|
|
|
|
|
if there is none. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Year must be four-digit. Strips any leading zeros from month and day. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Can be included or imported to a class as an object method, since the first |
57
|
|
|
|
|
|
|
argument supplied is discarded if an reference. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 EXPORTS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
C is exported by default, but this is deprecated and will |
62
|
|
|
|
|
|
|
be removed in a future version. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
our (%holidays, %_holidays); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
$_holidays{ 2005, 1, 3 } = |
69
|
|
|
|
|
|
|
$_holidays{ 2006, 1, 2 } = |
70
|
|
|
|
|
|
|
$_holidays{ 2011, 1, 3 } = |
71
|
|
|
|
|
|
|
$_holidays{ 2012, 1, 2 } = |
72
|
|
|
|
|
|
|
$_holidays{ 2017, 1, 2 } = |
73
|
|
|
|
|
|
|
$_holidays{ 2022, 1, 3 } = |
74
|
|
|
|
|
|
|
$_holidays{ 2023, 1, 2 } = |
75
|
|
|
|
|
|
|
"Substitute Bank Holiday in lieu of 1 Jan"; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$_holidays{ 2004, 4, 9 } = |
78
|
|
|
|
|
|
|
$_holidays{ 2005, 3, 25 } = |
79
|
|
|
|
|
|
|
$_holidays{ 2006, 4, 14 } = |
80
|
|
|
|
|
|
|
$_holidays{ 2007, 4, 6 } = |
81
|
|
|
|
|
|
|
$_holidays{ 2008, 3, 21 } = |
82
|
|
|
|
|
|
|
$_holidays{ 2009, 4, 10 } = |
83
|
|
|
|
|
|
|
$_holidays{ 2010, 4, 2 } = |
84
|
|
|
|
|
|
|
$_holidays{ 2011, 4, 22 } = |
85
|
|
|
|
|
|
|
$_holidays{ 2012, 4, 6 } = |
86
|
|
|
|
|
|
|
$_holidays{ 2013, 3, 29 } = |
87
|
|
|
|
|
|
|
$_holidays{ 2014, 4, 15 } = |
88
|
|
|
|
|
|
|
$_holidays{ 2015, 4, 3 } = |
89
|
|
|
|
|
|
|
$_holidays{ 2016, 3, 25 } = |
90
|
|
|
|
|
|
|
$_holidays{ 2017, 4, 14 } = |
91
|
|
|
|
|
|
|
$_holidays{ 2018, 3, 30 } = |
92
|
|
|
|
|
|
|
$_holidays{ 2019, 4, 19 } = |
93
|
|
|
|
|
|
|
$_holidays{ 2020, 4, 10 } = |
94
|
|
|
|
|
|
|
$_holidays{ 2021, 4, 2 } = |
95
|
|
|
|
|
|
|
$_holidays{ 2022, 4, 15 } = |
96
|
|
|
|
|
|
|
$_holidays{ 2023, 4, 7 } = |
97
|
|
|
|
|
|
|
$_holidays{ 2024, 3, 29 } = |
98
|
|
|
|
|
|
|
"Good Friday"; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$_holidays{ 2004, 4, 12 } = |
101
|
|
|
|
|
|
|
$_holidays{ 2005, 3, 28 } = |
102
|
|
|
|
|
|
|
$_holidays{ 2006, 4, 17 } = |
103
|
|
|
|
|
|
|
$_holidays{ 2007, 4, 9 } = |
104
|
|
|
|
|
|
|
$_holidays{ 2008, 3, 24 } = |
105
|
|
|
|
|
|
|
$_holidays{ 2009, 4, 13 } = |
106
|
|
|
|
|
|
|
$_holidays{ 2010, 4, 5 } = |
107
|
|
|
|
|
|
|
$_holidays{ 2011, 4, 25 } = |
108
|
|
|
|
|
|
|
$_holidays{ 2012, 4, 9 } = |
109
|
|
|
|
|
|
|
$_holidays{ 2013, 4, 1 } = |
110
|
|
|
|
|
|
|
$_holidays{ 2014, 4, 21 } = |
111
|
|
|
|
|
|
|
$_holidays{ 2015, 4, 6 } = |
112
|
|
|
|
|
|
|
$_holidays{ 2016, 3, 28 } = |
113
|
|
|
|
|
|
|
$_holidays{ 2017, 4, 17 } = |
114
|
|
|
|
|
|
|
$_holidays{ 2018, 4, 2 } = |
115
|
|
|
|
|
|
|
$_holidays{ 2019, 4, 22 } = |
116
|
|
|
|
|
|
|
$_holidays{ 2020, 4, 13 } = |
117
|
|
|
|
|
|
|
$_holidays{ 2021, 4, 5 } = |
118
|
|
|
|
|
|
|
$_holidays{ 2022, 4, 18 } = |
119
|
|
|
|
|
|
|
$_holidays{ 2023, 4, 10 } = |
120
|
|
|
|
|
|
|
$_holidays{ 2024, 4, 1 } = |
121
|
|
|
|
|
|
|
"Easter Monday"; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$_holidays{ 2004, 5, 3 } = |
124
|
|
|
|
|
|
|
$_holidays{ 2005, 5, 2 } = |
125
|
|
|
|
|
|
|
$_holidays{ 2006, 5, 1 } = |
126
|
|
|
|
|
|
|
$_holidays{ 2007, 5, 7 } = |
127
|
|
|
|
|
|
|
$_holidays{ 2008, 5, 5 } = |
128
|
|
|
|
|
|
|
$_holidays{ 2009, 5, 4 } = |
129
|
|
|
|
|
|
|
$_holidays{ 2010, 5, 3 } = |
130
|
|
|
|
|
|
|
$_holidays{ 2011, 5, 2 } = |
131
|
|
|
|
|
|
|
$_holidays{ 2012, 5, 7 } = |
132
|
|
|
|
|
|
|
$_holidays{ 2013, 5, 6 } = |
133
|
|
|
|
|
|
|
$_holidays{ 2014, 5, 5 } = |
134
|
|
|
|
|
|
|
$_holidays{ 2015, 5, 4 } = |
135
|
|
|
|
|
|
|
$_holidays{ 2016, 5, 2 } = |
136
|
|
|
|
|
|
|
$_holidays{ 2017, 5, 1 } = |
137
|
|
|
|
|
|
|
$_holidays{ 2018, 5, 7 } = |
138
|
|
|
|
|
|
|
$_holidays{ 2019, 5, 6 } = |
139
|
|
|
|
|
|
|
$_holidays{ 2020, 5, 4 } = |
140
|
|
|
|
|
|
|
$_holidays{ 2021, 5, 3 } = |
141
|
|
|
|
|
|
|
$_holidays{ 2022, 5, 2 } = |
142
|
|
|
|
|
|
|
$_holidays{ 2023, 5, 1 } = |
143
|
|
|
|
|
|
|
$_holidays{ 2024, 5, 6 } = |
144
|
|
|
|
|
|
|
"Early May Bank Holiday"; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$_holidays{ 2004, 5, 31 } = |
147
|
|
|
|
|
|
|
$_holidays{ 2005, 5, 30 } = |
148
|
|
|
|
|
|
|
$_holidays{ 2006, 5, 29 } = |
149
|
|
|
|
|
|
|
$_holidays{ 2007, 5, 28 } = |
150
|
|
|
|
|
|
|
$_holidays{ 2008, 5, 26 } = |
151
|
|
|
|
|
|
|
$_holidays{ 2009, 5, 25 } = |
152
|
|
|
|
|
|
|
$_holidays{ 2010, 5, 31 } = |
153
|
|
|
|
|
|
|
$_holidays{ 2011, 5, 30 } = |
154
|
|
|
|
|
|
|
$_holidays{ 2012, 5, 28 } = |
155
|
|
|
|
|
|
|
$_holidays{ 2013, 5, 27 } = |
156
|
|
|
|
|
|
|
$_holidays{ 2014, 5, 26 } = |
157
|
|
|
|
|
|
|
$_holidays{ 2015, 5, 25 } = |
158
|
|
|
|
|
|
|
$_holidays{ 2016, 5, 30 } = |
159
|
|
|
|
|
|
|
$_holidays{ 2017, 5, 29 } = |
160
|
|
|
|
|
|
|
$_holidays{ 2018, 5, 28 } = |
161
|
|
|
|
|
|
|
$_holidays{ 2019, 5, 27 } = |
162
|
|
|
|
|
|
|
$_holidays{ 2020, 5, 25 } = |
163
|
|
|
|
|
|
|
$_holidays{ 2021, 5, 31 } = |
164
|
|
|
|
|
|
|
$_holidays{ 2022, 5, 30 } = |
165
|
|
|
|
|
|
|
$_holidays{ 2023, 5, 29 } = |
166
|
|
|
|
|
|
|
$_holidays{ 2024, 5, 27 } = |
167
|
|
|
|
|
|
|
"Spring Bank Holiday"; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$_holidays{ 2004, 8, 30 } = |
170
|
|
|
|
|
|
|
$_holidays{ 2005, 8, 29 } = |
171
|
|
|
|
|
|
|
$_holidays{ 2006, 8, 28 } = |
172
|
|
|
|
|
|
|
$_holidays{ 2007, 8, 27 } = |
173
|
|
|
|
|
|
|
$_holidays{ 2008, 8, 25 } = |
174
|
|
|
|
|
|
|
$_holidays{ 2009, 8, 31 } = |
175
|
|
|
|
|
|
|
$_holidays{ 2010, 8, 30 } = |
176
|
|
|
|
|
|
|
$_holidays{ 2011, 8, 29 } = |
177
|
|
|
|
|
|
|
$_holidays{ 2012, 8, 27 } = |
178
|
|
|
|
|
|
|
$_holidays{ 2013, 8, 26 } = |
179
|
|
|
|
|
|
|
$_holidays{ 2014, 8, 25 } = |
180
|
|
|
|
|
|
|
$_holidays{ 2015, 8, 31 } = |
181
|
|
|
|
|
|
|
$_holidays{ 2016, 8, 29 } = |
182
|
|
|
|
|
|
|
$_holidays{ 2017, 8, 28 } = |
183
|
|
|
|
|
|
|
$_holidays{ 2018, 8, 27 } = |
184
|
|
|
|
|
|
|
$_holidays{ 2019, 8, 26 } = |
185
|
|
|
|
|
|
|
$_holidays{ 2020, 8, 31 } = |
186
|
|
|
|
|
|
|
$_holidays{ 2021, 8, 30 } = |
187
|
|
|
|
|
|
|
$_holidays{ 2022, 8, 29 } = |
188
|
|
|
|
|
|
|
$_holidays{ 2023, 8, 28 } = |
189
|
|
|
|
|
|
|
$_holidays{ 2024, 8, 26 } = |
190
|
|
|
|
|
|
|
"Summer Bank Holiday"; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
$_holidays{ 2004, 12, 28 } = |
193
|
|
|
|
|
|
|
$_holidays{ 2005, 12, 27 } = |
194
|
|
|
|
|
|
|
$_holidays{ 2010, 12, 27 } = |
195
|
|
|
|
|
|
|
$_holidays{ 2011, 12, 27 } = |
196
|
|
|
|
|
|
|
$_holidays{ 2016, 12, 27 } = |
197
|
|
|
|
|
|
|
$_holidays{ 2021, 12, 27 } = |
198
|
|
|
|
|
|
|
$_holidays{ 2022, 12, 27 } = |
199
|
|
|
|
|
|
|
"Substitute Bank Holiday in lieu of 25 Dec"; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
$_holidays{ 2004, 12, 27 } = |
202
|
|
|
|
|
|
|
$_holidays{ 2009, 12, 28 } = |
203
|
|
|
|
|
|
|
$_holidays{ 2010, 12, 28 } = |
204
|
|
|
|
|
|
|
$_holidays{ 2015, 12, 28 } = |
205
|
|
|
|
|
|
|
$_holidays{ 2021, 12, 28 } = |
206
|
|
|
|
|
|
|
"Substitute Bank Holiday in lieu of 26 Dec"; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
tie %holidays, 'Date::Holidays::UK::EnglandAndWales'; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
sub is_uk_holiday { |
212
|
11
|
50
|
33
|
11
|
1
|
2484
|
shift if $_[0] eq __PACKAGE__ or ref $_[0]; |
213
|
|
|
|
|
|
|
|
214
|
11
|
50
|
|
|
|
24
|
my ($year, $month, $day) = $#_ > 0 ? @_ : split/\D+/,$_[0],3; |
215
|
11
|
50
|
|
|
|
25
|
$month =~ s/^0// if $month; |
216
|
11
|
50
|
|
|
|
16
|
$day =~ s/^0// if $day; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
return $_holidays{ $year, $month, $day } |
219
|
11
|
50
|
|
|
|
28
|
if exists $_holidays{ $year, $month, $day }; |
220
|
|
|
|
|
|
|
|
221
|
11
|
50
|
|
|
|
17
|
if ($month == 12){ |
222
|
11
|
50
|
|
|
|
33
|
return 'Christmas Day' if $day == 25; |
223
|
0
|
0
|
|
|
|
|
return 'Boxing Day' if $day == 26; |
224
|
|
|
|
|
|
|
} |
225
|
0
|
0
|
|
|
|
|
if ($month == 1){ |
226
|
0
|
0
|
|
|
|
|
return 'New Year\'s Day' if $day == 1; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# alias |
231
|
|
|
|
|
|
|
*is_holiday = *is_uk_holiday; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# tie API forwards to legacy API |
234
|
|
|
|
|
|
|
sub FETCH { |
235
|
0
|
|
|
0
|
|
|
return is_uk_holiday( @_ ); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
1; |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
__END__ |