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 National and Revolutionary Iran Holidays #146

Merged
merged 5 commits into from
Feb 1, 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
12 changes: 12 additions & 0 deletions lang/Iran/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"پیروزی انقلاب اسلامی پنجاه و هفت": "Anniversary of Islamic Revolution Day",
"روز ملی شدن صنعت نفت": "Nationalization of Oil Industry Day",
"نخستین روز نوروز": "Nowruz First Day",
"دومین روز نوروز": "Nowruz Second Day",
"سومین روز نوروز": "Nowruz Third Day",
"چهارمین روز نوروز": "Nowruz Fourth Day",
"روز جمهوری اسلامی": "Islamic Republic Day",
"سیزده بدر": "Sizdah Bedar",
"رحلت روح\u200Cالله خمینی": "Death of Khomeini Day",
"قیام ۱۵ خرداد": "Revolt of Khordad 15 Day"
}
12 changes: 12 additions & 0 deletions lang/Iran/fa/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"پیروزی انقلاب اسلامی پنجاه و هفت": "پیروزی انقلاب اسلامی پنجاه و هفت",
"روز ملی شدن صنعت نفت": "روز ملی شدن صنعت نفت",
"نخستین روز نوروز": "نخستین روز نوروز",
"دومین روز نوروز": "دومین روز نوروز",
"سومین روز نوروز": "سومین روز نوروز",
"چهارمین روز نوروز": "چهارمین روز نوروز",
"روز جمهوری اسلامی": "روز جمهوری اسلامی",
"سیزده بدر": "سیزده بدر",
"رحلت روح\u200Cالله خمینی": "رحلت روح\u200Cالله خمینی",
"قیام ۱۵ خرداد": "قیام ۱۵ خرداد"
}
29 changes: 29 additions & 0 deletions src/Countries/Iran.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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 [
'پیروزی انقلاب اسلامی پنجاه و هفت' => '02-11',
'روز ملی شدن صنعت نفت' => '03-19',
'نخستین روز نوروز' => '03-20',
'دومین روز نوروز' => '03-21',
'سومین روز نوروز' => '03-22',
'چهارمین روز نوروز' => '03-23',
'روز جمهوری اسلامی' => '03-31',
'سیزده بدر' => '04-01',
'رحلت روح‌الله خمینی' => '06-03',
'قیام ۱۵ خرداد' => '06-04',
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"name": "\u067e\u06cc\u0631\u0648\u0632\u06cc \u0627\u0646\u0642\u0644\u0627\u0628 \u0627\u0633\u0644\u0627\u0645\u06cc \u067e\u0646\u062c\u0627\u0647 \u0648 \u0647\u0641\u062a",
"date": "2024-02-11"
},
{
"name": "\u0631\u0648\u0632 \u0645\u0644\u06cc \u0634\u062f\u0646 \u0635\u0646\u0639\u062a \u0646\u0641\u062a",
"date": "2024-03-19"
},
{
"name": "\u0646\u062e\u0633\u062a\u06cc\u0646 \u0631\u0648\u0632 \u0646\u0648\u0631\u0648\u0632",
"date": "2024-03-20"
},
{
"name": "\u062f\u0648\u0645\u06cc\u0646 \u0631\u0648\u0632 \u0646\u0648\u0631\u0648\u0632",
"date": "2024-03-21"
},
{
"name": "\u0633\u0648\u0645\u06cc\u0646 \u0631\u0648\u0632 \u0646\u0648\u0631\u0648\u0632",
"date": "2024-03-22"
},
{
"name": "\u0686\u0647\u0627\u0631\u0645\u06cc\u0646 \u0631\u0648\u0632 \u0646\u0648\u0631\u0648\u0632",
"date": "2024-03-23"
},
{
"name": "\u0631\u0648\u0632 \u062c\u0645\u0647\u0648\u0631\u06cc \u0627\u0633\u0644\u0627\u0645\u06cc",
"date": "2024-03-31"
},
{
"name": "\u0633\u06cc\u0632\u062f\u0647 \u0628\u062f\u0631",
"date": "2024-04-01"
},
{
"name": "\u0631\u062d\u0644\u062a \u0631\u0648\u062d\u200c\u0627\u0644\u0644\u0647 \u062e\u0645\u06cc\u0646\u06cc",
"date": "2024-06-03"
},
{
"name": "\u0642\u06cc\u0627\u0645 \u06f1\u06f5 \u062e\u0631\u062f\u0627\u062f",
"date": "2024-06-04"
}
]
31 changes: 31 additions & 0 deletions tests/Countries/IranTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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();
});

it('can calculate iran holidays in local', function (string $locale, string $newYearsDayName) {
CarbonImmutable::setTestNow('2024-01-01');
$result = Holidays::for(country: 'ir', year: null, locale: $locale)->get();

expect($result)->toBeArray();
expect($result[7]['name'])->toBe($newYearsDayName);
Copy link
Contributor Author

@alisalehi1380 alisalehi1380 Feb 1, 2024

Choose a reason for hiding this comment

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

I chose the 7th date of the holidays array because it is far from any political and ethnic front. 🤝

})->with(
[
['en', 'Sizdah Bedar'],
['fa', 'سیزده بدر'],
]
);
Loading