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 Tunisia Holidays #109

Merged
merged 31 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
abd492d
add Tunisia Holidays
mr-wolf-gb Jan 18, 2024
ff904a6
fix Tunisia Hijri Holidays
mr-wolf-gb Jan 18, 2024
ea6d1af
fix PHPStan error
mr-wolf-gb Jan 21, 2024
4aae5f9
sync latest commits
mr-wolf-gb Jan 31, 2024
a27dfe5
change Hijri Dates to generated Like in turkey holidays
mr-wolf-gb Jan 31, 2024
0b37ecb
Merge branch 'main' into main
Jan 31, 2024
30af822
minor fixes
mr-wolf-gb Jan 31, 2024
45d77ec
minor fixes
mr-wolf-gb Jan 31, 2024
ce11a5d
fix phpstan error
mr-wolf-gb Jan 31, 2024
616f4d1
fix phpstan error
mr-wolf-gb Jan 31, 2024
b98f93d
Merge branch 'spatie:main' into main
Feb 1, 2024
074767d
implement turkey method as trait for Hijri holidays
mr-wolf-gb Feb 1, 2024
19f83fa
Merge branch 'spatie:main' into main
Feb 1, 2024
342a574
minor fix
mr-wolf-gb Feb 1, 2024
4f96329
Merge remote-tracking branch 'origin/main'
mr-wolf-gb Feb 1, 2024
c38bd7a
move tunisia translations to correct dir
mr-wolf-gb Feb 1, 2024
707db3e
Merge branch 'spatie:main' into main
Feb 1, 2024
09e1ef5
Merge branch 'spatie:main' into main
Feb 5, 2024
8a40743
Merge branch 'main' into main
mr-wolf-gb Feb 11, 2024
c25e1e4
Update src/Countries/Tunisia.php
mr-wolf-gb Feb 12, 2024
d8ed1e7
Update src/Countries/Tunisia.php
mr-wolf-gb Feb 12, 2024
7ff692a
Update tests/Countries/TunisiaTest.php
mr-wolf-gb Feb 12, 2024
fae4fce
Update tests/Countries/TunisiaTest.php
mr-wolf-gb Feb 12, 2024
7685704
remove HijriCalendar
mr-wolf-gb Feb 12, 2024
80ef304
Fix phpstan fail test
mr-wolf-gb Feb 12, 2024
f7c8094
Fix phpstan Ternary operator condition is always true.
mr-wolf-gb Feb 12, 2024
404e998
Merge branch 'spatie:main' into main
mr-wolf-gb Mar 21, 2024
f31ab11
Merge branch 'spatie:main' into main
mr-wolf-gb Apr 1, 2024
548c21a
Fix code to use IslamicCalendar
mr-wolf-gb Apr 2, 2024
7ed2051
Merge branch 'spatie:main' into main
mr-wolf-gb Apr 3, 2024
db2e6b1
Fix translation
mr-wolf-gb Apr 3, 2024
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
22 changes: 22 additions & 0 deletions lang/tunisia/ar/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"New Year's Day'": "رأس السنة الميلادية",
"Independence Day": "عيد الاستقلال",
"Martyrs' Day": "عيد الشهداء",
"Labour Day": "عيد الشغل",
"Republic Day": "عيد الجمهورية",
"Women's Day": "عيد المرأة",
"Evacuation Day": "عيد الجلاء",
"Revolution and Youth Day": "عيد الثورة والشباب",
"Eid al-Fitr": "عيد الفطر",
"Eid al-Fitr Day 2": "عيد الفطر اليوم الثاني",
"Eid al-Fitr Day 3": "عيد الفطر اليوم الثالث",
"Eid al-Adha": "عيد الأضحى",
"Eid al-Adha Day 2": "عيد الأضحى اليوم الثاني",
"Eid al-Adha Day 3": "عيد الأضحى اليوم الثالث",
"Eid al-Adha Day 4": "عيد الأضحى اليوم الرابع",
"Islamic New Year": "رأس السنة الهجرية",
"Birthday of the Prophet Muhammad": "المولد النبوي الشريف",
"Arafat Day": "يوم عرفة (وقفة عيد الأضحى)",
"Day": "يوم"
}

