NAME

Calendar::Indonesia::Holiday - List Indonesian public holidays

VERSION

This document describes version 0.351 of Calendar::Indonesia::Holiday (from Perl distribution Calendar-Indonesia-Holiday), released on 2023-07-11.

SYNOPSIS

use Calendar::Indonesia::Holiday qw(
    list_idn_holidays
    list_idn_workdays

    count_idn_workdays

    is_idn_holiday
    is_idn_workday
);

This lists Indonesian holidays for the year 2011, without the joint leave days ("cuti bersama"), showing only the dates:

my $res = list_idn_holidays(year => 2011, is_joint_leave=>0);

Sample result:

[200, "OK", [
  '2011-01-01',
  '2011-02-03',
  '2011-02-16',
  '2011-03-05',
  '2011-04-22',
  '2011-05-17',
  '2011-06-02',
  '2011-06-29',
  '2011-08-17',
  '2011-08-31',
  '2011-09-01',
  '2011-11-07',
  '2011-11-27',
  '2011-12-25',
]];

This lists religious Indonesian holidays, showing full details:

my $res = list_idn_holidays(year => 2011,
                            "tags.has" => ['religious'], detail=>1);

Sample result:

[200, "OK", [
  {date        => '2011-02-16',
   day         => 16,
   month       => 2,
   year        => 2011,
   ind_name    => 'Maulid Nabi Muhammad',
   eng_name    => 'Mawlid',
   eng_aliases => ['Mawlid An-Nabi'],
   ind_aliases => ['Maulud'],
   is_holiday  => 1,
   tags        => [qw/religious religion=islam calendar=lunar/],
  },
  ...
]];

This checks whether 2011-02-16 is a holiday:

my $res = is_idn_holiday(date => '2011-02-16');
print "2011-02-16 is a holiday\n" if $res->[2];

This checks whether 2021-03-11 is a working day:

my $res = is_idn_workday(date => '2021-03-11');
print "2011-02-16 is a holiday\n" if $res->[2];

This lists working days for a certain period:

my $res = list_idn_workdays(start_date=>'2021-01-01', end_date=>'2021-06-30');

Idem, but returns a number instead. If unspecified, start_date defaults to start of current month and end_date defaults to end of current month. So this returns the number of working days in the current month:

my $res = count_idn_workdays();

DESCRIPTION

This module provides functions to list Indonesian holidays. There is a command-line script interface for this module: list-idn-holidays and a few others distributed in App::IndonesianHolidayUtils distribution.

Calendar years supported: 1990-2023.

Note: Note that sometimes the holiday (as set by law) falls at a different date than the actual religious commemoration date. When you use the detail option, the original_date key will show you the actual religious date.

Note: it is also possible that multiple (religious, cultural) holidays fall on the same national holiday. An example is May 8, 1997 which is commemorated as Hijra 1418H as well as Ascension Day. When this happens, the holidays key will contain the details of each religious/cultural holiday.

Caveat: aside from national holidays, some provinces sometimes declare their own (e.g. governor election day for East Java province, etc). This is currently not yet included in this module.

DEVELOPER NOTES

To mark that a holiday has been moved from its original date, use the original_date option. For example, Mawlid in 2021 has been moved from its original date 2021-11-19 (this is the day it is actually observed/commemorated) to 2021-11-20 (this is the day the holiday is in effect where offices and public places are closed). By adding this option, the summary will reflect this information:

date: 2021-12-20
eng_name: Mawlid (commemorated on 2021-12-19)
ind_name: Maulid Nabi Muhammad (diperingati 2021-12-19)

FUNCTIONS

count_idn_workdays

Usage:

count_idn_workdays(%args) -> [$status_code, $reason, $payload, \%result_meta]

Count working days (non-holiday business days) for a certain period.

Working day is defined as day that is not Saturday*/Sunday/holiday/joint leave days*. If work_saturdays is set to true, Saturdays are also counted as working days. If observe_joint_leaves is set to false, joint leave days are also counted as working days.

Contains data from years 1990 to 2023

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • end_date => str

    End date.

    Defaults to end of current month. Either a string in the form of "YYYY-MM-DD", or a DateTime object, is accepted.

  • observe_joint_leaves => bool (default: 1)

    If set to 0, do not observe joint leave as holidays.

  • start_date => str

    Starting date.

    Defaults to start of current month. Either a string in the form of "YYYY-MM-DD", or a DateTime object, is accepted.

  • work_saturdays => bool (default: 0)

    If set to 1, Saturday is a working day.

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

