line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Event::Holiday::US; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21923
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use Carp 'croak'; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
72
|
|
7
|
1
|
|
|
1
|
|
1045
|
use DateTime::Format::ICal; |
|
1
|
|
|
|
|
281113
|
|
|
1
|
|
|
|
|
41
|
|
8
|
1
|
|
|
1
|
|
14
|
use DateTime::Set; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
523
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
{ # Make the hash private |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# How do I do this? |
17
|
|
|
|
|
|
|
#Kwanzaa |
18
|
|
|
|
|
|
|
#December 26 through January 1 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %holiday = ( |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# January |
23
|
|
|
|
|
|
|
'New Years Day' => 'RRULE:FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1', # January 1 |
24
|
|
|
|
|
|
|
'Martin Luther King, Jr Birthday' => 'RRULE:FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=15', # January 15 |
25
|
|
|
|
|
|
|
'Martin Luther King Day' => 'RRULE:FREQ=YEARLY;BYMONTH=1;BYDAY=3mo', # Third Monday in January |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# February |
28
|
|
|
|
|
|
|
'Groundhog Day' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=2', # February 2 |
29
|
|
|
|
|
|
|
'Super Bowl Sunday' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYDAY=1su', # First Sunday in February |
30
|
|
|
|
|
|
|
'Lincolns Birthday' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=12', # February 12 |
31
|
|
|
|
|
|
|
'Valentines Day' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=14', # February 14 |
32
|
|
|
|
|
|
|
'Susan B. Anthony Day' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=15', # February 15 |
33
|
|
|
|
|
|
|
'Washingtons Birthday (observed)' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYDAY=3mo', # Third Monday in February |
34
|
|
|
|
|
|
|
'Washingtons Birthday' => 'RRULE:FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=22', # February 22 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# March |
37
|
|
|
|
|
|
|
'St. Patricks Day' => 'RRULE:FREQ=YEARLY;BYMONTH=3;BYMONTHDAY=17', # March 17 |
38
|
|
|
|
|
|
|
'Cesar Chavez Day' => 'RRULE:FREQ=YEARLY;BYMONTH=3;BYMONTHDAY=31', # March 31 |
39
|
|
|
|
|
|
|
'Sewards Day' => 'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1mo', # Last Monday in March |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# April |
42
|
|
|
|
|
|
|
'Confederate Memorial Day' => 'RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=4mo', # Fourth Monday in April |
43
|
|
|
|
|
|
|
'April Fools Day' => 'RRULE:FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=1', # April 1 |
44
|
|
|
|
|
|
|
'Earth Day' => 'RRULE:FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=22', # April 22 |
45
|
|
|
|
|
|
|
'Emancipation Day' => 'RRULE:FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=16', # April 16 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# May |
48
|
|
|
|
|
|
|
'Primary Election Day' => 'RRULE:FREQ=YEARLY;BYMONTH=5;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8', # First Tuesday after 1st Monday in May |
49
|
|
|
|
|
|
|
'Mothers Day' => 'RRULE:FREQ=YEARLY;BYMONTH=5;BYDAY=2su', # Second Sunday in May |
50
|
|
|
|
|
|
|
'Memorial Day' => 'RRULE:FREQ=YEARLY;BYMONTH=5;BYDAY=-1mo', # Last Monday in May |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# June |
53
|
|
|
|
|
|
|
'Jefferson Davis Day' => 'RRULE:FREQ=YEARLY;BYMONTH=6;BYDAY=1mo', # First Monday in June |
54
|
|
|
|
|
|
|
'Flag Day' => 'RRULE:FREQ=YEARLY;BYMONTH=6;BYMONTHDAY=14', # June 14 |
55
|
|
|
|
|
|
|
'Fathers Day' => 'RRULE:FREQ=YEARLY;BYMONTH=6;BYDAY=3su', # Third Sunday in June |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# July |
58
|
|
|
|
|
|
|
'Independence Day' => 'RRULE:FREQ=YEARLY;BYMONTH=7;BYMONTHDAY=4', # July 4 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# August |
61
|
|
|
|
|
|
|
'Womens Equality Day' => 'RRULE:FREQ=YEARLY;BYMONTH=8;BYMONTHDAY=26', # August 26 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# September |
64
|
|
|
|
|
|
|
'Labor Day' => 'RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=1mo', # First Monday in September |
65
|
|
|
|
|
|
|
'Patriot Day' => 'RRULE:FREQ=YEARLY;BYMONTH=9;BYMONTHDAY=11', # September 11 |
66
|
|
|
|
|
|
|
'Citizenship Day' => 'RRULE:FREQ=YEARLY;BYMONTH=9;BYMONTHDAY=17', # September 17 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# October |
69
|
|
|
|
|
|
|
'Columbus Day' => 'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=2mo', # Second Monday in October |
70
|
|
|
|
|
|
|
'Leif Erikson Day' => 'RRULE:FREQ=YEARLY;BYMONTH=10;BYMONTHDAY=9', # October 9 |
71
|
|
|
|
|
|
|
'Alaska Day' => 'RRULE:FREQ=YEARLY;BYMONTH=10;BYMONTHDAY=18', # October 18 |
72
|
|
|
|
|
|
|
'Halloween' => 'RRULE:FREQ=YEARLY;BYMONTH=10;BYMONTHDAY=31', # October 31 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# November |
75
|
|
|
|
|
|
|
'Election Day' => 'RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8', # First Tuesday after 1st Monday in November |
76
|
|
|
|
|
|
|
'Veterans Day' => 'RRULE:FREQ=YEARLY;BYMONTH=11;BYMONTHDAY=11', # November 11 |
77
|
|
|
|
|
|
|
'Thanksgiving Day' => 'RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=4th', # Fourth Thursday in November |
78
|
|
|
|
|
|
|
'Black Friday' => 'RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=FR;BYMONTHDAY=23,24,25,26,27,28,29', # Friday after Thanksgiving Day |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# December |
81
|
|
|
|
|
|
|
'Pearl Harbor Remembrance Day' => 'RRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=7', # December 7 |
82
|
|
|
|
|
|
|
'Winter Solstice' => 'RRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=21', # December 21 |
83
|
|
|
|
|
|
|
'Christmas Eve' => 'RRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=24', # December 24 |
84
|
|
|
|
|
|
|
'Christmas' => 'RRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=25', # December 25 |
85
|
|
|
|
|
|
|
'New Years Eve' => 'RRULE:FREQ=YEARLY;BYMONTH=12;BYMONTHDAY=31', # December 31 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Aliases |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$holiday{ 'Fourth of July' } = $holiday{ 'Independence Day' }; |
92
|
|
|
|
|
|
|
$holiday{ 'Presidents Day' } = $holiday{ 'Washingtons Birthday (observed)' }; |
93
|
|
|
|
|
|
|
$holiday{ 'Thanksgiving' } = $holiday{ 'Thanksgiving Day' }; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
1
|
50
|
|
1
|
1
|
1814
|
sub known { my @keys = sort keys %holiday; return wantarray ? @keys : \@keys } |
|
1
|
|
|
|
|
33
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub holiday { |
100
|
|
|
|
|
|
|
|
101
|
132
|
|
|
132
|
1
|
156551229
|
my ( $holiday ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
132
|
50
|
|
|
|
671
|
croak "Unknown holiday ($holiday)" |
104
|
|
|
|
|
|
|
unless exists $holiday{ $holiday }; |
105
|
|
|
|
|
|
|
|
106
|
132
|
|
|
|
|
692
|
return DateTime::Format::ICal->parse_recurrence( 'recurrence' => $holiday{ $holiday } ); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub holidays { |
112
|
|
|
|
|
|
|
|
113
|
2
|
|
|
2
|
1
|
21
|
my @holidays = @_; |
114
|
|
|
|
|
|
|
|
115
|
2
|
|
|
|
|
4
|
my %h; |
116
|
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
9
|
$h{ $_ } = holiday( $_ ) for @holidays; |
118
|
|
|
|
|
|
|
|
119
|
2
|
|
|
|
|
2751
|
return \%h; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub holidays_as_set { |
125
|
|
|
|
|
|
|
|
126
|
1
|
|
|
1
|
1
|
9
|
my @holidays = values %{ holidays( @_ ) }; |
|
1
|
|
|
|
|
4
|
|
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
10
|
my $set = shift @holidays; |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
|
|
|
10
|
$set = $set->union( $_ ) for @holidays; |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
8971
|
return $set; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
}; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; # End of DateTime::Event::Holiday::US |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |
142
|
|
|
|
|
|
|
=pod |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 NAME |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
DateTime::Event::Holiday::US |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 VERSION |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
version 0.02 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SYNOPSIS |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# This module handles creating a DateTime::Set::ICal object (see |
155
|
|
|
|
|
|
|
# DateTime::Event::Recurrence) that you can use as a US holiday. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
use DateTime::Event::Holiday::US; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $thanksgiving = DateTime::Event::Holiday::US::holiday( 'Thanksgiving' ); |
160
|
|
|
|
|
|
|
my @holidays = DateTime::Event::Holiday::US::known(); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# $thanksgiving will be a DateTime::Set::ICal object that you can perform |
163
|
|
|
|
|
|
|
# anything you would do with a DateTime::Set object. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# $holidays will be an array of all holiday names DateTime::Event::Holiday::US |
166
|
|
|
|
|
|
|
# knows about. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 NAME |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
DateTime::Event::Holiday::US - US Holiday's as DateTime::Set objects |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 VERSION |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Version 0.02 |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 EXPORT |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Nothing is exported. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 known |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Returns a list of holiday names DateTime::Event::Holiday::US knows about. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
@known = DateTime::Event::Holiday::US::known(); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 holiday |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Returns the requested holiday as a DateTime::Set::ICal object. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
$thanksgiving = DateTime::Event::Holiday::US::holiday( 'Thanksgiving' ); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$thanksgiving will be a DateTime::Set::ICal object that you can perform |
195
|
|
|
|
|
|
|
anything you would do with a DateTime::Set object. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 holidays |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Returns a hash reference of DateTime::Set::ICal objects for each holiday. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
$holidays = DateTime::Event::Holiday::US::holidays( 'Thanksgiving', 'Black Friday' ); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
$holidays is a hash reference where the key is the name of the holiday and the |
204
|
|
|
|
|
|
|
value is the object. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 holidays_as_set |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Returns requested holidays as a single DateTime::Set object; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
$holidays = DateTime::Event::Holiday::US::holidays_as_set( 'Thanksgiving', 'Black Friday' ); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
$holidays would be a DateTime::Set containing sets for both Thanksgiving and Black Friday |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 AUTHOR |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Alan Young, C<< <alansyoungiii at gmail.com> >> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 BUGS |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-datetime-event-holiday-us at rt.cpan.org>, or through |
221
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Event-Holiday-US>. I will be notified, and then you'll |
222
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 SUPPORT |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
perldoc DateTime::Event::Holiday::US |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
You can also look for information at: |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=over 4 |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Event-Holiday-US> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
L<http://annocpan.org/dist/DateTime-Event-Holiday-US> |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item * CPAN Ratings |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/DateTime-Event-Holiday-US> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item * Search CPAN |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/DateTime-Event-Holiday-US/> |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=back |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Copyright 2010 Alan Young. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
259
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
260
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 INSTALLATION |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
See perlmodinstall for information and options on installing Perl modules. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Alan Young <harleypig@gmail.com> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Alan Young. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
277
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=cut |
280
|
|
|
|
|
|
|
|