File Coverage

blib/lib/Date/Holidays/Adapter/JP.pm
Criterion Covered Total %
statement 18 34 52.9
branch 0 8 0.0
condition n/a
subroutine 6 9 66.6
pod 2 2 100.0
total 26 53 49.0


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