Calendar-Any

 view release on metacpan or  search on metacpan

bin/cal.pl  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;
use warnings;
use Pod::Usage;
use Getopt::Long qw(:config auto_help);
use Calendar::Any::Util::Calendar qw(:all);
use I18N::Langinfo;

my %Config = (
    'locale' => langinfo(I18N::Langinfo::CODESET()),
    'weekstart' => 0,
    'type' => 'gregorian',
);

my ($month, $year, $type, $china, $gregorian, $julian);

# Install configuration
$week_start_day = $Config{weekstart};
$type = $Config{type};

GetOptions(
    'locale=s' => \$Config{locale},
    'china' => \$china,
    'gregorian' => \$gregorian,
    'julian' => \$julian,
    'type=s' => \$type,
    'weekstart=i' => \$week_start_day,
);

# Check month and year
my @time = localtime;
$month = shift || $time[4]+1;

bin/cal.pl  view on Meta::CPAN

}
$type = ucfirst($type);

## ensure the package is implement
unless ( defined($type) && grep { $type eq $_ } qw(China Gregorian Julian) ) {
    pod2usage();
}

my $cal = Calendar::Any::Util::Calendar::calendar($month, $year, $type)."\n";
if ( $type =~ /China/ ) {
    # out put using locale
    require Encode;
    Encode::_utf8_on($cal);
    print Encode::encode($Config{locale}, $cal);
} else {
    print $cal;
}

__END__

=head1 NAME

cal.pl - Print calendar of multiple type

=head1 VERSION

version 0.5

=head1 SYNOPSIS

cal.pl [-l locale -w weekstart [-c|-g|-j|-t calendar_type] month year]

    Options:
       -l, --locale locale
           The locale of system. Only for Non english calendar.

       -w, --weekstart start
           The week start day for the output. Default is 0, means the
           first day of the week is Sunday

       -c, --china
           Output chinese calendar

       -g, --gregorian
           Output gregorian calendar



( run in 1.214 second using v1.01-cache-2.11-cpan-ceb78f64989 )