| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Date::Holidays::ES; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
755818
|
use base 'Date::Holidays::Super'; |
|
|
3
|
|
|
|
|
26
|
|
|
|
3
|
|
|
|
|
2021
|
|
|
4
|
3
|
|
|
3
|
|
1077
|
use warnings; |
|
|
3
|
|
|
|
|
31
|
|
|
|
3
|
|
|
|
|
159
|
|
|
5
|
3
|
|
|
3
|
|
32
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
65
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1763
|
use Date::Easter (); |
|
|
3
|
|
|
|
|
11694
|
|
|
|
3
|
|
|
|
|
93
|
|
|
8
|
3
|
|
|
3
|
|
1734
|
use Time::JulianDay (); |
|
|
3
|
|
|
|
|
15742
|
|
|
|
3
|
|
|
|
|
115
|
|
|
9
|
3
|
|
|
3
|
|
25
|
use Carp qw(croak); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
230
|
|
|
10
|
3
|
|
|
3
|
|
1815
|
use utf8; |
|
|
3
|
|
|
|
|
913
|
|
|
|
3
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION (maintained by dzil) |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
|
15
|
1
|
|
|
1
|
1
|
645
|
my $class = shift; |
|
16
|
1
|
|
|
|
|
4
|
return bless \$class, $class; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub is_holiday { |
|
20
|
3
|
|
|
3
|
1
|
14
|
my ($self, %params) = @_; |
|
21
|
3
|
50
|
|
|
|
12
|
my $year = $params{'year'} or croak 'Missing year argument'; |
|
22
|
3
|
50
|
|
|
|
9
|
my $month = $params{'month'} or croak 'Missing month argument'; |
|
23
|
3
|
50
|
|
|
|
9
|
my $day = $params{'day'} or croak 'Missing day argument'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
9
|
my $holidays = $self->holidays(year => $year); |
|
26
|
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
8
|
my $month_day = sprintf "%02d%02d", $month, $day; |
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
50
|
|
|
|
9
|
if (exists $holidays->{$month_day}) { |
|
30
|
3
|
|
|
|
|
29
|
return $holidays->{$month_day}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
return; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub is_es_holiday { |
|
37
|
3
|
|
|
3
|
1
|
485
|
my $self = shift; |
|
38
|
3
|
|
|
|
|
11
|
return $self->is_holiday(@_); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub holidays { |
|
42
|
5
|
|
|
5
|
1
|
15
|
my ($self, %params) = @_; |
|
43
|
5
|
50
|
|
|
|
14
|
my $year = $params{'year'} or croak 'Missing year argument'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
29
|
my $holidays = { |
|
46
|
|
|
|
|
|
|
'0101' => 'Año Nuevo', |
|
47
|
|
|
|
|
|
|
#'0106' => 'Día de Reyes', |
|
48
|
|
|
|
|
|
|
'0501' => 'Día del Trabajo', |
|
49
|
|
|
|
|
|
|
'1012' => 'Día de la Hispanidad', |
|
50
|
|
|
|
|
|
|
'1101' => 'Día de Todos los Santos', |
|
51
|
|
|
|
|
|
|
'1206' => 'Día de la Constitución', |
|
52
|
|
|
|
|
|
|
'1208' => 'Día de la Inmaculada Concepción', |
|
53
|
|
|
|
|
|
|
'1225' => 'Navidad', |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
16
|
my ($emonth, $eday) = Date::Easter::gregorian_easter($year); |
|
57
|
5
|
|
|
|
|
180
|
my $jd = Time::JulianDay::julian_day($year, $emonth, $eday); |
|
58
|
|
|
|
|
|
|
|
|
59
|
5
|
|
|
|
|
56
|
my (undef, $smonth, $sday) = Time::JulianDay::inverse_julian_day($jd - 2); |
|
60
|
5
|
|
|
|
|
146
|
my $month_day = sprintf "%02d%02d", $smonth, $sday; |
|
61
|
5
|
|
|
|
|
20
|
$holidays->{$month_day} = 'Viernes Santo'; |
|
62
|
|
|
|
|
|
|
|
|
63
|
5
|
|
|
|
|
16
|
return $holidays; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub es_holidays { |
|
67
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
68
|
1
|
|
|
|
|
12
|
return $self->holidays(@_); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub holidays_es { |
|
72
|
1
|
|
|
1
|
1
|
983
|
my ($self, %params) = @_; |
|
73
|
1
|
50
|
|
|
|
6
|
my $year = $params{'year'} or croak 'Missing year argument'; |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
3
|
my $holidays = $self->holidays(year => $year); |
|
76
|
1
|
|
|
|
|
3
|
my %hd = (); |
|
77
|
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
2716
|
require DateTime; |
|
79
|
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
537911
|
for my $month_day (keys %$holidays) { |
|
81
|
8
|
|
|
|
|
2503
|
my ($month, $day) = unpack "A2A2", $month_day; |
|
82
|
8
|
|
|
|
|
27
|
$hd{ $holidays->{$month_day} } = DateTime->new( |
|
83
|
|
|
|
|
|
|
year => $year, |
|
84
|
|
|
|
|
|
|
month => $month, |
|
85
|
|
|
|
|
|
|
day => $day, |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
443
|
return \%hd; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding utf8 |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Date::Holidays::ES - Spanish holidays |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use Date::Holidays; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $dh = Date::Holidays->new( countrycode => 'es' ); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
print "Woohoo" if $dh->is_holiday( |
|
109
|
|
|
|
|
|
|
year => $year, |
|
110
|
|
|
|
|
|
|
month => $month, |
|
111
|
|
|
|
|
|
|
day => $day |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $h = $dh->holidays( year => $year ); |
|
115
|
|
|
|
|
|
|
printf "Jan. 1st is named '%s'\n", $h->{'0101'}; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This module provide the Spanish national holidays. You should use it with the |
|
120
|
|
|
|
|
|
|
Date::Holidays OO wrapper, but you can also use it directly. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The following Spanish holidays have fixed dates: |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1 Jan Año Nuevo |
|
125
|
|
|
|
|
|
|
1 May Día del Trabajo |
|
126
|
|
|
|
|
|
|
12 Oct Día de la Hispanidad |
|
127
|
|
|
|
|
|
|
1 Nov Día de Todos los Santos |
|
128
|
|
|
|
|
|
|
6 Dec Día de la Constitución |
|
129
|
|
|
|
|
|
|
8 Dec Día de la Inmaculada Concepción |
|
130
|
|
|
|
|
|
|
25 Dec Navidad |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The following Spanish holiday hasn't a fixed date: |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Viernes Santo Friday before Pascua / Easter |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 METHODS |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 new |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Create a new Date::Holydays::ES object. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 is_holiday |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
if ( $dh->is_holiday( year => $year, month => $month, day => $day ) ) { |
|
145
|
|
|
|
|
|
|
# it's a holiday |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Arguments: |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
year (four digits) |
|
151
|
|
|
|
|
|
|
month (between 1-12) |
|
152
|
|
|
|
|
|
|
day (between 1-31) |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The return value from is_holiday is either the string with the holiday name or |
|
155
|
|
|
|
|
|
|
an undefined value. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 is_es_holiday |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
A wrapper of the L<is_holiday> method. Not available through |
|
160
|
|
|
|
|
|
|
L<Date::Holidays>. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 holidays |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $yh = $dh->holidays( year => $year ); |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
for (keys %$yh) { |
|
167
|
|
|
|
|
|
|
my ($day, $month) = unpack "A2A2", $_; |
|
168
|
|
|
|
|
|
|
print "$day/$month - $yh->{$_}\n"; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Arguments: |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
year (four digits) |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Returns a hash reference, where the keys are dates represented as |
|
176
|
|
|
|
|
|
|
four digits, the two first representing the month (01-12) and the last two |
|
177
|
|
|
|
|
|
|
representing the day (01-31). |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
The value for a given key is the local name for the holiday. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 es_holidays |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
A wrapper of the L<holidays> function. Not available through |
|
184
|
|
|
|
|
|
|
L<Date::Holidays>. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 holidays_es |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $dh = Date::Holidays::ES->new; |
|
189
|
|
|
|
|
|
|
my $yho = $dh->holidays_es( year => $year ); |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
for my $holiday (sort keys %$yho) { |
|
192
|
|
|
|
|
|
|
my $dt = $yho->{$holiday}; |
|
193
|
|
|
|
|
|
|
my $year = $dt->year; |
|
194
|
|
|
|
|
|
|
my $month = $dt->month; |
|
195
|
|
|
|
|
|
|
my $day = $dt->day; |
|
196
|
|
|
|
|
|
|
print "$holiday is on $day/$month/$year\n"; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Arguments: |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
year (four digits) |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This method is not available through L<Date::Holidays>' interface. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns a hash reference, where the keys are the holidays name and the values |
|
206
|
|
|
|
|
|
|
are L<DateTime> objects. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
L<Date::Holidays>, L<DateTime> |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 AUTHOR |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * jonasbn, E<lt>jonasbn@cpan.orgE<gt>, current maintainer |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * Florian Merges, E<lt>fmerges@cpan.orgE<gt> |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=back |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Copyright since 2007 Florian Merges, All Rights Reserved. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
227
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |