Skip to content

Commit

Permalink
refactor CNY and Aidilfitri holiday function
Browse files Browse the repository at this point in the history
  • Loading branch information
pisyek committed Feb 2, 2024
1 parent 698a1c2 commit 7f02190
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Countries/Malaysia.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ 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->islamicCalendar('01/10', $year),
'Hari Raya Aidilfitri Hari Kedua' => $this->islamicCalendar('02/10', $year),
'Tahun Baru Cina' => $this->lunarNewYear($year),
'Tahun Baru Cina Hari Kedua' => $this->lunarNewYear($year)->addDays(1),
'Hari Raya Aidilfitri' => $this->hariAidilfitri($year),
'Hari Raya Aidilfitri Hari Kedua' => $this->hariAidilfitri($year)->addDays(1),
'Hari Wesak' => $this->hariWesak($year),
'Hari Raya Aidiladha' => $this->hariAidiladha($year),
'Awal Muharram' => $this->awalMuharram($year),
Expand Down Expand Up @@ -417,6 +417,11 @@ private function newYear(): string
return '01-01';
}

private function lunarNewYear(int $year): CarbonImmutable
{
return $this->chineseToGregorianDate('01-01', $year);
}

protected function getIslamicFormatter(): IntlDateFormatter
{
return new IntlDateFormatter(
Expand Down Expand Up @@ -453,6 +458,11 @@ protected function islamicCalendar(string $input, int $year, bool $nextYear = fa
return CarbonImmutable::createFromTimestamp($timeStamp, $this->timezone);
}

protected function hariAidilfitri(int $year): CarbonImmutable
{
return $this->islamicCalendar('01/10', $year);
}

protected function hariWilayah(int $year): CarbonImmutable
{
return CarbonImmutable::createFromDate($year, 2, 1, $this->timezone);
Expand Down

0 comments on commit 7f02190

Please sign in to comment.