22 changes: 22 additions & 0 deletions lang/tunisia/en/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"New Year's Day'": "New Year's Day",
"Independence Day": "Independence Day",
"Martyrs' Day": "Martyrs' Day",
"Labour Day": "Labour Day",
"Republic Day": "Republic Day",
"Women's Day": "Women's Day",
"Evacuation Day": "Evacuation Day",
"Revolution and Youth Day": "Revolution and Youth Day",
"Eid al-Fitr": "Eid al-Fitr day 1",
"Eid al-Fitr Day 2": "Eid al-Fitr day 2",
"Eid al-Fitr Day 3": "Eid al-Fitr day 3",
"Eid al-Adha": "Eid al-Adha day 1",
"Eid al-Adha Day 2": "Eid al-Adha day 2",
"Eid al-Adha Day 3": "Eid al-Adha day 3",
"Eid al-Adha Day 4": "Eid al-Adha day 4",
"Islamic New Year": "Islamic new year",
"Birthday of the Prophet Muhammad": "Birthday of the Prophet Mohamed",
"Arafat Day": "Arafat Day",
"Day": "Day"
}

22 changes: 22 additions & 0 deletions lang/tunisia/fr/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"New Year's Day'": "Jour de l'An",
"Independence Day": "Fête de l'indépendance",
"Martyrs' Day": "Fête des Martyrs",
"Labour Day": "Fête du Travail",
"Republic Day": "Fête de la République",
"Women's Day": "Fête de la femme",
"Evacuation Day": "Fête d'évacuation",
"Revolution and Youth Day": "Fête de la Révolution et de la Jeunesse",
"Eid al-Fitr": "Eid al-Fitr 1er jour",
"Eid al-Fitr Day 2": "Eid al-Fitr 2e jour",
"Eid al-Fitr Day 3": "Eid al-Fitr 3e jour",
"Eid al-Adha": "Eid al-Adha",
"Eid al-Adha Day 2": "Eid al-Adha",
"Eid al-Adha Day 3": "Eid al-Adha",
"Eid al-Adha Day 4": "Eid al-Adha",
"Islamic New Year": "Nouvel an islamique",
"Birthday of the Prophet Muhammad": "Anniversaire du prophète Mohamed",
"Arafat Day": "Arafat Day",
"Day": "Jour"
}

279 changes: 279 additions & 0 deletions src/Countries/Tunisia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
<?php

namespace Spatie\Holidays\Countries;

use Spatie\Holidays\Calendars\IslamicCalendar;
use Spatie\Holidays\Concerns\Translatable;
use Spatie\Holidays\Contracts\HasTranslations;
use Spatie\Holidays\Contracts\Islamic;

