App-calx
view release on metacpan or search on metacpan
"Test::Rinci" : "0.151"
},
"x_spec" : {
"Rinci" : "v1.1.102"
}
},
"runtime" : {
"requires" : {
"Color::ANSI::Util" : "0.164",
"Color::RGB::Util" : "0.600",
"DateTime" : "0",
"Getopt::Long" : "2.50",
"List::Util" : "1.54",
"Module::List::Tiny" : "0",
"Text::ANSI::Util" : "0.22",
"perl" : "5.010001",
"strict" : "0",
"warnings" : "0"
}
},
"test" : {
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: App-calx
provides:
App::calx:
file: lib/App/calx.pm
version: '0.009'
requires:
Color::ANSI::Util: '0.164'
Color::RGB::Util: '0.600'
DateTime: '0'
Getopt::Long: '2.50'
List::Util: '1.54'
Module::List::Tiny: '0'
Text::ANSI::Util: '0.22'
perl: '5.010001'
strict: '0'
warnings: '0'
resources:
bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=App-calx
homepage: https://metacpan.org/release/App-calx
Makefile.PL view on Meta::CPAN
"DISTNAME" => "App-calx",
"EXE_FILES" => [
"script/calx"
],
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.010001",
"NAME" => "App::calx",
"PREREQ_PM" => {
"Color::ANSI::Util" => "0.164",
"Color::RGB::Util" => "0.600",
"DateTime" => 0,
"Getopt::Long" => "2.50",
"List::Util" => "1.54",
"Module::List::Tiny" => 0,
"Text::ANSI::Util" => "0.22",
"strict" => 0,
"warnings" => 0
},
"TEST_REQUIRES" => {
"File::Spec" => 0,
"IO::Handle" => 0,
Makefile.PL view on Meta::CPAN
"VERSION" => "0.009",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"Color::ANSI::Util" => "0.164",
"Color::RGB::Util" => "0.600",
"DateTime" => 0,
"File::Spec" => 0,
"Getopt::Long" => "2.50",
"IO::Handle" => 0,
"IPC::Open3" => 0,
"List::Util" => "1.54",
"Module::List::Tiny" => 0,
"Test::More" => 0,
"Text::ANSI::Util" => "0.22",
"strict" => 0,
"warnings" => 0
[Prereqs / TestRequires]
;Test::More=0.98
[Prereqs]
perl=5.010001
strict=0
warnings=0
Color::ANSI::Util=0.164
Color::RGB::Util=0.600
DateTime=0
Getopt::Long=2.50
List::Util=1.54
Module::List::Tiny=0
Text::ANSI::Util=0.22
[Prereqs / DevelopX_spec]
-phase=develop
-relationship=x_spec
Rinci=1.1.102
lib/App/calx.pm view on Meta::CPAN
package App::calx;
use 5.010001;
use strict;
use warnings;
use Color::ANSI::Util qw(ansifg);
use Color::RGB::Util qw(assign_rgb_light_color);
use DateTime;
use List::Util qw(max);
use Text::ANSI::Util qw(ta_length);
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2023-06-22'; # DATE
our $DIST = 'App-calx'; # DIST
our $VERSION = '0.009'; # VERSION
# XXX use locale
my $month_names = [qw(January February March April May June July August September October November December)];
lib/App/calx.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 = [];
if ($args{dates} && @{ $args{dates} }) {
$hol = $args{dates};
} else {
for my $mod0 (@{ $args{caldates_modules} // [] }) {
my $mod = $mod0; $mod =~ s!/!::!g;
$mod = "Calendar::Dates::$mod" unless $mod =~ /\ACalendar::Dates::/;
(my $mod_pm = "$mod.pm") =~ s!::!/!g;
require $mod_pm;
lib/App/calx.pm view on Meta::CPAN
$lines[-1] .= " ";
}
$dt->add(days => 1);
}
for (1..$dtl->day) {
if ($dt->day_of_week == 1) {
push @lines, "";
}
my $col = "808080";
my $reverse;
if (($args{highlight_today}//1) && DateTime->compare($dt, $dt_today) == 0) {
$reverse++;
} else {
for (@$hol) {
if ($dt->day == $_->{day}) {
#my $is_holiday = $_->{is_holiday} ||
# (grep {$_ eq 'holiday'} @{ $_->{tags} // [] });
$col = assign_rgb_light_color($_->{module} // "dates");
$reverse++ if $args{dates};
}
}
script/calx view on Meta::CPAN
#!perl
use 5.010001;
use strict;
use warnings;
use App::calx;
use DateTime;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2023-06-22'; # DATE
our $DIST = 'App-calx'; # DIST
our $VERSION = '0.009'; # VERSION
my %args = (
months => 1,
caldates_modules => [],
script/calx view on Meta::CPAN
require Module::List::Tiny;
my $mods = Module::List::Tiny::list_modules(
"Calendar::Dates::", {list_modules=>1, recurse=>1});
my @res = sort keys %$mods;
for (@res) { s/\ACalendar::Dates::// }
$args{caldates_modules} = \@res;
},
);
my $dt = DateTime->now;
my $re = qr/\A((\d{4})-(\d{2})-(\d{2}))(?:\t(.+))?\z/;
if (!(-t STDIN)) { ## no critic: InputOutput::ProhibitInteractiveTest
my @dates;
while (my $line = <STDIN>) {
chomp $line;
$line =~ $re or die "Invalid date syntax '$line'\n";
push @dates, {
date => $1,
day => $4,
script/calx view on Meta::CPAN
$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::calx::gen_calendar(%args);
die $res->[1] unless $res->[0] == 200;
say $res->[2];
1;
( run in 0.405 second using v1.01-cache-2.11-cpan-05444aca049 )