is_idn_holiday

Usage:

is_idn_holiday(%args) -> [$status_code, $reason, $payload, \%result_meta]

Check whether a date is an Indonesian holiday.

Will return boolean if a given date is a holiday. A joint leave day will not count as holiday unless you specify include_joint_leave option.

Date can be given using separate day (of month), month, and year, or as a single YYYY-MM-DD date.

Will return undef (exit code 2 on CLI) if year is not within range of the holiday data.

Note that you can also use list_idn_holidays to check whether a date (or a combination of day, month, and year) is a holiday , but is_idn_holiday is slightly more efficient, its include_joint_leave option is more convenient, and it offers a few more options.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • date => str

    (No description)

  • day => int

    (No description)

  • detail => bool

    (No description)

  • include_joint_leave => bool

    (No description)

  • month => int

    (No description)

  • quiet => bool

    (No description)

  • reverse => bool

    (No description)

  • year => int

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

is_idn_workday

Usage:

is_idn_workday(%args) -> [$status_code, $reason, $payload, \%result_meta]

Check whether a date is a working day (non-holiday business day).

Working day is defined as day that is not Saturday*/Sunday/holiday/joint leave days*. If work_saturdays is set to true, Saturdays are also counted as working days. If observe_joint_leaves is set to false, joint leave days are also counted as working days.

Contains data from years 1990 to 2023

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • date => str

    (No description)

  • day => int

    (No description)

  • month => int

    (No description)

  • observe_joint_leaves => bool (default: 1)

    If set to 0, do not observe joint leave as holidays.

  • work_saturdays => bool (default: 0)

    If set to 1, Saturday is a working day.

  • year => int

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

list_idn_holidays

Usage:

list_idn_holidays(%args) -> [$status_code, $reason, $payload, \%result_meta]

List Indonesian holidays in calendar.

List holidays and joint leave days ("cuti bersama").

