diff --git a/lang/tunisia/ar/holidays.json b/lang/tunisia/ar/holidays.json new file mode 100644 index 000000000..c0f4dca3e --- /dev/null +++ b/lang/tunisia/ar/holidays.json @@ -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": "يوم" +} + diff --git a/lang/tunisia/en/holidays.json b/lang/tunisia/en/holidays.json new file mode 100644 index 000000000..9a3632685 --- /dev/null +++ b/lang/tunisia/en/holidays.json @@ -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" +} + diff --git a/lang/tunisia/fr/holidays.json b/lang/tunisia/fr/holidays.json new file mode 100644 index 000000000..59d104fa6 --- /dev/null +++ b/lang/tunisia/fr/holidays.json @@ -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" +} + diff --git a/src/Countries/Tunisia.php b/src/Countries/Tunisia.php new file mode 100644 index 000000000..a6bac81d2 --- /dev/null +++ b/src/Countries/Tunisia.php @@ -0,0 +1,279 @@ + '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 + */ + 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]), + ); + } + +} diff --git a/tests/.pest/snapshots/Countries/TunisiaTest/it_can_calculate_tunisia_holidays_with_data_set___2024____2024_.snap b/tests/.pest/snapshots/Countries/TunisiaTest/it_can_calculate_tunisia_holidays_with_data_set___2024____2024_.snap new file mode 100644 index 000000000..ea825b988 --- /dev/null +++ b/tests/.pest/snapshots/Countries/TunisiaTest/it_can_calculate_tunisia_holidays_with_data_set___2024____2024_.snap @@ -0,0 +1,62 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Independence Day", + "date": "2024-03-20" + }, + { + "name": "Martyrs' Day", + "date": "2024-04-09" + }, + { + "name": "Eid al-Fitr day 1", + "date": "2024-04-10" + }, + { + "name": "Eid al-Fitr day 2", + "date": "2024-04-11" + }, + { + "name": "Labour Day", + "date": "2024-05-01" + }, + { + "name": "Arafat Day", + "date": "2024-06-16" + }, + { + "name": "Eid al-Adha day 1", + "date": "2024-06-17" + }, + { + "name": "Eid al-Adha day 2", + "date": "2024-06-18" + }, + { + "name": "Islamic new year", + "date": "2024-07-08" + }, + { + "name": "Republic Day", + "date": "2024-07-25" + }, + { + "name": "Women's Day", + "date": "2024-08-13" + }, + { + "name": "Birthday of the Prophet Mohamed", + "date": "2024-09-16" + }, + { + "name": "Evacuation Day", + "date": "2024-10-15" + }, + { + "name": "Revolution and Youth Day", + "date": "2024-12-17" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/TunisiaTest/it_can_calculate_tunisia_holidays_with_data_set___2025____2025_.snap b/tests/.pest/snapshots/Countries/TunisiaTest/it_can_calculate_tunisia_holidays_with_data_set___2025____2025_.snap new file mode 100644 index 000000000..8074f3583 --- /dev/null +++ b/tests/.pest/snapshots/Countries/TunisiaTest/it_can_calculate_tunisia_holidays_with_data_set___2025____2025_.snap @@ -0,0 +1,62 @@ +[ + { + "name": "New Year's Day", + "date": "2025-01-01" + }, + { + "name": "Independence Day", + "date": "2025-03-20" + }, + { + "name": "Eid al-Fitr day 1", + "date": "2025-03-31" + }, + { + "name": "Eid al-Fitr day 2", + "date": "2025-04-01" + }, + { + "name": "Martyrs' Day", + "date": "2025-04-09" + }, + { + "name": "Labour Day", + "date": "2025-05-01" + }, + { + "name": "Arafat Day", + "date": "2025-06-06" + }, + { + "name": "Islamic new year", + "date": "2025-06-06" + }, + { + "name": "Eid al-Adha day 1", + "date": "2025-06-07" + }, + { + "name": "Eid al-Adha day 2", + "date": "2025-06-08" + }, + { + "name": "Republic Day", + "date": "2025-07-25" + }, + { + "name": "Women's Day", + "date": "2025-08-13" + }, + { + "name": "Birthday of the Prophet Mohamed", + "date": "2025-09-06" + }, + { + "name": "Evacuation Day", + "date": "2025-10-15" + }, + { + "name": "Revolution and Youth Day", + "date": "2025-12-17" + } +] \ No newline at end of file diff --git a/tests/Countries/TunisiaTest.php b/tests/Countries/TunisiaTest.php new file mode 100644 index 000000000..a241fd2ec --- /dev/null +++ b/tests/Countries/TunisiaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +})->with([2024, 2025]);