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 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
38 changes: 38 additions & 0 deletions src/Countries/Iran.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

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

protected function allHolidays(int $year): array
{
return array_merge([
'Islamic Revolution Day' => '02-11',
'Nationalization of Oil Industry Day' => '03-19',
'Nowruz First Day' => '03-20',
'Nowruz Second Day' => '03-21',
'Nowruz Third Day' => '03-22',
'Nowruz Fourth Day' => '03-23',
'Islamic Republic Day' => '03-31',
'Nature Day' => '04-01',
'Death of Khomeini Day' => '06-03',
'Revolt of Khordad 15 Day' => '06-04',
], $this->variableHolidays($year));
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
{

return [
//add more holidays
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which ones are missing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nielsvanpach Currently, Islamic holidays cannot be added because they are not fixed every year.For example, some holidays may occur 1 or 2 days earlier or later with the sighting of the moon

];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "Islamic Revolution Day",
"date": "2024-02-11"
},
{
"name": "Nationalization of Oil Industry Day",
"date": "2024-03-19"
},
{
"name": "Nowruz First Day",
"date": "2024-03-20"
},
{
"name": "Nowruz Second Day",
"date": "2024-03-21"
},
{
"name": "Nowruz Third Day",
"date": "2024-03-22"
},
{
"name": "Nowruz Fourth Day",
"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 Day",
"date": "2024-06-03"
},
{
"name": "Revolt of Khordad 15 Day",
"date": "2024-06-04"
}
]
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::setTestNow('2024-01-01');

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

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

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