App-calx
view release on metacpan or search on metacpan
lib/App/calx.pm view on Meta::CPAN
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)];
my $short_month_names = [qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)];
our %SPEC;
$SPEC{':package'} = {
v => 1.1,
summary => 'Display a calendar, with highlighted dates',
};
lib/App/calx.pm view on Meta::CPAN
$mod = "Calendar::Dates::$mod" unless $mod =~ /\ACalendar::Dates::/;
(my $mod_pm = "$mod.pm") =~ s!::!/!g;
require $mod_pm;
my $res; eval { $res = $mod->get_entries($y, $m) }; next if $@;
for (@$res) { $_->{module} = $mod0 }
push @$hol, @$res;
}
}
$hol = [sort {$a->{date} cmp $b->{date}} @$hol];
# 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]));
}
push @lines, "Mo Tu We Th Fr Sa Su"; # XXX use locale, option to start on Sunday
my $dow = $dt->day_of_week;
$dt->subtract(days => $dow-1);
for my $i (1..$dow-1) {
push @lines, "" if $i == 1;
if ($args{show_prev_month_days} // 1) {
$lines[-1] .= sprintf("%s%2d \e[0m", ansifg("404040"), $dt->day);
} else {
$lines[-1] .= " ";
}
( run in 1.004 second using v1.01-cache-2.11-cpan-ceb78f64989 )