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 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
23 changes: 23 additions & 0 deletions lang/egypt/ar/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"New Year\n's Day": "يوم رأس السنة",
"Coptic Christmas": "عيد الميلاد القبطي",
"Revolution Day January 25": "عيد ثورة 25 يناير",
"March Equinox": "اعتدال مارس",
"Sinai Liberation": "تحرير سيناء",
"Labor": "العمل",
"Coptic Good": "الصالح القبطي",
"Coptic Holy": "المقدس القبطي",
"Coptic Easter": "عيد الفصح القبطي",
"Spring Festival": "مهرجان الربيع",
"June Solstice": "انقلاب يونيو",
"June 30 Revolution": "ثورة 30 يونيو",
"Day off for June 30 Revolution": "يوم عطلة بمناسبة ثورة 30 يونيو",
"Revolution Day July 23": "عيد ثورة 23 يوليو",
"Day off for Revolution Day July 23": "يوم عطلة بمناسبة عيد ثورة 23 يوليو",
"Flooding of the Nile": "فيضان النيل",
"Nayrouz": "النيروز",
"September Equinox": "الاعتدال في سبتمبر",
"Armed Forces": "القوات المسلحة",
"Day off for Armed Forces": "يوم عطلة للقوات المسلحة",
"December Solstice": "الانقلاب الشمسي في ديسمبر"
}
47 changes: 47 additions & 0 deletions src/Countries/Egypt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

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

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
{
// The variable holidays all follow the lunar calendar, so their dates are not confirmed.
return [];
}
}
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();
});