diff --git a/src/Calendars/IslamicCalendar.php b/src/Calendars/IslamicCalendar.php index 33b6be64f..bcda47412 100644 --- a/src/Calendars/IslamicCalendar.php +++ b/src/Calendars/IslamicCalendar.php @@ -2,8 +2,12 @@ namespace Spatie\Holidays\Calendars; -use Carbon\CarbonImmutable; +use DateTime; +use DateTimeZone; +use IntlCalendar; +use IntlDateFormatter; use Carbon\CarbonPeriod; +use Carbon\CarbonImmutable; use Carbon\Exceptions\InvalidFormatException; use Spatie\Holidays\Countries\Country; use Spatie\Holidays\Exceptions\InvalidYear; @@ -11,6 +15,8 @@ /** @mixin Country */ trait IslamicCalendar { + protected string $islamicCalendarTimezone = 'UTC'; + /** @return array */ public function eidAlFitr(int $year, int $totalDays = 3): array { @@ -138,4 +144,47 @@ protected function getOverlapping(array $collection, int $year, int $totalDays): return null; } + + public function setIslamicCalendarTimezone(string $islamicCalendarTimezone): static + { + $this->islamicCalendarTimezone = $islamicCalendarTimezone; + + return $this; + } + + protected function getIslamicCalendarFormatter(): IntlDateFormatter + { + return new IntlDateFormatter( + 'en_US@calendar=islamic-civil', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'UTC', + IntlDateFormatter::TRADITIONAL, + 'yyyy-MM-dd' + ); + } + + protected function getHijriYear(int $year, bool $nextYear = false): int + { + $formatter = $this->getIslamicCalendarFormatter(); + $formatter->setPattern('yyyy'); + $dateTime = DateTime::createFromFormat('d/m/Y', '01/01/' . ($nextYear ? $year + 1 : $year)); + + if (!$dateTime) { + throw InvalidYear::invalidHijriYear(); + } + + return (int) $formatter->format($dateTime->getTimestamp()); + } + + protected function islamicToGregorianDate(string $input, int $year, bool $nextYear = false): CarbonImmutable + { + $hijriYear = $this->getHijriYear(year: $year, nextYear: $nextYear); + $formatter = $this->getIslamicCalendarFormatter(); + $timestamp = (int) $formatter->parse(sprintf('%s-%s', $hijriYear, $input)); + + return (new CarbonImmutable()) + ->setTimeStamp($timestamp) + ->setTimezone(new DateTimeZone($this->islamicCalendarTimezone)); + } } diff --git a/src/Countries/Malaysia.php b/src/Countries/Malaysia.php new file mode 100644 index 000000000..25779fb3a --- /dev/null +++ b/src/Countries/Malaysia.php @@ -0,0 +1,439 @@ + $regions */ + protected array $regions = [ + 'jhr', + 'kdh', + 'ktn', + 'kul', + 'lbn', + 'mlk', + 'nsn', + 'phg', + 'png', + 'prk', + 'pls', + 'pjy', + 'sbh', + 'swk', + 'sgr', + 'trg', + ]; + + protected function __construct( + protected ?string $region = null, + ) { + } + + public function countryCode(): string + { + return 'my'; + } + + protected function allHolidays(int $year): array + { + return array_merge([ + 'Hari Pekerja' => '05-01', + 'Hari Kebangsaan' => '08-31', + 'Hari Malaysia' => '09-16', + 'Hari Krismas' => '12-25', + ], $this->variableHolidays($year), $this->regionHolidays($year)); + } + + /** + * @return array + */ + protected function variableHolidays(int $year): array + { + $this->setChineseCalendarTimezone($this->timezone); + + $variableHolidays = [ + 'Tahun Baru Cina' => $this->chineseToGregorianDate('01-01', $year), + 'Tahun Baru Cina Hari Kedua' => $this->chineseToGregorianDate('01-02', $year), + 'Hari Raya Aidilfitri' => $this->islamicToGregorianDate('10-01', $year), + 'Hari Raya Aidilfitri Hari Kedua' => $this->islamicToGregorianDate('10-02', $year), + 'Hari Wesak' => '01-01', + 'Hari Raya Aidiladha' => $this->islamicToGregorianDate('12-10', $year), + 'Awal Muharram' => $this->islamicToGregorianDate('01-01', $year, true), + 'Maulidur Rasul' => $this->islamicToGregorianDate('03-12', $year, true), + ]; + + if ($this->hariKeputeraanYDP($year)) { + $variableHolidays['Hari Keputeraan Yang Di-Pertuan Agong'] = $this->hariKeputeraanYDP($year); + } + + return $variableHolidays; + } + + /** + * @return array + */ + protected function regionHolidays(int $year): array + { + if ($this->region && !$this->validRegion($this->region)) { + throw InvalidRegion::notFound($this->region); + } + + return $this->holidaysByRegion($year); + } + + protected function validRegion(string $region): bool + { + return in_array($region, $this->regions); + } + + /** + * return holiday by region, if not set return all + * + * @return array + */ + protected function holidaysByRegion(int $year): array + { + return match ($this->region) { + 'jhr' => $this->regionJohor($year), + 'kdh' => $this->regionKedah($year), + 'ktn' => $this->regionKelantan($year), + 'kul' => $this->regionKualaLumpur($year), + 'lbn' => $this->regionLabuan($year), + 'mlk' => $this->regionMelaka($year), + 'nsn' => $this->regionNegeri9($year), + 'phg' => $this->regionPahang($year), + 'png' => $this->regionPenang($year), + 'prk' => $this->regionPerak($year), + 'pls' => $this->regionPerlis($year), + 'pjy' => $this->regionPutrajaya($year), + 'sbh' => $this->regionSabah($year), + 'swk' => $this->regionSarawak($year), + 'sgr' => $this->regionSelangor($year), + 'trg' => $this->regionTerengganu($year), + default => array_merge( + $this->regionJohor($year), + $this->regionKedah($year), + $this->regionKelantan($year), + $this->regionKualaLumpur($year), + $this->regionLabuan($year), + $this->regionMelaka($year), + $this->regionNegeri9($year), + $this->regionPahang($year), + $this->regionPenang($year), + $this->regionPerak($year), + $this->regionPerlis($year), + $this->regionPutrajaya($year), + $this->regionSabah($year), + $this->regionSarawak($year), + $this->regionSelangor($year), + $this->regionTerengganu($year), + ), + }; + } + + /** + * @return array + */ + protected function regionJohor(int $year): array + { + $johorHolidays = [ + 'Hari Keputeraan Sultan Johor' => '03-23', + 'Hari Thaipusam' => '01-01', + 'Awal Ramadan' => $this->islamicToGregorianDate('09-01', $year), + 'Hari Deepavali' => '01-01', + ]; + + $hariHolJohor = match ($year) { + 2020 => CarbonImmutable::createFromDate($year, 9, 24), + 2021 => CarbonImmutable::createFromDate($year, 9, 13), + 2022 => CarbonImmutable::createFromDate($year, 9, 3), + 2023 => CarbonImmutable::createFromDate($year, 8, 23), + 2024 => CarbonImmutable::createFromDate($year, 8, 11), + 2025 => CarbonImmutable::createFromDate($year, 7, 31), + 2026 => CarbonImmutable::createFromDate($year, 7, 21), + default => null, + }; + + if ($hariHolJohor) { + $johorHolidays['Hari Hol Johor'] = $hariHolJohor; + } + + return $johorHolidays; + } + + /** + * @return array + */ + protected function regionKedah(int $year): array + { + return [ + 'Hari Thaipusam' => '01-01', + 'Israk dan Mikraj' => $this->islamicToGregorianDate('07-27', $year), + 'Awal Ramadan' => $this->islamicToGregorianDate('09-01', $year), + 'Hari Keputeraan Sultan Kedah' => CarbonImmutable::parse("third sunday of june {$year}"), + 'Hari Raya Aidiladha Hari Kedua' => $this->islamicToGregorianDate('12-11', $year), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionKelantan(int $year): array + { + $kelantanHolidays = [ + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Arafah' => $this->islamicToGregorianDate('12-09', $year), + 'Hari Raya Aidiladha Hari Kedua' => $this->islamicToGregorianDate('12-11', $year), + 'Hari Deepavali' => '01-01', + ]; + + $kingBirthday = match (true) { + in_array($year, range(2010, 2022)) => CarbonImmutable::createFromDate($year, 11, 11), + in_array($year, range(2023, 2026)) => CarbonImmutable::createFromDate($year, 9, 29), + default => null, + + }; + + if ($kingBirthday) { + $kelantanHolidays['Hari Keputeraan Sultan Kelantan'] = $kingBirthday; + } + + $kingBirthdaySecondDay = match (true) { + in_array($year, range(2010, 2022)) => CarbonImmutable::createFromDate($year, 11, 12), + in_array($year, range(2023, 2026)) => CarbonImmutable::createFromDate($year, 9, 30), + default => null, + }; + + if ($kingBirthdaySecondDay) { + $kelantanHolidays['Hari Keputeraan Sultan Kelantan Hari Kedua'] = $kingBirthdaySecondDay; + } + + return $kelantanHolidays; + } + + /** + * @return array + */ + protected function regionKualaLumpur(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Thaipusam' => '01-01', + 'Hari Wilayah Persekutuan' => $this->hariWilayah($year), + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionLabuan(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Wilayah Persekutuan' => $this->hariWilayah($year), + 'Pesta Kaamatan' => $this->pestaKaamatan($year), + 'Pesta Kaamatan Hari Kedua' => $this->pestaKaamatan($year)->addDay(), + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionMelaka(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Awal Ramadan' => $this->islamicToGregorianDate('09-01', $year), + 'Hari Perisytiharan Melaka Sebagai Bandaraya Bersejarah' => CarbonImmutable::createFromDate($year, 4, 15), + 'Harijadi Yang di-Pertua Negeri Melaka' => CarbonImmutable::createFromDate($year, 8, 24), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionNegeri9(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Thaipusam' => '01-01', + 'Israk dan Mikraj' => $this->islamicToGregorianDate('07-27', $year), + 'Hari Keputeraan Yang Di-Pertuan Besar Negeri Sembilan' => CarbonImmutable::createFromDate($year, 1, 14), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionPahang(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Hol Pahang' => CarbonImmutable::createFromDate($year, 5, 22), + 'Hari Keputeraan Sultan Pahang' => CarbonImmutable::createFromDate($year, 7, 30), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionPenang(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Thaipusam' => '01-01', + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Bandar Warisan Dunia Georgetown' => CarbonImmutable::createFromDate($year, 7, 7), + 'Harijadi Yang di-Pertua Negeri Pulau Pinang' => CarbonImmutable::parse("second saturday of july {$year}"), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionPerak(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Thaipusam' => '01-01', + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Keputeraan Sultan Perak' => CarbonImmutable::parse("first friday of november {$year}"), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionPerlis(int $year): array + { + return [ + 'Israk dan Mikraj' => $this->islamicToGregorianDate('07-27', $year), + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Keputeraan Raja Perlis' => CarbonImmutable::createFromDate($year, 5, 17), + 'Hari Raya Aidiladha Hari Kedua' => $this->islamicToGregorianDate('12-11', $year), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionPutrajaya(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Thaipusam' => '01-01', + 'Hari Wilayah Persekutuan' => $this->hariWilayah($year), + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Deepavali' => '01-01', + ]; + } + + /** + * @return array + */ + protected function regionSabah(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Pesta Kaamatan' => $this->pestaKaamatan($year), + 'Pesta Kaamatan Hari Kedua' => $this->pestaKaamatan($year)->addDays(1), + 'Good Friday' => $this->goodFriday($year), + 'Harijadi Yang di-Pertua Negeri Sabah' => CarbonImmutable::parse("first saturday of october {$year}"), + 'Hari Deepavali' => '01-01', + 'Hari Natal' => CarbonImmutable::createFromDate($year, 12, 24), + ]; + } + + /** + * @return array + */ + protected function regionSarawak(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Sarawak' => CarbonImmutable::createFromDate($year, 7, 22), + 'Hari Gawai' => CarbonImmutable::createFromDate($year, 6, 1), + 'Hari Gawai Kedua' => CarbonImmutable::createFromDate($year, 6, 2), + 'Harijadi Yang di-Pertua Negeri Sarawak' => CarbonImmutable::parse("second saturday of october {$year}"), + 'Good Friday' => $this->goodFriday($year), + ]; + } + + /** + * @return array + */ + protected function regionSelangor(int $year): array + { + return [ + 'Tahun Baru' => '01-01', + 'Hari Thaipusam' => '01-01', + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Deepavali' => '01-01', + 'Hari Keputeraan Sultan Selangor' => CarbonImmutable::createFromDate($year, 12, 11), + ]; + } + + /** + * @return array + */ + protected function regionTerengganu(int $year): array + { + return [ + 'Israk dan Mikraj' => $this->islamicToGregorianDate('07-27', $year), + 'Hari Ulang Tahun Pertabalan Sultan Terengganu' => CarbonImmutable::createFromDate($year, 3, 4), + 'Hari Nurul Al-Quran' => $this->islamicToGregorianDate('09-17', $year), + 'Hari Keputeraan Sultan Terengganu' => CarbonImmutable::createFromDate($year, 4, 26), + 'Hari Arafah' => $this->islamicToGregorianDate('12-09', $year), + 'Hari Raya Aidiladha Hari Kedua' => $this->islamicToGregorianDate('12-11', $year), + 'Hari Deepavali' => '01-01', + ]; + } + + protected function hariWilayah(int $year): CarbonImmutable + { + return CarbonImmutable::createFromDate($year, 2, 1); + } + + protected function pestaKaamatan(int $year): CarbonImmutable + { + return CarbonImmutable::createFromDate($year, 5, 30); + } + + protected function goodFriday(int $year): CarbonImmutable + { + $easter = $this->easter($year); + + return $easter->subDays(2); + } + + protected function hariKeputeraanYDP(int $year): ?CarbonImmutable + { + return match (true) { + in_array($year, range(2001, 2026)) => CarbonImmutable::parse("first saturday of october {$year}"), + default => null, + }; + } +} diff --git a/src/Exceptions/InvalidYear.php b/src/Exceptions/InvalidYear.php index 13fd335ad..9760c41cd 100644 --- a/src/Exceptions/InvalidYear.php +++ b/src/Exceptions/InvalidYear.php @@ -20,4 +20,9 @@ public static function range(string $country, int $start, int $end): self { return new self("Only years between {$start} and {$end} are supported for {$country}."); } + + public static function invalidHijriYear(): self + { + return new self('Unable to get the Hijri year.'); + } } diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_Malaysia_holidays.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_Malaysia_holidays.snap new file mode 100644 index 000000000..7efe998eb --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_Malaysia_holidays.snap @@ -0,0 +1,194 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Besar Negeri Sembilan", + "date": "2024-01-14" + }, + { + "name": "Hari Wilayah Persekutuan", + "date": "2024-02-01" + }, + { + "name": "Israk dan Mikraj", + "date": "2024-02-07" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Ulang Tahun Pertabalan Sultan Terengganu", + "date": "2024-03-04" + }, + { + "name": "Awal Ramadan", + "date": "2024-03-11" + }, + { + "name": "Hari Keputeraan Sultan Johor", + "date": "2024-03-23" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Perisytiharan Melaka Sebagai Bandaraya Bersejarah", + "date": "2024-04-15" + }, + { + "name": "Hari Keputeraan Sultan Terengganu", + "date": "2024-04-26" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Keputeraan Raja Perlis", + "date": "2024-05-17" + }, + { + "name": "Hari Hol Pahang", + "date": "2024-05-22" + }, + { + "name": "Pesta Kaamatan", + "date": "2024-05-30" + }, + { + "name": "Pesta Kaamatan Hari Kedua", + "date": "2024-05-31" + }, + { + "name": "Hari Gawai", + "date": "2024-06-01" + }, + { + "name": "Hari Gawai Kedua", + "date": "2024-06-02" + }, + { + "name": "Hari Keputeraan Sultan Kedah", + "date": "2024-06-16" + }, + { + "name": "Hari Arafah", + "date": "2024-06-16" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Hari Raya Aidiladha Hari Kedua", + "date": "2024-06-18" + }, + { + "name": "Hari Bandar Warisan Dunia Georgetown", + "date": "2024-07-07" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Pulau Pinang", + "date": "2024-07-13" + }, + { + "name": "Hari Sarawak", + "date": "2024-07-22" + }, + { + "name": "Hari Keputeraan Sultan Pahang", + "date": "2024-07-30" + }, + { + "name": "Hari Hol Johor", + "date": "2024-08-11" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Melaka", + "date": "2024-08-24" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Sultan Kelantan", + "date": "2024-09-29" + }, + { + "name": "Hari Keputeraan Sultan Kelantan Hari Kedua", + "date": "2024-09-30" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Sabah", + "date": "2024-10-05" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Sarawak", + "date": "2024-10-12" + }, + { + "name": "Hari Keputeraan Sultan Perak", + "date": "2024-11-01" + }, + { + "name": "Hari Keputeraan Sultan Selangor", + "date": "2024-12-11" + }, + { + "name": "Hari Natal", + "date": "2024-12-24" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____jhr___18_____jhr___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____jhr___18_____jhr___18_.snap new file mode 100644 index 000000000..c074f8649 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____jhr___18_____jhr___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Awal Ramadan", + "date": "2024-03-11" + }, + { + "name": "Hari Keputeraan Sultan Johor", + "date": "2024-03-23" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Hol Johor", + "date": "2024-08-11" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____kdh___19_____kdh___19_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____kdh___19_____kdh___19_.snap new file mode 100644 index 000000000..ac9344582 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____kdh___19_____kdh___19_.snap @@ -0,0 +1,78 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Israk dan Mikraj", + "date": "2024-02-07" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Awal Ramadan", + "date": "2024-03-11" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Keputeraan Sultan Kedah", + "date": "2024-06-16" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Hari Raya Aidiladha Hari Kedua", + "date": "2024-06-18" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____ktn___19_____ktn___19_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____ktn___19_____ktn___19_.snap new file mode 100644 index 000000000..1ec56d1e4 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____ktn___19_____ktn___19_.snap @@ -0,0 +1,78 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Arafah", + "date": "2024-06-16" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Hari Raya Aidiladha Hari Kedua", + "date": "2024-06-18" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Sultan Kelantan", + "date": "2024-09-29" + }, + { + "name": "Hari Keputeraan Sultan Kelantan Hari Kedua", + "date": "2024-09-30" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____kul___18_____kul___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____kul___18_____kul___18_.snap new file mode 100644 index 000000000..5d46c6579 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____kul___18_____kul___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Hari Wilayah Persekutuan", + "date": "2024-02-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____lbn___19_____lbn___19_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____lbn___19_____lbn___19_.snap new file mode 100644 index 000000000..451be4205 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____lbn___19_____lbn___19_.snap @@ -0,0 +1,78 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Hari Wilayah Persekutuan", + "date": "2024-02-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Pesta Kaamatan", + "date": "2024-05-30" + }, + { + "name": "Pesta Kaamatan Hari Kedua", + "date": "2024-05-31" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____mlk___18_____mlk___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____mlk___18_____mlk___18_.snap new file mode 100644 index 000000000..95481d83a --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____mlk___18_____mlk___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Awal Ramadan", + "date": "2024-03-11" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Perisytiharan Melaka Sebagai Bandaraya Bersejarah", + "date": "2024-04-15" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Melaka", + "date": "2024-08-24" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____nsn___18_____nsn___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____nsn___18_____nsn___18_.snap new file mode 100644 index 000000000..58466ece3 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____nsn___18_____nsn___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Besar Negeri Sembilan", + "date": "2024-01-14" + }, + { + "name": "Israk dan Mikraj", + "date": "2024-02-07" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____phg___18_____phg___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____phg___18_____phg___18_.snap new file mode 100644 index 000000000..8113ddb81 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____phg___18_____phg___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Hol Pahang", + "date": "2024-05-22" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Keputeraan Sultan Pahang", + "date": "2024-07-30" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____pjy___18_____pjy___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____pjy___18_____pjy___18_.snap new file mode 100644 index 000000000..5d46c6579 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____pjy___18_____pjy___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Hari Wilayah Persekutuan", + "date": "2024-02-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____pls___18_____pls___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____pls___18_____pls___18_.snap new file mode 100644 index 000000000..edac07a13 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____pls___18_____pls___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Israk dan Mikraj", + "date": "2024-02-07" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Keputeraan Raja Perlis", + "date": "2024-05-17" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Hari Raya Aidiladha Hari Kedua", + "date": "2024-06-18" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____png___19_____png___19_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____png___19_____png___19_.snap new file mode 100644 index 000000000..5e9afe375 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____png___19_____png___19_.snap @@ -0,0 +1,78 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Hari Bandar Warisan Dunia Georgetown", + "date": "2024-07-07" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Pulau Pinang", + "date": "2024-07-13" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____prk___18_____prk___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____prk___18_____prk___18_.snap new file mode 100644 index 000000000..08a427c6d --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____prk___18_____prk___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Keputeraan Sultan Perak", + "date": "2024-11-01" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____sbh___20_____sbh___20_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____sbh___20_____sbh___20_.snap new file mode 100644 index 000000000..2c13e1b00 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____sbh___20_____sbh___20_.snap @@ -0,0 +1,82 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Pesta Kaamatan", + "date": "2024-05-30" + }, + { + "name": "Pesta Kaamatan Hari Kedua", + "date": "2024-05-31" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Sabah", + "date": "2024-10-05" + }, + { + "name": "Hari Natal", + "date": "2024-12-24" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____sgr___18_____sgr___18_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____sgr___18_____sgr___18_.snap new file mode 100644 index 000000000..cbcd01511 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____sgr___18_____sgr___18_.snap @@ -0,0 +1,74 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Hari Thaipusam", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Keputeraan Sultan Selangor", + "date": "2024-12-11" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____swk___19_____swk___19_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____swk___19_____swk___19_.snap new file mode 100644 index 000000000..04678ca20 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____swk___19_____swk___19_.snap @@ -0,0 +1,78 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru", + "date": "2024-01-01" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Gawai", + "date": "2024-06-01" + }, + { + "name": "Hari Gawai Kedua", + "date": "2024-06-02" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Sarawak", + "date": "2024-07-22" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Harijadi Yang di-Pertua Negeri Sarawak", + "date": "2024-10-12" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____trg___20_____trg___20_.snap b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____trg___20_____trg___20_.snap new file mode 100644 index 000000000..1d774b431 --- /dev/null +++ b/tests/.pest/snapshots/Countries/MalaysiaTest/it_can_calculate_total_holidays_by_regions_with_data_set____trg___20_____trg___20_.snap @@ -0,0 +1,82 @@ +[ + { + "name": "Hari Wesak", + "date": "2024-01-01" + }, + { + "name": "Hari Deepavali", + "date": "2024-01-01" + }, + { + "name": "Israk dan Mikraj", + "date": "2024-02-07" + }, + { + "name": "Tahun Baru Cina", + "date": "2024-02-10" + }, + { + "name": "Tahun Baru Cina Hari Kedua", + "date": "2024-02-11" + }, + { + "name": "Hari Ulang Tahun Pertabalan Sultan Terengganu", + "date": "2024-03-04" + }, + { + "name": "Hari Nurul Al-Quran", + "date": "2024-03-27" + }, + { + "name": "Hari Raya Aidilfitri", + "date": "2024-04-10" + }, + { + "name": "Hari Raya Aidilfitri Hari Kedua", + "date": "2024-04-11" + }, + { + "name": "Hari Keputeraan Sultan Terengganu", + "date": "2024-04-26" + }, + { + "name": "Hari Pekerja", + "date": "2024-05-01" + }, + { + "name": "Hari Arafah", + "date": "2024-06-16" + }, + { + "name": "Hari Raya Aidiladha", + "date": "2024-06-17" + }, + { + "name": "Hari Raya Aidiladha Hari Kedua", + "date": "2024-06-18" + }, + { + "name": "Awal Muharram", + "date": "2024-07-08" + }, + { + "name": "Hari Kebangsaan", + "date": "2024-08-31" + }, + { + "name": "Hari Malaysia", + "date": "2024-09-16" + }, + { + "name": "Maulidur Rasul", + "date": "2024-09-16" + }, + { + "name": "Hari Keputeraan Yang Di-Pertuan Agong", + "date": "2024-10-05" + }, + { + "name": "Hari Krismas", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/MalaysiaTest.php b/tests/Countries/MalaysiaTest.php new file mode 100644 index 000000000..09be119d6 --- /dev/null +++ b/tests/Countries/MalaysiaTest.php @@ -0,0 +1,40 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); + +it('can calculate Hari Raya is in year 2023', function () { + CarbonImmutable::setTestNow('2023-01-01'); + + $holiday = Holidays::for('my')->isHoliday('2023-04-22'); + + expect($holiday)->toBeTrue(); +}); + +it('can calculate Tahun Baru Cina in year 2023', function () { + CarbonImmutable::setTestNow('2023-01-01'); + + $holiday = Holidays::for('my')->isHoliday('2023-01-22'); + + expect($holiday)->toBeTrue(); +}); + +it('cannot calculate invalid region', function () { + $holiday = Holidays::for(Malaysia::make('invalid-region'))->get(); +})->throws(InvalidRegion::class);