File Coverage

blib/lib/Date/Holidays/Adapter/AT.pm
Criterion Covered Total %
statement 15 31 48.3
branch 0 8 0.0
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 22 48 45.8


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