Contains data from years 1990 to 2023

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • date => date

    Only return records where the 'date' field equals specified value.

  • date.in => array[date]

    Only return records where the 'date' field is in the specified values.

  • date.is => date

    Only return records where the 'date' field equals specified value.

  • date.isnt => date

    Only return records where the 'date' field does not equal specified value.

  • date.max => date

    Only return records where the 'date' field is less than or equal to specified value.

  • date.min => date

    Only return records where the 'date' field is greater than or equal to specified value.

  • date.not_in => array[date]

    Only return records where the 'date' field is not in the specified values.

  • date.xmax => date

    Only return records where the 'date' field is less than specified value.

  • date.xmin => date

    Only return records where the 'date' field is greater than specified value.

  • day => int

    Only return records where the 'day' field equals specified value.

  • day.in => array[int]

    Only return records where the 'day' field is in the specified values.

  • day.is => int

    Only return records where the 'day' field equals specified value.

  • day.isnt => int

    Only return records where the 'day' field does not equal specified value.

  • day.max => int

    Only return records where the 'day' field is less than or equal to specified value.

  • day.min => int

    Only return records where the 'day' field is greater than or equal to specified value.

  • day.not_in => array[int]

    Only return records where the 'day' field is not in the specified values.

  • day.xmax => int

    Only return records where the 'day' field is less than specified value.

  • day.xmin => int

    Only return records where the 'day' field is greater than specified value.

  • decree_date => str

    Only return records where the 'decree_date' field equals specified value.

  • decree_date.contains => str

    Only return records where the 'decree_date' field contains specified text.

  • decree_date.in => array[str]

    Only return records where the 'decree_date' field is in the specified values.

  • decree_date.is => str

    Only return records where the 'decree_date' field equals specified value.

  • decree_date.isnt => str

    Only return records where the 'decree_date' field does not equal specified value.

  • decree_date.max => str

    Only return records where the 'decree_date' field is less than or equal to specified value.

  • decree_date.min => str

    Only return records where the 'decree_date' field is greater than or equal to specified value.

  • decree_date.not_contains => str

    Only return records where the 'decree_date' field does not contain specified text.

  • decree_date.not_in => array[str]

    Only return records where the 'decree_date' field is not in the specified values.

  • decree_date.xmax => str

    Only return records where the 'decree_date' field is less than specified value.

  • decree_date.xmin => str

    Only return records where the 'decree_date' field is greater than specified value.

  • decree_note => str

    Only return records where the 'decree_note' field equals specified value.

  • decree_note.contains => str

    Only return records where the 'decree_note' field contains specified text.

  • decree_note.in => array[str]

    Only return records where the 'decree_note' field is in the specified values.

  • decree_note.is => str

    Only return records where the 'decree_note' field equals specified value.

  • decree_note.isnt => str

    Only return records where the 'decree_note' field does not equal specified value.

  • decree_note.max => str

    Only return records where the 'decree_note' field is less than or equal to specified value.

  • decree_note.min => str

    Only return records where the 'decree_note' field is greater than or equal to specified value.

  • decree_note.not_contains => str

    Only return records where the 'decree_note' field does not contain specified text.

  • decree_note.not_in => array[str]

    Only return records where the 'decree_note' field is not in the specified values.

  • decree_note.xmax => str

    Only return records where the 'decree_note' field is less than specified value.

  • decree_note.xmin => str

    Only return records where the 'decree_note' field is greater than specified value.

  • detail => bool (default: 0)

    Return array of full records instead of just ID fields.

    By default, only the key (ID) field is returned per result entry.

  • dow => int

    Only return records where the 'dow' field equals specified value.

  • dow.in => array[int]

    Only return records where the 'dow' field is in the specified values.

  • dow.is => int

    Only return records where the 'dow' field equals specified value.

  • dow.isnt => int

    Only return records where the 'dow' field does not equal specified value.

  • dow.max => int

    Only return records where the 'dow' field is less than or equal to specified value.

  • dow.min => int

    Only return records where the 'dow' field is greater than or equal to specified value.

  • dow.not_in => array[int]

    Only return records where the 'dow' field is not in the specified values.

  • dow.xmax => int

    Only return records where the 'dow' field is less than specified value.

  • dow.xmin => int

    Only return records where the 'dow' field is greater than specified value.

  • eng_aliases => array

    Only return records where the 'eng_aliases' field equals specified value.

  • eng_aliases.has => array[str]

    Only return records where the 'eng_aliases' field is an array/list which contains specified value.

  • eng_aliases.is => array

    Only return records where the 'eng_aliases' field equals specified value.

  • eng_aliases.isnt => array

    Only return records where the 'eng_aliases' field does not equal specified value.

  • eng_aliases.lacks => array[str]

    Only return records where the 'eng_aliases' field is an array/list which does not contain specified value.

  • eng_name => str

    Only return records where the 'eng_name' field equals specified value.

  • eng_name.contains => str

    Only return records where the 'eng_name' field contains specified text.

  • eng_name.in => array[str]

    Only return records where the 'eng_name' field is in the specified values.

  • eng_name.is => str

    Only return records where the 'eng_name' field equals specified value.

  • eng_name.isnt => str

    Only return records where the 'eng_name' field does not equal specified value.

  • eng_name.max => str

    Only return records where the 'eng_name' field is less than or equal to specified value.

  • eng_name.min => str

    Only return records where the 'eng_name' field is greater than or equal to specified value.

  • eng_name.not_contains => str

    Only return records where the 'eng_name' field does not contain specified text.

  • eng_name.not_in => array[str]

    Only return records where the 'eng_name' field is not in the specified values.

  • eng_name.xmax => str

    Only return records where the 'eng_name' field is less than specified value.

  • eng_name.xmin => str

    Only return records where the 'eng_name' field is greater than specified value.

  • exclude_fields => array[str]

    Select fields to return.

  • fields => array[str]

    Select fields to return.

  • ind_aliases => array

    Only return records where the 'ind_aliases' field equals specified value.

  • ind_aliases.has => array[str]

    Only return records where the 'ind_aliases' field is an array/list which contains specified value.

  • ind_aliases.is => array

    Only return records where the 'ind_aliases' field equals specified value.

  • ind_aliases.isnt => array

    Only return records where the 'ind_aliases' field does not equal specified value.

  • ind_aliases.lacks => array[str]

    Only return records where the 'ind_aliases' field is an array/list which does not contain specified value.

  • ind_name => str

    Only return records where the 'ind_name' field equals specified value.

  • ind_name.contains => str

    Only return records where the 'ind_name' field contains specified text.

  • ind_name.in => array[str]

    Only return records where the 'ind_name' field is in the specified values.

  • ind_name.is => str

    Only return records where the 'ind_name' field equals specified value.

  • ind_name.isnt => str

    Only return records where the 'ind_name' field does not equal specified value.

  • ind_name.max => str

    Only return records where the 'ind_name' field is less than or equal to specified value.

  • ind_name.min => str

    Only return records where the 'ind_name' field is greater than or equal to specified value.

  • ind_name.not_contains => str

    Only return records where the 'ind_name' field does not contain specified text.

  • ind_name.not_in => array[str]

    Only return records where the 'ind_name' field is not in the specified values.

  • ind_name.xmax => str

    Only return records where the 'ind_name' field is less than specified value.

  • ind_name.xmin => str

    Only return records where the 'ind_name' field is greater than specified value.

  • is_holiday => bool

    Only return records where the 'is_holiday' field equals specified value.

  • is_holiday.is => bool

    Only return records where the 'is_holiday' field equals specified value.

  • is_holiday.isnt => bool

    Only return records where the 'is_holiday' field does not equal specified value.

  • is_joint_leave => bool

    Only return records where the 'is_joint_leave' field equals specified value.

  • is_joint_leave.is => bool

    Only return records where the 'is_joint_leave' field equals specified value.

  • is_joint_leave.isnt => bool

    Only return records where the 'is_joint_leave' field does not equal specified value.

  • month => int

    Only return records where the 'month' field equals specified value.

  • month.in => array[int]

    Only return records where the 'month' field is in the specified values.

  • month.is => int

    Only return records where the 'month' field equals specified value.

  • month.isnt => int

    Only return records where the 'month' field does not equal specified value.

  • month.max => int

    Only return records where the 'month' field is less than or equal to specified value.

  • month.min => int

    Only return records where the 'month' field is greater than or equal to specified value.

  • month.not_in => array[int]

    Only return records where the 'month' field is not in the specified values.

  • month.xmax => int

    Only return records where the 'month' field is less than specified value.

  • month.xmin => int

    Only return records where the 'month' field is greater than specified value.

  • note => str

    Only return records where the 'note' field equals specified value.

  • note.contains => str

    Only return records where the 'note' field contains specified text.

  • note.in => array[str]

    Only return records where the 'note' field is in the specified values.

  • note.is => str

    Only return records where the 'note' field equals specified value.

  • note.isnt => str

    Only return records where the 'note' field does not equal specified value.

  • note.max => str

    Only return records where the 'note' field is less than or equal to specified value.

  • note.min => str

    Only return records where the 'note' field is greater than or equal to specified value.

  • note.not_contains => str

    Only return records where the 'note' field does not contain specified text.

  • note.not_in => array[str]

    Only return records where the 'note' field is not in the specified values.

  • note.xmax => str

    Only return records where the 'note' field is less than specified value.

  • note.xmin => str

    Only return records where the 'note' field is greater than specified value.

  • queries => array[str]

    Search.

    This will search all searchable fields with one or more specified queries. Each query can be in the form of -FOO (dash prefix notation) to require that the fields do not contain specified string, or /FOO/ to use regular expression. All queries must match if the query_boolean option is set to and; only one query should match if the query_boolean option is set to or.

  • query_boolean => str (default: "and")

    Whether records must match all search queries ('and') or just one ('or').

    If set to and, all queries must match; if set to or, only one query should match. See the queries option for more details on searching.

  • random => bool (default: 0)

    Return records in random order.

  • result_limit => int

    Only return a certain number of records.

  • result_start => int (default: 1)

    Only return starting from the n'th record.

  • sort => array[str]

    Order records according to certain field(s).

    A list of field names separated by comma. Each field can be prefixed with '-' to specify descending order instead of the default ascending.

  • tags => array

    Only return records where the 'tags' field equals specified value.

  • tags.has => array[str]

    Only return records where the 'tags' field is an array/list which contains specified value.

  • tags.is => array

    Only return records where the 'tags' field equals specified value.

  • tags.isnt => array

    Only return records where the 'tags' field does not equal specified value.

  • tags.lacks => array[str]

    Only return records where the 'tags' field is an array/list which does not contain specified value.

  • with_field_names => bool

    Return field names in each record (as hash/associative array).

    When enabled, function will return each record as hash/associative array (field name => value pairs). Otherwise, function will return each record as list/array (field value, field value, ...).

  • year => int

    Only return records where the 'year' field equals specified value.

  • year.in => array[int]

    Only return records where the 'year' field is in the specified values.

  • year.is => int

    Only return records where the 'year' field equals specified value.

  • year.isnt => int

    Only return records where the 'year' field does not equal specified value.

  • year.max => int

    Only return records where the 'year' field is less than or equal to specified value.

  • year.min => int

    Only return records where the 'year' field is greater than or equal to specified value.

  • year.not_in => array[int]

    Only return records where the 'year' field is not in the specified values.

  • year.xmax => int

    Only return records where the 'year' field is less than specified value.

  • year.xmin => int

    Only return records where the 'year' field is greater than specified value.

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

