Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(holiday): Utamaduni day renamed to Mazingira day #245

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/Countries/Kenya.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public function countryCode(): string
protected function allHolidays(int $year): array
{
return array_merge([
"New Year's" => '01-01',
'Labour' => '05-01',
'Madaraka' => '06-01',
'Utamaduni' => '10-10',
'Mashujaa' => '10-20',
'Jamhuri' => '12-01',
"New Year's Day" => '01-01',
'Labour day' => '05-01',
'Madaraka Day' => '06-01',
$this->getOctober10HolidayName($year) => '10-10',
'Mashujaa Day' => '10-20',
'Jamhuri Day' => '12-01',
'Christmas' => '12-25',
'Boxing' => '12-26',
'Boxing Day' => '12-26',
], $this->variableHolidays($year));
}

Expand All @@ -35,4 +35,15 @@ protected function variableHolidays(int $year): array
'Easter Monday' => $easter->addDay(),
];
}

/** @return string */
protected function getOctober10HolidayName(int $year): string
{
return match (true) {
$year >= 2024 => 'Mazingira Day',
$year >= 2022 => 'Utamaduni Day',
$year >= 2019 => 'Huduma Day',
default => 'Moi Day'
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "New Year's Day",
"date": "2021-01-01"
},
{
"name": "Good Friday",
"date": "2021-04-02"
},
{
"name": "Easter Monday",
"date": "2021-04-05"
},
{
"name": "Labour day",
"date": "2021-05-01"
},
{
"name": "Madaraka Day",
"date": "2021-06-01"
},
{
"name": "Huduma Day",
"date": "2021-10-10"
},
{
"name": "Mashujaa Day",
"date": "2021-10-20"
},
{
"name": "Jamhuri Day",
"date": "2021-12-01"
},
{
"name": "Christmas",
"date": "2021-12-25"
},
{
"name": "Boxing Day",
"date": "2021-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "New Year's Day",
"date": "2024-01-01"
},
{
"name": "Good Friday",
"date": "2024-03-29"
},
{
"name": "Easter Monday",
"date": "2024-04-01"
},
{
"name": "Labour day",
"date": "2024-05-01"
},
{
"name": "Madaraka Day",
"date": "2024-06-01"
},
{
"name": "Mazingira Day",
"date": "2024-10-10"
},
{
"name": "Mashujaa Day",
"date": "2024-10-20"
},
{
"name": "Jamhuri Day",
"date": "2024-12-01"
},
{
"name": "Christmas",
"date": "2024-12-25"
},
{
"name": "Boxing Day",
"date": "2024-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "New Year's Day",
"date": "2018-01-01"
},
{
"name": "Good Friday",
"date": "2018-03-30"
},
{
"name": "Easter Monday",
"date": "2018-04-02"
},
{
"name": "Labour day",
"date": "2018-05-01"
},
{
"name": "Madaraka Day",
"date": "2018-06-01"
},
{
"name": "Moi Day",
"date": "2018-10-10"
},
{
"name": "Mashujaa Day",
"date": "2018-10-20"
},
{
"name": "Jamhuri Day",
"date": "2018-12-01"
},
{
"name": "Christmas",
"date": "2018-12-25"
},
{
"name": "Boxing Day",
"date": "2018-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "New Year's Day",
"date": "2023-01-01"
},
{
"name": "Good Friday",
"date": "2023-04-07"
},
{
"name": "Easter Monday",
"date": "2023-04-10"
},
{
"name": "Labour day",
"date": "2023-05-01"
},
{
"name": "Madaraka Day",
"date": "2023-06-01"
},
{
"name": "Utamaduni Day",
"date": "2023-10-10"
},
{
"name": "Mashujaa Day",
"date": "2023-10-20"
},
{
"name": "Jamhuri Day",
"date": "2023-12-01"
},
{
"name": "Christmas",
"date": "2023-12-25"
},
{
"name": "Boxing Day",
"date": "2023-12-26"
}
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"name": "New Year's",
"name": "New Year's Day",
"date": "2024-01-01"
},
{
Expand All @@ -12,31 +12,31 @@
"date": "2024-04-01"
},
{
"name": "Labour",
"name": "Labour day",
"date": "2024-05-01"
},
{
"name": "Madaraka",
"name": "Madaraka Day",
"date": "2024-06-01"
},
{
"name": "Utamaduni",
"name": "Mazingira Day",
"date": "2024-10-10"
},
{
"name": "Mashujaa",
"name": "Mashujaa Day",
"date": "2024-10-20"
},
{
"name": "Jamhuri",
"name": "Jamhuri Day",
"date": "2024-12-01"
},
{
"name": "Christmas",
"date": "2024-12-25"
},
{
"name": "Boxing",
"name": "Boxing Day",
"date": "2024-12-26"
}
]
60 changes: 60 additions & 0 deletions tests/Countries/KenyaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,63 @@

expect(formatDates($holidays))->toMatchSnapshot();
});

it('calculates October 10th holiday as Mazingira Day in 2024', function () {
CarbonImmutable::setTestNow('2024-10-10');

$holidays = Holidays::for(country: 'ke')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(findDate($holidays, 'Mazingira Day'))
->toEqual(CarbonImmutable::create(2024, 10, 10));

expect(formatDates($holidays))->toMatchSnapshot();
});

it('calculates October 10th holiday as Utamaduni Day in 2023', function () {
CarbonImmutable::setTestNow('2023-10-10');

$holidays = Holidays::for(country: 'ke')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(findDate($holidays, 'Utamaduni Day'))
->toEqual(CarbonImmutable::create(2023, 10, 10));

expect(formatDates($holidays))->toMatchSnapshot();
});

it('calculates October 10th holiday as Huduma Day in 2021', function () {
CarbonImmutable::setTestNow('2021-10-10');

$holidays = Holidays::for(country: 'ke')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(findDate($holidays, 'Huduma Day'))
->toEqual(CarbonImmutable::create(2021, 10, 10));

expect(formatDates($holidays))->toMatchSnapshot();
});

it('calculates October 10th holiday as Moi Day before 2019', function () {
CarbonImmutable::setTestNow('2018-10-10');

$holidays = Holidays::for(country: 'ke')->get();

expect($holidays)
->toBeArray()
->not()->toBeEmpty();

expect(findDate($holidays, 'Moi Day'))
->toEqual(CarbonImmutable::create(2018, 10, 10));

expect(formatDates($holidays))->toMatchSnapshot();
});