line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Holidays::UK; |
2
|
1
|
|
|
1
|
|
935
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
17
|
use base qw(Exporter); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
618
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
6
|
|
|
|
|
|
|
our @EXPORT = qw( is_uk_holiday ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Date::Holidays::UK - Determine UK Public Holidays |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Date::Holidays::UK; |
15
|
|
|
|
|
|
|
my ($year, $month, $day) = (localtime)[ 5, 4, 3 ]; |
16
|
|
|
|
|
|
|
$year += 1900; |
17
|
|
|
|
|
|
|
$month += 1; |
18
|
|
|
|
|
|
|
print "Woohoo" if is_uk_holiday( $year, $month, $day ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Naming modules is a tricky thing, especially when similar modules |
23
|
|
|
|
|
|
|
already exist. The awkwardness can be further excaberated when the |
24
|
|
|
|
|
|
|
similar modules don't have consistent apis. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
In this case we started by contrasting L and |
27
|
|
|
|
|
|
|
L. We've crossed the streams by taking the simple |
28
|
|
|
|
|
|
|
is_*_holiday interface from L, and taken the |
29
|
|
|
|
|
|
|
Date::Holidays:: convention from Date::Holidays::DE. We hope |
30
|
|
|
|
|
|
|
nothing explodes. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SUBROUTINES |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 is_uk_holiday( $year, $month, $day ) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Returns the name of the Holiday that falls on the given day, or undef |
37
|
|
|
|
|
|
|
if there is none. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# XXX either programatically fill these, or just do the monkey work |
42
|
|
|
|
|
|
|
# OOK! |
43
|
|
|
|
|
|
|
our %holidays; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$holidays{ 2004, 1, 1 } = |
46
|
|
|
|
|
|
|
$holidays{ 2005, 1, 3 } = |
47
|
|
|
|
|
|
|
$holidays{ 2006, 1, 2 } = |
48
|
|
|
|
|
|
|
$holidays{ 2007, 1, 1 } = "New Year's Day"; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$holidays{ 2004, 4, 9 } = |
51
|
|
|
|
|
|
|
$holidays{ 2005, 3, 25 } = |
52
|
|
|
|
|
|
|
$holidays{ 2006, 4, 14 } = |
53
|
|
|
|
|
|
|
$holidays{ 2007, 4, 6 } = "Good Friday"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$holidays{ 2004, 4, 12 } = |
56
|
|
|
|
|
|
|
$holidays{ 2005, 3, 28 } = |
57
|
|
|
|
|
|
|
$holidays{ 2006, 4, 17 } = |
58
|
|
|
|
|
|
|
$holidays{ 2007, 4, 9 } = "Easter Monday"; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$holidays{ 2004, 5, 3 } = |
61
|
|
|
|
|
|
|
$holidays{ 2005, 5, 2 } = |
62
|
|
|
|
|
|
|
$holidays{ 2006, 5, 1 } = |
63
|
|
|
|
|
|
|
$holidays{ 2007, 5, 7 } = "Early May Bank Holiday"; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$holidays{ 2004, 5, 31 } = |
66
|
|
|
|
|
|
|
$holidays{ 2005, 5, 30 } = |
67
|
|
|
|
|
|
|
$holidays{ 2006, 5, 29 } = |
68
|
|
|
|
|
|
|
$holidays{ 2007, 5, 28 } = "Spring Bank Holiday"; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$holidays{ 2004, 8, 30 } = |
71
|
|
|
|
|
|
|
$holidays{ 2005, 8, 29 } = |
72
|
|
|
|
|
|
|
$holidays{ 2006, 8, 28 } = |
73
|
|
|
|
|
|
|
$holidays{ 2007, 8, 27 } = "Summer Bank Holiday"; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$holidays{ 2004, 12, 25 } = |
76
|
|
|
|
|
|
|
$holidays{ 2005, 12, 25 } = |
77
|
|
|
|
|
|
|
$holidays{ 2006, 12, 25 } = |
78
|
|
|
|
|
|
|
$holidays{ 2007, 12, 25 } = "Christmas Day"; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$holidays{ 2004, 12, 26 } = |
81
|
|
|
|
|
|
|
$holidays{ 2005, 12, 26 } = |
82
|
|
|
|
|
|
|
$holidays{ 2006, 12, 26 } = |
83
|
|
|
|
|
|
|
$holidays{ 2007, 12, 26 } = "Boxing Day"; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$holidays{ 2004, 12, 27 } = "Substitute Bank Holiday in lieu of 26th"; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$holidays{ 2004, 12, 28 } = |
88
|
|
|
|
|
|
|
$holidays{ 2005, 12, 27 } = "Substitute Bank Holiday in lieu of 25th"; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub is_uk_holiday { |
91
|
2
|
|
|
2
|
1
|
864
|
my ($year, $month, $day) = @_; |
92
|
2
|
|
|
|
|
14
|
return $holidays{ $year, $month, $day }; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
__END__ |