list_idn_workdays

Usage:

list_idn_workdays(%args) -> [$status_code, $reason, $payload, \%result_meta]

List working days (non-holiday business days) for a certain period.

Working day is defined as day that is not Saturday*/Sunday/holiday/joint leave days*. If work_saturdays is set to true, Saturdays are also counted as working days. If observe_joint_leaves is set to false, joint leave days are also counted as working days.

Contains data from years 1990 to 2023

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • end_date => str

    End date.

    Defaults to end of current month. Either a string in the form of "YYYY-MM-DD", or a DateTime object, is accepted.

  • observe_joint_leaves => bool (default: 1)

    If set to 0, do not observe joint leave as holidays.

  • start_date => str

    Starting date.

    Defaults to start of current month. Either a string in the form of "YYYY-MM-DD", or a DateTime object, is accepted.

  • work_saturdays => bool (default: 0)

    If set to 1, Saturday is a working day.

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

FAQ

What is "joint leave"?

Workers are normally granted around 12 days of paid leave per year (excluding special leaves like maternity, etc). They are free to spend them on whichever days they want. The joint leave ("cuti bersama") is a government program to recommend that some of these leave days be spent together nationally on certain assigned days, especially adjacent to holidays like Eid Ul-Fitr ("Lebaran"). It is not mandated (companies can opt to follow it or not, depending on their specific situation), but many do follow it anyway, e.g. government civil workers, banks, etc. I am marking joint leave days with is_joint_leave=1 and is_holiday=0, while the holidays themselves with is_holiday=1, so you can differentiate/select both/either one.

