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

[feat] implement iran holidays #128

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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/Iran.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class Iran extends Country
{
public function countryCode(): string
{
return 'ir';
}

/** @return array<string, CarbonImmutable> */
aryala7 marked this conversation as resolved.
Show resolved Hide resolved
protected function allHolidays(int $year): array
{
return array_merge([
'Islamic Revolution Day' => '02-11',
'Nourouz' => '03-19',
aryala7 marked this conversation as resolved.
Show resolved Hide resolved
'National Oil Industry Day' => '03-20',
'Nourouz' => '03-21',
'Nourouz' => '03-22',
'Nourouz' => '03-23',
'Islamic Republic Day' => '03-31',
'Nature Day' => '04-01',
'Death of Khomeini' => '04-06',
'15th Khordad March' => '04-07',
aryala7 marked this conversation as resolved.
Show resolved Hide resolved
], $this->variableHolidays($year));
}

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

return [
//add more holidays
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"name": "Islamic Revolution Day",
"date": "2024-02-11"
},
{
"name": "National Oil Industry Day",
"date": "2024-03-20"
},
{
"name": "Nourouz",
"date": "2024-03-23"
aryala7 marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "Islamic Republic Day",
"date": "2024-03-31"
},
{
"name": "Nature Day",
"date": "2024-04-01"
},
{
"name": "Death of Khomeini",
"date": "2024-04-06"
},
{
"name": "15th Khordad March",
"date": "2024-04-07"
}
]
18 changes: 18 additions & 0 deletions tests/Countries/IranTest.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 iran holidays', function () {
CarbonImmutable::setTestNowAndTimezone('2024-01-01');
aryala7 marked this conversation as resolved.
Show resolved Hide resolved

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

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

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