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

Added the syrian holidays #65

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
41 changes: 41 additions & 0 deletions src/Countries/Syria.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Syria extends Country
{
public function countryCode(): string
{
return 'sy';
}

protected function allHolidays(int $year): array
{
return array_merge([
'New Year\'s Day' => '01-01',
'Mother\'s Day' => '03-21',
'Independence Day' => '04-17',
'Labor' => '05-01',
'Martyrs\' Day' => '05-06',
'Anniversary of the October War' => '10-06',
'Christmas' => '12-25',

], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable|string> */
protected function variableHolidays(int $year): array
{
$easter = CarbonImmutable::createFromTimestamp(easter_date($year))
->setTimezone('Asia/Damascus');
amralsaleeh marked this conversation as resolved.
Show resolved Hide resolved

// TODO: Implement islamic holidays
amralsaleeh marked this conversation as resolved.
Show resolved Hide resolved

return [
'Western Easter' => $easter,
'Eastern Easter' => $easter->addDays(35),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"name": "New Year's Day",
"date": "2024-01-01"
},
{
"name": "Mother's Day",
"date": "2024-03-21"
},
{
"name": "Western Easter",
"date": "2024-03-31"
},
{
"name": "Independence Day",
"date": "2024-04-17"
},
{
"name": "Labor",
"date": "2024-05-01"
},
{
"name": "Eastern Easter",
"date": "2024-05-05"
},
{
"name": "Martyrs' Day",
"date": "2024-05-06"
},
{
"name": "Anniversary of the October War",
"date": "2024-10-06"
},
{
"name": "Christmas",
"date": "2024-12-25"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/SyriaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Spatie\Holidays\Tests\Countries;

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

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

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

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

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