class Tunisia extends Country implements HasTranslations, Islamic
{
use IslamicCalendar;
use Translatable;

protected const eidAlFitr = [
2005 => '11-04',
2006 => '10-24',
2007 => '10-13',
2008 => '10-02',
2009 => '09-21',
2010 => '09-10',
2011 => '08-30',
2012 => '08-19',
2013 => '08-08',
2014 => '07-28',
2015 => '07-17',
2016 => '07-07',
2017 => '06-26',
2018 => '06-15',
2019 => '06-05',
2020 => '05-24',
2021 => '05-13',
2022 => '05-02',
2023 => '04-20',
2024 => '04-10',
2025 => '03-31',
2026 => '03-21',
2027 => '03-10',
2028 => '02-27',
2029 => '02-15',
2030 => '02-04',
2031 => '01-25',
2032 => '01-15',
2033 => '01-03',
2034 => '12-13',
2035 => '12-02',
2036 => '11-20',
2037 => '11-09',
];

protected const arafat = [
2005 => '01-21',
2006 => '01-10',
2007 => '01-01',
2008 => '12-09',
2009 => '11-26',
2010 => '11-15',
2011 => '11-05',
2012 => '10-25',
2013 => '10-15',
2014 => '10-04',
2015 => '09-23',
2016 => '09-11',
2017 => '08-31',
2018 => '08-20',
2019 => '08-10',
2020 => '07-30',
2021 => '07-19',
2022 => '07-09',
2023 => '06-27',
2024 => '06-16',
2025 => '06-06',
2026 => '05-26',
2027 => '05-16',
2028 => '05-05',
2029 => '04-24',
2030 => '04-13',
2031 => '04-02',
2032 => '03-21',
2033 => '03-11',
2034 => '03-01',
2035 => '02-18',
2036 => '02-07',
2037 => '01-26',
];
protected const eidAlAdha = [
2005 => '01-22',
2006 => '01-11',
2007 => '01-02',
2008 => '12-10',
2009 => '11-27',
2010 => '11-16',
2011 => '11-06',
2012 => '10-26',
2013 => '10-16',
2014 => '10-05',
2015 => '09-24',
2016 => '09-12',
2017 => '08-31',
2018 => '08-21',
2019 => '08-11',
2020 => '07-31',
2021 => '07-20',
2022 => '07-09',
2023 => '06-28',
2024 => '06-17',
2025 => '06-07',
2026 => '05-27',
2027 => '05-17',
2028 => '05-06',
2029 => '04-25',
2030 => '04-14',
2031 => '04-03',
2032 => '03-22',
2033 => '03-12',
2034 => '03-02',
2035 => '02-19',
2036 => '02-08',
2037 => '01-27',
];
protected const islamicNewYear = [
2005 => '02-10',
2006 => '01-31',
2007 => '01-20',
2008 => '01-10',
2009 => '12-18',
2010 => '12-07',
2011 => '11-27',
2012 => '11-15',
2013 => '11-05',
2014 => '10-25',
2015 => '10-14',
2016 => '10-03',
2017 => '09-22',
2018 => '09-11',
2019 => '08-31',
2020 => '08-20',
2021 => '08-09',
2022 => '07-30',
2023 => '07-19',
2024 => '07-08',
2025 => '06-06',
2026 => '06-17',
2027 => '06-07',
2028 => '05-26',
2029 => '05-15',
2030 => '05-05',
2031 => '04-24',
2032 => '04-12',
2033 => '04-01',
2034 => '03-22',
2035 => '03-12',
2036 => '02-29',
2037 => '02-17',
];
protected const ashura = [
2005 => '02-19',
2006 => '02-09',
2007 => '01-29',
2008 => '01-19',
2009 => '12-27',
2010 => '12-16',
2011 => '12-06',
2012 => '11-25',
2013 => '11-15',
2014 => '11-04',
2015 => '10-24',
2016 => '10-13',
2017 => '10-02',
2018 => '09-21',
2019 => '09-10',
2020 => '08-30',
2021 => '08-19',
2022 => '08-08',
2023 => '07-28',
2024 => '07-17',
2025 => '07-07',
2026 => '06-26',
2027 => '06-15',
2028 => '06-04',
2029 => '05-24',
2030 => '05-13',
2031 => '05-02',
2032 => '04-20',
2033 => '04-10',
2034 => '03-30',
2035 => '03-19',
2036 => '03-08',
2037 => '02-25',
];
protected const prophetMuhammadBirthday = [
2005 => '04-21',
2006 => '04-11',
2007 => '03-31',
2008 => '03-20',
2009 => '03-09',
2010 => '02-26',
2011 => '02-16',
2012 => '02-05',
2013 => '01-24',
2014 => '01-13',
2015 => '12-23',
2016 => '12-12',
2017 => '12-01',
2018 => '11-20',
2019 => '11-09',
2020 => '10-29',
2021 => '10-21',
2022 => '10-08',
2023 => '09-28',
2024 => '09-16',
2025 => '09-06',
2026 => '08-26',
2027 => '08-15',
2028 => '08-04',
2029 => '07-25',
2030 => '07-14',
2031 => '07-03',
2032 => '06-21',
2033 => '06-10',
2034 => '05-31',
2035 => '05-21',
2036 => '05-09',
2037 => '04-29',
];

/**
* @return string
*/
mr-wolf-gb marked this conversation as resolved.
Show resolved Hide resolved
public function countryCode(): string
{
return 'tn';
}

public function defaultLocale(): string
{
return 'en';
}

protected function allHolidays(int $year): array
{
$revolutionHoliday = [];

if (2022 > $year && $year >= 2011) {
$revolutionHoliday['Revolution and Youth Day'] = '01-14';
}

if ($year >= 2022) {
$revolutionHoliday['Revolution and Youth Day'] = '12-17';
}

return array_merge([
'New Year\'s Day' => '01-01',
'Independence Day' => '03-20',
'Martyrs\' Day' => '04-09',
'Labour Day' => '05-01',
'Republic Day' => '07-25',
'Women\'s Day' => '08-13',
'Evacuation Day' => '10-15',
], $revolutionHoliday, $this->islamicHolidays($year));
}

public function islamicHolidays(int $year): array
{
$eidAlFitr = $this->eidAlFitr(year: $year, totalDays: 2);
$eidAlAdha = $this->eidAlAdha(year: $year, totalDays: 2);

return array_merge(
[
'Arafat Day' => $this->arafat($year),
'Islamic New Year' => $this->islamicNewYear($year),
'Birthday of the Prophet Muhammad' => $this->prophetMuhammadBirthday($year),
],
$this->convertPeriods(name: 'Eid al-Fitr', year: $year, period: $eidAlFitr[0]),
$this->convertPeriods(name: 'Eid al-Adha', year: $year, period: $eidAlAdha[0]),
);
}

}
Loading
Loading