App-CalId
    
    
  
  
  
view release on metacpan or search on metacpan
0.04    2013-10-05  Released-By: SHARYANTO
        - Add option --show-joint-leave.
0.03    2013-04-03  Released-By: SHARYANTO
        - No functional changes. Some display tweaks (short day of week names,
          not showing prev/next month's days if we are showing more than one
          month of calendar).
0.02    2013-04-03  Released-By: SHARYANTO
        - Add options: -1, -3, -y, -h, -L.
0.01    2013-04-03  Released-By: SHARYANTO
        - First release.
{
   "abstract" : "Display Indonesian calendar on the command-line",
   "author" : [
      "perlancar <perlancar@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
---
abstract: 'Display Indonesian calendar on the command-line'
author:
  - 'perlancar <perlancar@cpan.org>'
build_requires:
  File::Spec: '0'
  IO::Handle: '0'
  IPC::Open3: '0'
  Test::More: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 0
Makefile.PL view on Meta::CPAN
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012.
use strict;
use warnings;
use 5.010001;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
  "ABSTRACT" => "Display Indonesian calendar on the command-line",
  "AUTHOR" => "perlancar <perlancar\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-CalId",
  "EXE_FILES" => [
    "script/cal-id"
  ],
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010001",
NAME
    App::CalId - Display Indonesian calendar on the command-line
VERSION
    This document describes version 0.133 of App::CalId (from Perl
    distribution App-CalId), released on 2021-01-13.
SYNOPSIS
     # See cal-id script provided in this distribution
DESCRIPTION
    This module provides the cal-id command to display Indonesian calendar
    on the command-line.
FUNCTIONS
  gen_calendar
    Usage:
     gen_calendar(%args) -> [status, msg, payload, meta]
    Generate one or more monthly calendars in 3-column format.
    This function is not exported.
    Arguments ('*' denotes required arguments):
    *   highlight_today => *bool* (default: 1)
    *   month => *int*
        The first month.
    First element (status) is an integer containing HTTP status code (200
    means OK, 4xx caller error, 5xx function error). Second element (msg) is
    a string containing error message, or 'OK' if status is 200. Third
    element (payload) is optional, the actual result. Fourth element (meta)
    is called result metadata and is optional, a hash that contains extra
    information.
    Return value: (any)
  gen_monthly_calendar
    Usage:
     gen_monthly_calendar(%args) -> any
    Generate a single month calendar.
    Return [\@lines, \@hol]
    This function is not exported.
    Arguments ('*' denotes required arguments):
    *   highlight_today => *bool* (default: 1)
    *   month* => *int*
lib/App/CalId.pm view on Meta::CPAN
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'} = {
    v => 1.1,
    summary => 'Display Indonesian calendar on the command-line',
};
sub _center {
    my ($w, $text) = @_;
    my $tw = length($text);
    sprintf("%s%s%s",
            (" " x int(($w-$tw)/2)),
            $text,
            (" " x int(($w-$tw)/2)),
        );
}
sub _rpad {
    my ($w, $text) = @_;
    sprintf("%s%s", $text, " " x ($w-ta_length($text)));
}
$SPEC{gen_monthly_calendar} = {
    v => 1.1,
    summary => 'Generate a single month calendar',
    description => <<'_',
Return [\@lines, \@hol]
_
    args => {
        month => {
            schema => ['int*' => between => [1, 12]],
            req => 1,
        },
lib/App/CalId.pm view on Meta::CPAN
        highlight_today => {
            schema => [bool => default => 1],
        },
        time_zone => {
            schema => 'str*',
        },
    },
    "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(
lib/App/CalId.pm view on Meta::CPAN
        $dow = $dt->day_of_week - 1; $dow = 7 if $dow == 0;
        for my $i ($dow+1..7) {
            $lines[-1] .= colored(sprintf("%2d ", $dt->day), "bright_black");
            $dt->add(days => 1);
        }
    }
    return [\@lines, $hol];
}
$SPEC{gen_calendar} = {
    v => 1.1,
    summary => 'Generate one or more monthly calendars in 3-column format',
    args => {
        months => {
            schema => ['int*', min=>1, max=>12, default=>1],
        },
        year => {
            schema => ['int*'],
            req => 1,
        },
        month => {
            summary => 'The first month',
lib/App/CalId.pm view on Meta::CPAN
        },
        highlight_today => {
            schema => [bool => default => 1],
        },
        time_zone => {
            schema => 'str*',
        },
    },
    "x.perinci.sub.wrapper.disable_validate_args" => 1,
};
sub gen_calendar {
    my %args = @_;
    my $y  = $args{year};
    my $m  = $args{month};
    my $mm = $args{months} // 1;
    my $tz = $args{time_zone} // $ENV{TZ} // "UTC";
    my @lines;
    my %margs = (
        highlight_today => ($args{highlight_today} // 1),
lib/App/CalId.pm view on Meta::CPAN
    }
    $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) {
        for (0..$l-1) {
            push @lines,
lib/App/CalId.pm view on Meta::CPAN
        for my $i (0..@hol-1) {
            push @lines, "" if $i == 0;
            push @lines, sprintf("%2d %s = %s", $hol[$i]{day}, $short_month_names->[$hol[$i]{month}-1], $hol[$i]{ind_name});
        }
    }
    [200, "OK", join("\n", @lines)];
}
1;
# ABSTRACT: Display Indonesian calendar on the command-line
__END__
=pod
=encoding UTF-8
=head1 NAME
App::CalId - Display Indonesian calendar on the command-line
=head1 VERSION
This document describes version 0.133 of App::CalId (from Perl distribution App-CalId), released on 2021-01-13.
=head1 SYNOPSIS
 # See cal-id script provided in this distribution
=head1 DESCRIPTION
This module provides the B<cal-id> command to display Indonesian calendar on the
command-line.
=head1 FUNCTIONS
=head2 gen_calendar
Usage:
 gen_calendar(%args) -> [status, msg, payload, meta]
Generate one or more monthly calendars in 3-column format.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<highlight_today> => I<bool> (default: 1)
=item * B<month> => I<int>
lib/App/CalId.pm view on Meta::CPAN
(200 means OK, 4xx caller error, 5xx function error). Second element
(msg) is a string containing error message, or 'OK' if status is
200. Third element (payload) is optional, the actual result. Fourth
element (meta) is called result metadata and is optional, a hash
that contains extra information.
Return value:  (any)
=head2 gen_monthly_calendar
Usage:
 gen_monthly_calendar(%args) -> any
Generate a single month calendar.
Return [\@lines, \@hol]
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<highlight_today> => I<bool> (default: 1)
script/cal-id view on Meta::CPAN
    $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;
# ABSTRACT: Display Indonesian calendar on the command-line
# PODNAME: cal-id
__END__
=pod
=encoding UTF-8
=head1 NAME
cal-id - Display Indonesian calendar on the command-line
=head1 VERSION
This document describes version 0.133 of cal-id (from Perl distribution App-CalId), released on 2021-01-13.
=head1 SYNOPSIS
 # show calendar for the current month
 % cal-id
 # show calendar for the whole year
 % cal-id 2013
 # show calendar for a certain month and year
 % cal-id 12 2013
=head1 DESCRIPTION
This command provides a subset of the Unix command B<cal> functionality for
displaying Indonesian calendar. It starts the week at Monday and highlights (and
lists) Indonesian holidays.
Background: I needed a quick and easy way to see monthly (and sometimes yearly)
calendar, since I haven't got a desk calendar on my desk for years (decades,
even).
=head1 OPTIONS
 % cal-id [opts] [[month] year]
Most options follow corresponding options of B<cal>. Not all options from B<cal>
are supported/recognized. Some options (long ones) are specific to B<cal-id>.
=head2 -1
Show a single month of calendar (the default).
=head2 -3
Show three months of calendar (previous, current, next).
=head2 -h
Turn off highlighting of today.
=head2 -y
Show one year (12 months) of calendar (the default if only year is specified).
=head2 --noshow-holiday-list (-L)
Turn off showing list of holidays.
=head2 --show-joint-leave
Turn on showing list of joint leaves (cuti bersama). By default it is turned
off.
( run in 1.730 second using v1.01-cache-2.11-cpan-5dc5da66d9d )