When was joint leave established?

Joint leave was first decreed in 2001 [1] for the 2002 & 2003 calendar years. The 2001 calendar year does not yet have joint leave days [2]. See also [3]. Websites that list joint leave days for 2001 or earlier years (example: [4], [5]) are incorrect; by 2001 or earlier, these joint leave days had not been officially decreed by the government.

[1] https://jdih.kemnaker.go.id/data_wirata/2002-4-4.pdf

[2] https://peraturan.bkpm.go.id/jdih/userfiles/batang/Kepmenag_162_2000.pdf

[3] http://www.wikiapbn.org/cuti-bersama/

[4] https://kalenderindonesia.com/libur/masehi/2001

[5] https://kalenderindonesia.com/libur/masehi/1991

What happens when multiple religious/holidays coincide on a single calendar day?

For example, in 1997, both Hijra and Ascension Day fall on May 8th. When this happens, ind_name and eng_name will contain all the names of the holidays separated by comma, respectively:

Tahun Baru Hijriah, Kenaikan Isa Al-Masih
Hijra, Ascension Day

All the properties that have the same value will be set in the merged holiday data:

is_holiday => 1,
is_joint_leave => 1,

The multiple property will also be set to true:

multiple => 1,

All the tags will be merged:

tags => ['religious', 'religion=christianity', 'calendar=lunar']

You can get each holiday's data in the holidays key.

Data for older holidays?

Will be provided if there is demand and data source.

Holidays after (current year)+1?

Some religious holidays, especially Vesakha, are not determined yet. Joint leave days are also usually decreed by the government in as late as October/November in the preceding year.

How to calculate the difference of two dates in number of working days?

Use "count_idn_workdays".

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Calendar-Indonesia-Holiday.

SOURCE

Source repository is at https://github.com/perlancar/perl-Calendar-Indonesia-Holiday.

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTOR

Steven Haryanto <stevenharyanto@gmail.com>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar <perlancar@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Calendar-Indonesia-Holiday

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.