File Coverage

lib/Date/Holidays/Adapter/JP.pm
Criterion Covered Total %
statement 25 34 73.5
branch 3 8 37.5
condition n/a
subroutine 7 9 77.7
pod 2 2 100.0
total 37 53 69.8


line stmt bran cond sub pod time code
1              
2             use strict;
3 1     1   493 use warnings;
  1         4  
  1         28  
4 1     1   6 use vars qw($VERSION);
  1         1  
  1         26  
5 1     1   5 use Locale::Country;
  1         3  
  1         35  
6 1     1   5 use Carp;
  1         2  
  1         78  
7 1     1   6  
  1         1  
  1         47  
8             use base 'Date::Holidays::Adapter';
9 1     1   4  
  1         2  
  1         312  
10             $VERSION = '1.33';
11              
12             croak "holidays is unimplemented for ".__PACKAGE__;
13             }
14 0     0 1 0  
15             my ($self, %params) = @_;
16              
17             my $sub = $self->{_adaptee}->can('is_japanese_holiday');
18 0     0 1 0  
19             if ($sub) {
20 0         0 return &{$sub}($params{'year'}, $params{'month'}, $params{'day'});
21             } else {
22 0 0       0 return;
23 0         0 }
  0         0  
24             }
25 0         0  
26             my ( $self, $params ) = @_;
27              
28             if ( !$self->{_countrycode} ) {
29             croak "No country code specified";
30 1     1   3 }
31              
32 1 50       7 my $module = 'Date::Japanese::Holiday';
33 0         0  
34             if ( !$params->{nocheck} ) {
35             if ( !code2country($self->{_countrycode}) ) { #from Locale::Country
36 1         2 croak "$self->{_countrycode} is not a valid country code";
37             }
38 1 50       3 }
39 1 50       3  
40 0         0 try {
41             $self->_load($module);
42             }
43              
44 1         37 return $module;
45 1         5 }
46              
47             1;
48              
49              
50             =pod
51              
52             =encoding UTF-8
53              
54             =head1 NAME
55              
56             Date::Holidays::Adapter::JP - an adapter class for Date::Japanese::Holiday
57              
58             =head1 VERSION
59              
60             This POD describes version 1.33 of Date::Holidays::Adapter::JP
61              
62             =head1 DESCRIPTION
63              
64             The is the adapter class for L<Date::Japanese::Holiday>.
65              
66             =head1 SUBROUTINES/METHODS
67              
68             =head2 new
69              
70             The constructor, takes a single named argument, B<countrycode>
71              
72             The constructor is inherited from L<Date::Holidays::Adapter>
73              
74             =head2 is_holiday
75              
76             The B<holidays> method, takes 3 named arguments, B<year>, B<month> and B<day>
77              
78             returns an indication of whether the day is a holiday in the calendar of the
79             country referenced by B<countrycode> in the call to the constructor B<new>.
80              
81             =head2 holidays
82              
83             Not implemented in L<Date::Japanese::Holiday>, calls to this throw the
84             L<Date::Holidays::Exception::UnsupportedMethod>
85              
86             =head1 DIAGNOSTICS
87              
88             Please refer to DIAGNOSTICS in L<Date::Holidays>
89              
90             =head1 DEPENDENCIES
91              
92             =over
93              
94             =item * L<Date::Japanese::Holiday>
95              
96             =item * L<Date::Holidays::Adapter>
97              
98             =back
99              
100             =head1 INCOMPATIBILITIES
101              
102             Please refer to INCOMPATIBILITIES in L<Date::Holidays>
103              
104             =head1 BUGS AND LIMITATIONS
105              
106             The adaptee module for this class is named: L<Date::Japanese::Holiday>, but the
107             adapter class is following the general adapter naming of
108             Date::Holidays::Adapter::<countrycode>.
109              
110             B<holidays> method or similar isnot implemented in L<Date::Japanese::Holiday> as
111             of version 0.05.
112              
113             The adapter does currently not support the object-oriented API of
114             L<Date::Japanese::Holiday>.
115              
116             Please refer to BUGS AND LIMITATIONS in L<Date::Holidays>
117              
118             =head1 BUG REPORTING
119              
120             Please refer to BUG REPORTING in L<Date::Holidays>
121              
122             =head1 SEE ALSO
123              
124             =over
125              
126             =item * L<Date::Holidays>
127              
128             =back
129              
130             =head1 AUTHOR
131              
132             Jonas Brømsø, (jonasbn) - C<< <jonasbn@cpan.org> >>
133              
134             =head1 LICENSE AND COPYRIGHT
135              
136             L<Date::Holidays> and related modules are (C) by Jonas Brømsø, (jonasbn)
137             2004-2022
138              
139             Date-Holidays and related modules are released under the Artistic License 2.0
140              
141             =cut