App-CalId
view release on metacpan or search on metacpan
"Test::Pod::Coverage" : "1.08",
"Test::Rinci" : "0.151"
},
"x_spec" : {
"Rinci" : "v1.1.94"
}
},
"runtime" : {
"requires" : {
"Calendar::Indonesia::Holiday" : "0.331",
"DateTime" : "0",
"Getopt::Long" : "2.50",
"List::Util" : "1.45",
"Term::ANSIColor" : "0",
"Text::ANSI::Util" : "0.22",
"experimental" : "0",
"perl" : "5.010001",
"strict" : "0",
"warnings" : "0"
}
},
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: App-CalId
requires:
Calendar::Indonesia::Holiday: '0.331'
DateTime: '0'
Getopt::Long: '2.50'
List::Util: '1.45'
Term::ANSIColor: '0'
Text::ANSI::Util: '0.22'
experimental: '0'
perl: '5.010001'
strict: '0'
warnings: '0'
resources:
bugtracker: https://github.com/perlancar/perl-App-CalId/issues
Makefile.PL view on Meta::CPAN
},
"DISTNAME" => "App-CalId",
"EXE_FILES" => [
"script/cal-id"
],
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.010001",
"NAME" => "App::CalId",
"PREREQ_PM" => {
"Calendar::Indonesia::Holiday" => "0.331",
"DateTime" => 0,
"Getopt::Long" => "2.50",
"List::Util" => "1.45",
"Term::ANSIColor" => 0,
"Text::ANSI::Util" => "0.22",
"experimental" => 0,
"strict" => 0,
"warnings" => 0
},
"TEST_REQUIRES" => {
"File::Spec" => 0,
Makefile.PL view on Meta::CPAN
},
"VERSION" => "0.133",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"Calendar::Indonesia::Holiday" => "0.331",
"DateTime" => 0,
"File::Spec" => 0,
"Getopt::Long" => "2.50",
"IO::Handle" => 0,
"IPC::Open3" => 0,
"List::Util" => "1.45",
"Term::ANSIColor" => 0,
"Test::More" => 0,
"Text::ANSI::Util" => "0.22",
"experimental" => 0,
"strict" => 0,
[Prereqs / TestRequires]
;Test::More=0.98
[Prereqs]
perl=5.010001
experimental=0
strict=0
warnings=0
Calendar::Indonesia::Holiday=0.331
DateTime=0
Getopt::Long=2.50
List::Util=1.45
;Log::Any=0
Term::ANSIColor=0
Text::ANSI::Util=0.22
[Prereqs / DevelopX_spec]
-phase=develop
-relationship=x_spec
Rinci=1.1.94
lib/App/CalId.pm view on Meta::CPAN
our $DATE = '2021-01-13'; # DATE
our $DIST = 'App-CalId'; # DIST
our $VERSION = '0.133'; # VERSION
use 5.010001;
use strict;
use warnings;
use experimental 'smartmatch';
use Calendar::Indonesia::Holiday qw(list_id_holidays);
use DateTime;
use List::Util qw(max);
use Term::ANSIColor;
use Text::ANSI::Util qw(ta_length);
my $month_names = [qw(Januari Februari Maret April Mei Juni Juli Agustus September Oktober November Desember)];
my $short_month_names = [qw(Jan Feb Mar Apr Mei Jun Jul Agt Sep Okt Nov Des)];
our %SPEC;
$SPEC{':package'} = {
lib/App/CalId.pm view on Meta::CPAN
"x.perinci.sub.wrapper.disable_validate_args" => 1,
result_naked => 1,
};
sub gen_monthly_calendar {
my %args = @_;
my $m = $args{month};
my $y = $args{year};
my @lines;
my $tz = $args{time_zone} // $ENV{TZ} // "UTC";
my $dt = DateTime->new(year=>$y, month=>$m, day=>1, time_zone=>$tz);
my $dtl = DateTime->last_day_of_month(year=>$y, month=>$m, time_zone=>$tz);
my $dt_today = DateTime->today(time_zone=>$tz);
my $hol = list_id_holidays(
detail => 1, year => $y, month => $m,
(is_joint_leave => 0) x !$args{show_joint_leave},
)->[2];
# XXX use locale
if ($args{show_year_in_title} // 1) {
push @lines, _center(21, sprintf("%s %d", $month_names->[$m-1], $y));
} else {
push @lines, _center(21, sprintf("%s", $month_names->[$m-1]));
lib/App/CalId.pm view on Meta::CPAN
} else {
$lines[-1] .= " ";
}
$dt->add(days => 1);
}
for (1..$dtl->day) {
if ($dt->day_of_week == 1) {
push @lines, "";
}
my $col = "white";
if (($args{highlight_today}//1) && DateTime->compare($dt, $dt_today) == 0) {
$col = "reverse";
} else {
for (@$hol) {
if ($dt->day == $_->{day}) {
$col = "bright_red";
}
}
}
$lines[-1] .= colored(sprintf("%2d ", $dt->day), $col);
$dt->add(days => 1);
lib/App/CalId.pm view on Meta::CPAN
$margs{show_year_in_title} = 0;
push @lines, _center(64, $y);
}
$m or return [400, "Please specify month"];
if ($mm > 1) {
$margs{show_prev_month_days} = 0;
$margs{show_next_month_days} = 0;
}
my @moncals;
my $dt = DateTime->new(year=>$y, month=>$m, day=>1, time_zone=>$tz);
for (1..$mm) {
push @moncals, gen_monthly_calendar(
month=>$dt->month, year=>$dt->year, time_zone=>$tz, %margs);
$dt->add(months => 1);
}
my @hol = map {@{ $_->[1] }} @moncals;
my $l = max(map {~~@$_} map {$_->[0]} @moncals);
my $i = 0;
my $j = @moncals;
while (1) {
script/cal-id view on Meta::CPAN
our $DATE = '2021-01-13'; # DATE
our $DIST = 'App-CalId'; # DIST
our $VERSION = '0.133'; # VERSION
use 5.010001;
use strict;
use warnings;
#use Log::Any '$log';
use App::CalId;
use DateTime;
use Getopt::Long qw(:config auto_help auto_version);
my %args = (months => 1);
GetOptions(
'h' => sub { $args{highlight_today} = 0 },
'noshow-holiday-list|L' => sub { $args{show_holiday_list} = 0 },
'1' => sub { $args{months} = 1 },
'3' => sub { $args{months} = 3 },
'y' => sub { $args{months} = 12 },
'show-joint-leave' => sub { $args{show_joint_leave} = 1 },
) or die "cal-id: Error in option parsing, bailing out\n";
my $dt = DateTime->now;
if (@ARGV == 1) {
$args{year} = $ARGV[0];
$args{months} = 12;
} elsif (@ARGV == 2) {
$args{month} = $ARGV[0];
$args{year} = $ARGV[1];
} else {
$args{month} = $dt->month;
$args{year} = $dt->year;
}
if ($args{months} == 3) {
$dt = DateTime->new(year=>$args{year}, month=>$args{month}//1, day=>1);
$dt->subtract(months=>1);
$args{month} = $dt->month;
$args{year} = $dt->year;
}
my $res = App::CalId::gen_calendar(%args);
die $res->[1] unless $res->[0] == 200;
say $res->[2];
1;
( run in 0.413 second using v1.01-cache-2.11-cpan-05444aca049 )