File Coverage

lib/Date/Holidays/Adapter/CZ.pm
Criterion Covered Total %
statement 14 33 42.4
branch 0 4 0.0
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 21 46 45.6


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   429 use warnings;
  1         2  
  1         26  
4 1     1   5  
  1         2  
  1         24  
5             use base 'Date::Holidays::Adapter';
6 1     1   5  
  1         2  
  1         60  
7             use vars qw($VERSION);
8 1     1   5  
  1         1  
  1         391  
9             $VERSION = '1.33';
10              
11             my $format = '%#:%m%d';
12              
13             # Lifted from Date::Holidays::CZ example: svatky.plx
14             # Ref: https://metacpan.org/source/SMITHFARM/Date-Holidays-CZ-0.13/example/svatky.plx
15             my %holiday_names = (
16             'obss' => 'Restoration Day of the Independent Czech State',
17             'veln' => 'Easter Sunday',
18             'velp' => 'Easter Monday',
19             'svpr' => 'Labor Day',
20             'dvit' => 'Liberation Day',
21             'cyme' => 'Saints Cyril and Methodius Day',
22             'mhus' => 'Jan Hus Day',
23             'wenc' => 'Feast of St. Wenceslas (Czech Statehood Day)',
24             'vzcs' => 'Independent Czechoslovak State Day',
25             'bojs' => 'Struggle for Freedom and Democracy Day',
26             'sted' => 'Christmas Eve',
27             'van1' => 'Christmas Day',
28             'van2' => 'Feast of St. Stephen',
29             );
30              
31             my ($self, %params) = @_;
32              
33 0     0 1 0 my $sub = $self->{_adaptee}->can('holidays');
34              
35 0         0 if ($sub) {
36             return &{$sub}(YEAR => $params{'year'});
37 0 0       0 } else {
38 0         0 return {};
  0         0  
39             }
40 0         0 }
41              
42             my ($self, %params) = @_;
43              
44             my $holidays = Date::Holidays::CZ::holidays(
45 1     1 1 3 YEAR => $params{'year'},
46             FORMAT => $format,
47             );
48 1         19  
49             my $holidays_hashref = $self->_transform_arrayref_to_hashref($holidays);
50              
51             my $holiday_date = sprintf('%02s%02s', $params{month}, $params{day});
52 0            
53             my $holiday = $holidays_hashref->{$holiday_date};
54 0            
55             if ($holiday) {
56 0           return $holiday;
57             } else {
58 0 0         return '';
59 0           }
60             }
61 0            
62             my ($self, $arrayref_of_holidays) = @_;
63              
64             my $hashref_of_holidays;
65              
66 0     0     foreach my $entry (@{$arrayref_of_holidays}) {
67             my ($shortname, $key) = split /:/, $entry;
68 0           $hashref_of_holidays->{$key} = $holiday_names{$shortname};
69             }
70 0            
  0            
71 0           return $hashref_of_holidays;
72 0           }
73              
74             1;
75 0            
76              
77             =pod
78              
79             =encoding UTF-8
80              
81             =head1 NAME
82              
83             Date::Holidays::Adapter::CZ - an adapter class for Date::Holidays::CZ
84              
85             =head1 VERSION
86              
87             This POD describes version 1.33 of Date::Holidays::Adapter::CZ
88              
89             =head1 DESCRIPTION
90              
91             The is the adapter class for L<Date::Holidays::CZ>.
92              
93             =head1 SUBROUTINES/METHODS
94              
95             =head2 new
96              
97             The constructor, takes a single named argument, B<countrycode>
98              
99             The constructor is inherited from L<Date::Holidays::Adapter>
100              
101             =head2 is_holiday
102              
103             The C<is_holiday> method, takes 3 named arguments, C<year>, C<month> and C<day>
104              
105             Returns an indication of whether the day is a holiday in the calendar of the
106             country referenced by C<countrycode> in the call to the constructor C<new>.
107              
108             =head2 holidays
109              
110             The B<holidays> method, takes a single named argument, B<year>
111              
112             returns a reference to a hash holding the calendar of the country referenced by
113             B<countrycode> in the call to the constructor B<new>.
114              
115             The calendar will spand for a year and the keys consist of B<month> and B<day>
116             concatenated.
117              
118             =head1 DIAGNOSTICS
119              
120             Please refer to DIAGNOSTICS in L<Date::Holidays>
121              
122             =head1 DEPENDENCIES
123              
124             =over
125              
126             =item * L<Date::Japanese::Holiday>
127              
128             =item * L<Date::Holidays::Adapter>
129              
130             =back
131              
132             =head1 INCOMPATIBILITIES
133              
134             Please refer to INCOMPATIBILITIES in L<Date::Holidays>
135              
136             =head1 BUGS AND LIMITATIONS
137              
138             B<is_holiday> or similar method is not implemented in L<Date::Holidays::CZ> as
139             of version 0.13.
140              
141             The adapter does currently not support the complex API of
142             L<Date::Holidays::CZ> B<holidays>.
143              
144             Please refer to BUGS AND LIMITATIONS in L<Date::Holidays>
145              
146             =head1 BUG REPORTING
147              
148             Please refer to BUG REPORTING in L<Date::Holidays>
149              
150             =head1 AUTHOR
151              
152             Jonas Brømsø, (jonasbn) - C<< <jonasbn@cpan.org> >>
153              
154             =head1 LICENSE AND COPYRIGHT
155              
156             L<Date::Holidays> and related modules are (C) by Jonas Brømsø, (jonasbn)
157             2004-2022
158              
159             Date-Holidays and related modules are released under the Artistic License 2.0
160              
161             =cut