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

Add Egypt Holidays #35

Merged
merged 8 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
49 changes: 49 additions & 0 deletions src/Countries/Egypt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Egypt extends Country
{
public function countryCode(): string
{
return 'eg';
}

/** @return array<string, string|CarbonImmutable> */
michaelnabil230 marked this conversation as resolved.
Show resolved Hide resolved
protected function allHolidays(int $year): array
{
return array_merge([
'New Year\'s Day' => '01-01',
michaelnabil230 marked this conversation as resolved.
Show resolved Hide resolved
'Coptic Christmas' => '01-07',
'Revolution Day January 25' => '01-25',
'March Equinox' => '03-20',
'Sinai Liberation' => '04-25',
'Labor' => '05-01',
'Coptic Good' => '05-03',
'Coptic Holy' => '05-04',
'Coptic Easter' => '05-05',
'Spring Festival' => '05-06',
'June Solstice' => '06-20',
'June 30 Revolution' => '06-30',
'Day off for June 30 Revolution' => '07-04',
'Revolution Day July 23' => '07-23',
'Day off for Revolution Day July 23' => '07-25',
'Flooding of the Nile' => '08-15',
'Nayrouz' => '09-11',
'September Equinox' => '09-22',
'Armed Forces' => '10-06',
'Day off for Armed Forces' => '10-10',
'December Solstice' => '12-21',
], $this->variableHolidays($year));
}

/** @return array<string, string|CarbonImmutable> */
protected function variableHolidays(int $year): array
{
return [
// TODO: Add more holidays
michaelnabil230 marked this conversation as resolved.
Show resolved Hide resolved
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"name": "New Year's Day",
"date": "2024-01-01"
},
{
"name": "Coptic Christmas",
"date": "2024-01-07"
},
{
"name": "Revolution Day January 25",
"date": "2024-01-25"
},
{
"name": "March Equinox",
"date": "2024-03-20"
},
{
"name": "Sinai Liberation",
"date": "2024-04-25"
},
{
"name": "Labor",
"date": "2024-05-01"
},
{
"name": "Coptic Good",
"date": "2024-05-03"
},
{
"name": "Coptic Holy",
"date": "2024-05-04"
},
{
"name": "Coptic Easter",
"date": "2024-05-05"
},
{
"name": "Spring Festival",
"date": "2024-05-06"
},
{
"name": "June Solstice",
"date": "2024-06-20"
},
{
"name": "June 30 Revolution",
"date": "2024-06-30"
},
{
"name": "Day off for June 30 Revolution",
"date": "2024-07-04"
},
{
"name": "Revolution Day July 23",
"date": "2024-07-23"
},
{
"name": "Day off for Revolution Day July 23",
"date": "2024-07-25"
},
{
"name": "Flooding of the Nile",
"date": "2024-08-15"
},
{
"name": "Nayrouz",
"date": "2024-09-11"
},
{
"name": "September Equinox",
"date": "2024-09-22"
},
{
"name": "Armed Forces",
"date": "2024-10-06"
},
{
"name": "Day off for Armed Forces",
"date": "2024-10-10"
},
{
"name": "December Solstice",
"date": "2024-12-21"
}
]
17 changes: 17 additions & 0 deletions tests/Countries/EgyptTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

use Carbon\CarbonImmutable;
use Spatie\Holidays\Holidays;

it('can calculate egypt holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');

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

expect($holidays)
->toBeArray()
->not()->toBeEmpty()
->and(formatDates($holidays))->toMatchSnapshot();
});
Loading