line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Holidays::UK::EnglandAndWales; |
2
|
2
|
|
|
2
|
|
84264
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2084
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; # Updated dates |
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
|
|
|
|
|
|
|
"Substitute Bank Holiday in lieu of 1 Jan"; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$_holidays{ 2004, 4, 9 } = |
75
|
|
|
|
|
|
|
$_holidays{ 2005, 3, 25 } = |
76
|
|
|
|
|
|
|
$_holidays{ 2006, 4, 14 } = |
77
|
|
|
|
|
|
|
$_holidays{ 2007, 4, 6 } = |
78
|
|
|
|
|
|
|
$_holidays{ 2008, 3, 21 } = |
79
|
|
|
|
|
|
|
$_holidays{ 2009, 4, 10 } = |
80
|
|
|
|
|
|
|
$_holidays{ 2010, 4, 2 } = |
81
|
|
|
|
|
|
|
$_holidays{ 2011, 4, 22 } = |
82
|
|
|
|
|
|
|
$_holidays{ 2012, 4, 6 } = |
83
|
|
|
|
|
|
|
$_holidays{ 2013, 3, 29 } = |
84
|
|
|
|
|
|
|
$_holidays{ 2014, 4, 15 } = |
85
|
|
|
|
|
|
|
"Good Friday"; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$_holidays{ 2004, 4, 12 } = |
88
|
|
|
|
|
|
|
$_holidays{ 2005, 3, 28 } = |
89
|
|
|
|
|
|
|
$_holidays{ 2006, 4, 17 } = |
90
|
|
|
|
|
|
|
$_holidays{ 2007, 4, 9 } = |
91
|
|
|
|
|
|
|
$_holidays{ 2008, 3, 24 } = |
92
|
|
|
|
|
|
|
$_holidays{ 2009, 4, 13 } = |
93
|
|
|
|
|
|
|
$_holidays{ 2010, 4, 5 } = |
94
|
|
|
|
|
|
|
$_holidays{ 2011, 4, 25 } = |
95
|
|
|
|
|
|
|
$_holidays{ 2012, 4, 9 } = |
96
|
|
|
|
|
|
|
$_holidays{ 2013, 4, 1 } = |
97
|
|
|
|
|
|
|
$_holidays{ 2014, 4, 21 } = |
98
|
|
|
|
|
|
|
"Easter Monday"; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$_holidays{ 2004, 5, 3 } = |
101
|
|
|
|
|
|
|
$_holidays{ 2005, 5, 2 } = |
102
|
|
|
|
|
|
|
$_holidays{ 2006, 5, 1 } = |
103
|
|
|
|
|
|
|
$_holidays{ 2007, 5, 7 } = |
104
|
|
|
|
|
|
|
$_holidays{ 2008, 5, 5 } = |
105
|
|
|
|
|
|
|
$_holidays{ 2009, 5, 4 } = |
106
|
|
|
|
|
|
|
$_holidays{ 2010, 5, 3 } = |
107
|
|
|
|
|
|
|
$_holidays{ 2011, 5, 2 } = |
108
|
|
|
|
|
|
|
$_holidays{ 2012, 5, 7 } = |
109
|
|
|
|
|
|
|
$_holidays{ 2013, 5, 6 } = |
110
|
|
|
|
|
|
|
$_holidays{ 2014, 5, 5 } = |
111
|
|
|
|
|
|
|
"Early May Bank Holiday"; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$_holidays{ 2004, 5, 31 } = |
114
|
|
|
|
|
|
|
$_holidays{ 2005, 5, 30 } = |
115
|
|
|
|
|
|
|
$_holidays{ 2006, 5, 29 } = |
116
|
|
|
|
|
|
|
$_holidays{ 2007, 5, 28 } = |
117
|
|
|
|
|
|
|
$_holidays{ 2008, 5, 26 } = |
118
|
|
|
|
|
|
|
$_holidays{ 2009, 5, 25 } = |
119
|
|
|
|
|
|
|
$_holidays{ 2010, 5, 31 } = |
120
|
|
|
|
|
|
|
$_holidays{ 2011, 5, 30 } = |
121
|
|
|
|
|
|
|
$_holidays{ 2012, 5, 28 } = |
122
|
|
|
|
|
|
|
$_holidays{ 2013, 5, 27 } = |
123
|
|
|
|
|
|
|
$_holidays{ 2014, 5, 26 } = |
124
|
|
|
|
|
|
|
"Spring Bank Holiday"; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$_holidays{ 2004, 8, 30 } = |
127
|
|
|
|
|
|
|
$_holidays{ 2005, 8, 29 } = |
128
|
|
|
|
|
|
|
$_holidays{ 2006, 8, 28 } = |
129
|
|
|
|
|
|
|
$_holidays{ 2007, 8, 27 } = |
130
|
|
|
|
|
|
|
$_holidays{ 2008, 8, 25 } = |
131
|
|
|
|
|
|
|
$_holidays{ 2009, 8, 31 } = |
132
|
|
|
|
|
|
|
$_holidays{ 2010, 8, 30 } = |
133
|
|
|
|
|
|
|
$_holidays{ 2011, 8, 29 } = |
134
|
|
|
|
|
|
|
$_holidays{ 2012, 8, 27 } = |
135
|
|
|
|
|
|
|
$_holidays{ 2013, 8, 26 } = |
136
|
|
|
|
|
|
|
$_holidays{ 2014, 8, 25 } = |
137
|
|
|
|
|
|
|
"Summer Bank Holiday"; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$_holidays{ 2004, 12, 28 } = |
140
|
|
|
|
|
|
|
$_holidays{ 2005, 12, 27 } = |
141
|
|
|
|
|
|
|
$_holidays{ 2010, 12, 27 } = |
142
|
|
|
|
|
|
|
$_holidays{ 2011, 12, 27 } = |
143
|
|
|
|
|
|
|
"Substitute Bank Holiday in lieu of 25 Dec"; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$_holidays{ 2004, 12, 27 } = |
146
|
|
|
|
|
|
|
$_holidays{ 2009, 12, 28 } = |
147
|
|
|
|
|
|
|
$_holidays{ 2010, 12, 28 } = "Substitute Bank Holiday in lieu of 26 Dec"; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
tie %holidays, 'Date::Holidays::UK::EnglandAndWales'; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub is_uk_holiday { |
153
|
11
|
50
|
33
|
11
|
1
|
3540
|
shift if $_[0] eq __PACKAGE__ or ref $_[0]; |
154
|
|
|
|
|
|
|
|
155
|
11
|
50
|
|
|
|
31
|
my ($year, $month, $day) = $#_ > 0 ? @_ : split/\D+/,$_[0],3; |
156
|
11
|
50
|
|
|
|
34
|
$month =~ s/^0// if $month; |
157
|
11
|
50
|
|
|
|
24
|
$day =~ s/^0// if $day; |
158
|
|
|
|
|
|
|
|
159
|
11
|
50
|
|
|
|
43
|
return $_holidays{ $year, $month, $day } |
160
|
|
|
|
|
|
|
if exists $_holidays{ $year, $month, $day }; |
161
|
|
|
|
|
|
|
|
162
|
11
|
50
|
|
|
|
20
|
if ($month == 12){ |
163
|
11
|
50
|
|
|
|
51
|
return 'Christmas Day' if $day == 25; |
164
|
0
|
0
|
|
|
|
|
return 'Boxing Day' if $day == 26; |
165
|
|
|
|
|
|
|
} |
166
|
0
|
0
|
|
|
|
|
if ($month == 1){ |
167
|
0
|
0
|
|
|
|
|
return 'New Year\'s Day' if $day == 1; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# alias |
172
|
|
|
|
|
|
|
*is_holiday = *is_uk_holiday; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# tie API forwards to legacy API |
175
|
|
|
|
|
|
|
sub FETCH { |
176
|
0
|
|
|
0
|
|
|
return is_uk_holiday( @_ ); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
__END__ |