File Coverage

blib/lib/Date/Holidays/CA_ES.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Date::Holidays::CA_ES;
2             $Date::Holidays::CA_ES::VERSION = '0.04';
3 2     2   2405908 use strict;
  2         5  
  2         60  
4 2     2   12 use warnings;
  2         5  
  2         62  
5              
6 2     2   1023 use DateTime;
  2         520359  
  2         73  
7              
8 2     2   25 use base 'Date::Holidays::ES';
  2         5  
  2         1002  
9              
10             sub holidays {
11 13     13 1 11310 my ($self, %params) = @_;
12              
13 13         45 my $es_h = $self->SUPER::holidays(%params);
14 13         967 my $ct_h = {
15             '0624' => 'Sant Joan',
16             '0911' => 'Diada Nacional',
17             '1226' => 'Sant Esteve',
18             '0106' => 'Reis',
19             };
20              
21 13         88 my %reverse = reverse %$es_h;
22 13         27 my $v_santo = $reverse{'Viernes Santo'};
23              
24             # 'Pasqua Florida' is always 3 days after 'Viernes Santo'
25             my $p_florida = DateTime->new(
26             year => $params{year},
27 13         68 month => substr($v_santo, 0, 2),
28             day => substr($v_santo, 2, 2),
29             )->add( days => 3 );
30 13         17625 my (undef, $month, $day) = split '-', $p_florida->ymd();
31 13         277 $ct_h->{"$month$day"} = 'Pasqua Florida';
32              
33 13         95 my %merge = ( %$es_h, %$ct_h );
34 13         114 return \%merge;
35             }
36              
37             1;
38              
39             __END__
40              
41             =head1 NAME
42              
43             Date::Holidays::CA_ES - Catalan holidays
44              
45             =head1 SYNOPSIS
46              
47             use Date::Holidays;
48              
49             my $dh = Date::Holidays->new( countrycode => 'es' );
50             $dh->is_holiday(year => 2007, month => 4, day => 9 , region => 'ca')
51              
52             =head1 DESCRIPTION
53              
54             This module provide the official holidays for Catalonia, an Autonomous
55             Community of Spain. It makes use of Date::Holidays::ES as parent class, since
56             the catalan holidays are the spanish ones plus some more.
57              
58             The following Catalan holidays have fixed dates (remember to take a look to the
59             spanish ones as well!)
60              
61             6 Jan Reis
62             24 Jun Sant Joan
63             11 Sep Diada Nacional
64             26 Dec Sant Esteve
65              
66             The following Catalan holiday hasn't a fixed date:
67              
68             Pasqua Florida Three days after the spanish holiday "Viernes Santo"
69              
70             =head1 METHODS
71              
72             The methods are identical to Date::Holidays::ES ones, except those with the
73             "es" country code in them.
74              
75             =head2 holidays
76              
77             This is the only implemented method, adding the catalan holidays to the days
78             provided by Date::Holidays::ES
79              
80             =head1 SEE ALSO
81              
82             L<Date::Holidays::ES>,
83              
84             =head1 AUTHOR
85              
86             Miquel Ruiz, E<lt>mruiz@cpan.orgE<gt>
87              
88             =head1 COPYRIGHT & LICENSE
89              
90             Copyright 2020 Miquel Ruiz.
91              
92             This program is free software; you can redistribute it and/or modify
93             it under the same terms as Perl itself.
94              
95             =cut
96