Calendar-Japanese-Acme-Syukujitsu

 view release on metacpan or  search on metacpan

lib/Calendar/Japanese/Acme/Syukujitsu.pm  view on Meta::CPAN

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use List::Util qw(max min);
 
our $VERSION = '0.01';
 
sub new {
    args
        my $class,
        my $cachefile => {optional => 1},
        my $endpoint => {optional => 1};
 
    my $data;
    if ($cachefile) {
        $data = read_file($cachefile);
    } else {
        $endpoint = $endpoint || $DEFAULT_ENDPOINT;
        $data = Furl->new()->get($endpoint)->content;
    }
    Encode::from_to($data, 'sjis', 'utf-8');
 
    my $syukujitsus = {};
    for my $line (split /\n/, $data) {
        chop($line) if $line =~ /(\n|\r|\n\r)$/;
        my ($date, $syukujitsu_name) = split /,/, $line;
        my ($year, $month, $day) = split /-/, $date;
        next unless $day;

lib/Calendar/Japanese/Acme/Syukujitsu.pm  view on Meta::CPAN

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  $name = is_syukujitsu(2017, 9, 11);
 
=head1 DESCRIPTION
 
This module read Syukujitsu information from
F<syukujitsu.csv> that published by Japanese government.
With interface that referenced to C<Calendar::Japanese::Holiday>.
 
=head1 METHODS
 
=head2 new([cachefile => $cachefile][endpoint => $endpoint])
Constructor.
 
=head2 get_syukujitsus(year => $year [, month => $month [, day => $day]])
 
=head2 is_syukujitsu(year => $year, month => $month, day => $day)
 
=head1 AUTHOR
 
Nao Muto <n@o625.com>



( run in 0.576 second using v1.01-cache-2.11-cpan-49f99fa48dc )