File Coverage

lib/Date/Holidays/Adapter/AT.pm
Criterion Covered Total %
statement 18 31 58.0
branch 1 8 12.5
condition n/a
subroutine 6 7 85.7
pod 2 2 100.0
total 27 48 56.2


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   449 use warnings;
  1         1  
  1         27  
4 1     1   5 use Carp;
  1         1  
  1         21  
5 1     1   4  
  1         2  
  1         67  
6             use base 'Date::Holidays::Adapter::DE';
7 1     1   6  
  1         2  
  1         390  
8             use vars qw($VERSION);
9 1     1   6  
  1         2  
  1         365  
10             my $format = '%#:%m%d';
11              
12             $VERSION = '1.33';
13              
14             # Lifted from Date::Holidays::AT source code
15             # Ref: https://metacpan.org/source/MDIETRICH/Date-Holidays-AT-v0.1.4/lib/Date/Holidays/AT.pm
16             my %holiday_names = (
17             'neuj' => "New year's day",
18             'hl3k' => 'Heilige 3 Koenige',
19             'jose' => 'Josef',
20             'tdar' => 'Staatsfeiertag (Tag der Arbeit)',
21             'flor' => 'Florian',
22             'mahi' => 'Mariae Himmelfahrt',
23             'rupe' => 'Rupert',
24             'volk' => 'Tag der Volksabstimmung',
25             'nati' => 'Nationalfeiertag',
26             'alhe' => 'Allerheiligen',
27             'mart' => 'Martin',
28             'leop' => 'Leopold',
29             'maem' => 'Mariae Empfaengnis',
30             'heab' => 'Heiliger Abend',
31             'chri' => 'Christtag',
32             'stef' => 'Stefanitag',
33             'silv' => 'Silvester',
34             'karf' => 'Karfreitag',
35             'ostm' => 'Ostermontag',
36             'himm' => 'Christi Himmelfahrt',
37             'pfim' => 'Pfingstmontag',
38             'fron' => 'Fronleichnam',
39             );
40              
41             my ($self, %params) = @_;
42              
43 0     0 1 0 my $state = $params{'state'} ? $params{'state'} : ['all'];
44              
45 0 0       0 my $holidays;
46              
47 0         0 if ( $params{'year'} ) {
48             $holidays = $self->_transform_arrayref_to_hashref(
49 0 0       0 Date::Holidays::AT::holidays(
50             YEAR => $params{'year'},
51             FORMAT => $format,
52 0         0 WHERE => $state,
53             )
54             );
55             }
56             else {
57             $holidays = $self->_transform_arrayref_to_hashref(
58             Date::Holidays::AT::holidays(
59 0         0 FORMAT => $format,
60             WHERE => $state,
61             )
62             );
63             }
64              
65             return $holidays;
66             }
67 0         0  
68             my ($self, %params) = @_;
69              
70             my $state = $params{'state'} ? $params{'state'} : ['all'];
71 1     1 1 2  
72             my $holidays = Date::Holidays::AT::holidays(
73 1 50       4 YEAR => $params{'year'},
74             FORMAT => $format,
75             WHERE => $state,
76 1         18 );
77              
78             my $holidays_hashref = $self->_transform_arrayref_to_hashref($holidays);
79              
80             my $holiday_date = sprintf('%02s%02s', $params{month}, $params{day});
81 0            
82             my $holiday = $holidays_hashref->{$holiday_date};
83 0            
84             if ($holiday) {
85 0           return $holiday;
86             } else {
87 0 0         return '';
88 0           }
89             }
90 0            
91             1;
92              
93              
94             =pod
95              
96             =encoding UTF-8
97              
98             =head1 NAME
99              
100             Date::Holidays::Adapter::AT - an adapter class for Date::Holidays::AT
101              
102             =head1 VERSION
103              
104             This POD describes version 1.33 of Date::Holidays::Adapter::AT
105              
106             =head1 DESCRIPTION
107              
108             The is the adapter class for L<Date::Holidays::AT>.
109              
110             =head1 SUBROUTINES/METHODS
111              
112             =head2 new
113              
114             The constructor, takes a single named argument, B<countrycode>
115              
116             The constructor is inherited from L<Date::Holidays::Adapter>
117              
118             =head2 is_holiday
119              
120             The C<is_holiday> method, takes 3 named arguments, C<year>, C<month> and C<day>
121              
122             Returns an indication of whether the day is a holiday in the calendar of the
123             country referenced by C<countrycode> in the call to the constructor C<new>.
124              
125             =head2 holidays
126              
127             The B<holidays> method, takes a single named argument, B<year>
128              
129             returns a reference to a hash holding the calendar of the country referenced by
130             B<countrycode> in the call to the constructor B<new>.
131              
132             The calendar will spand for a year and the keys consist of B<month> and B<day>
133             concatenated.
134              
135             In addition from version 1.25 the adapter support the B<state> parameter, defaulting to
136             B<'all'>.
137              
138             =head1 DIAGNOSTICS
139              
140             Please refer to DIAGNOSTICS in L<Date::Holidays>
141              
142             =head1 DEPENDENCIES
143              
144             =over
145              
146             =item * L<Date::Holidays::AT>
147              
148             =item * L<Date::Holidays::Adapter::DE>
149              
150             =item * L<Date::Holidays::Adapter>
151              
152             =back
153              
154             =head1 INCOMPATIBILITIES
155              
156             Please refer to INCOMPATIBILITIES in L<Date::Holidays>
157              
158             =head1 BUGS AND LIMITATIONS
159              
160             B<is_holiday> or similar method is not implemented in L<Date::Holidays::AT> as of version v0.1.4.
161              
162             The adapter does currently not support the complex API of
163             L<Date::Holidays::AT> B<holidays>.
164              
165             Please refer to BUGS AND LIMITATIONS in L<Date::Holidays>
166              
167             =head1 BUG REPORTING
168              
169             Please refer to BUG REPORTING in L<Date::Holidays>
170              
171             =head1 AUTHOR
172              
173             Jonas Brømsø, (jonasbn) - C<< <jonasbn@cpan.org> >>
174              
175             =head1 LICENSE AND COPYRIGHT
176              
177             L<Date::Holidays> and related modules are (C) by Jonas Brømsø, (jonasbn)
178             2004-2022
179              
180             Date-Holidays and related modules are released under the Artistic License 2.0
181              
182             =cut
183