-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# holidays | ||
# -------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: Vacanza Team and individual contributors (see AUTHORS file) | ||
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/python-holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
# python-holidays | ||
# --------------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/dr-prodigy/python-holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
from holidays.calendars.gregorian import FRI, SAT | ||
from holidays.groups import InternationalHolidays, IslamicHolidays | ||
from holidays.holiday_base import HolidayBase | ||
|
||
|
||
class Mauritania(HolidayBase, InternationalHolidays, IslamicHolidays): | ||
""" | ||
References: | ||
- https://en.wikipedia.org/wiki/Public_holidays_in_Mauritania | ||
- https://www.timeanddate.com/holidays/mauritania/ | ||
""" | ||
|
||
country = "MR" | ||
weekend = {FRI, SAT} | ||
|
||
def __init__(self, *args, **kwargs): | ||
InternationalHolidays.__init__(self) | ||
IslamicHolidays.__init__(self) | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
def _populate(self, year): | ||
super()._populate(year) | ||
|
||
# New Year's Day. | ||
self._add_new_years_day("New Year's Day") | ||
|
||
# Labor Day. | ||
self._add_labor_day("Labor Day") | ||
|
||
# Africa Day. | ||
self._add_africa_day("Africa Day") | ||
|
||
# Independence Day. | ||
if year >= 1960: | ||
self._add_holiday_nov_28("Independence Day") | ||
|
||
# Islamic holidays. | ||
# Eid al-Fitr. | ||
self._add_eid_al_fitr_day("Eid al-Fitr") | ||
self._add_eid_al_fitr_day_two("Eid al-Fitr") | ||
|
||
# Eid al-Adha. | ||
self._add_eid_al_adha_day("Eid al-Adha") | ||
self._add_eid_al_adha_day_two("Eid al-Adha") | ||
|
||
# Muharram/Islamic New Year. | ||
self._add_islamic_new_year_day("Islamic New Year") | ||
|
||
# Prophet Muhammad's Birthday. | ||
self._add_mawlid_day("Mawlid al-Nabi") | ||
|
||
|
||
class MR(Mauritania): | ||
pass | ||
|
||
|
||
class MRT(Mauritania): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# holidays | ||
# -------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: Vacanza Team and individual contributors (see AUTHORS file) | ||
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/python-holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
# python-holidays | ||
# --------------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/dr-prodigy/python-holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
from unittest import TestCase | ||
|
||
from holidays.countries.mauritania import Mauritania, MR, MRT | ||
from tests.common import CommonCountryTests | ||
|
||
|
||
class TestMauritania(CommonCountryTests, TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass(Mauritania, years=range(1950, 2050)) | ||
|
||
def test_country_aliases(self): | ||
self.assertAliases(Mauritania, MR, MRT) | ||
|
||
def test_new_years_day(self): | ||
self.assertHolidayName("New Year's Day", (f"{year}-01-01" for year in range(1950, 2050))) | ||
|
||
def test_labor_day(self): | ||
self.assertHolidayName("Labor Day", (f"{year}-05-01" for year in range(1950, 2050))) | ||
|
||
def test_africa_day(self): | ||
self.assertHolidayName("Africa Day", (f"{year}-05-25" for year in range(1950, 2050))) | ||
|
||
def test_independence_day(self): | ||
name = "Independence Day" | ||
self.assertHolidayName(name, (f"{year}-11-28" for year in range(1960, 2050))) | ||
self.assertNoHolidayName(name, range(1950, 1960)) | ||
|
||
def test_2023(self): | ||
self.assertHolidays( | ||
Mauritania(years=2023), | ||
("2023-01-01", "New Year's Day"), | ||
("2023-04-21", "Eid al-Fitr (estimated)"), | ||
("2023-04-22", "Eid al-Fitr (estimated)"), | ||
("2023-05-01", "Labor Day"), | ||
("2023-05-25", "Africa Day"), | ||
("2023-06-28", "Eid al-Adha (estimated)"), | ||
("2023-06-29", "Eid al-Adha (estimated)"), | ||
("2023-07-19", "Islamic New Year (estimated)"), | ||
("2023-09-27", "Mawlid al-Nabi (estimated)"), | ||
("2023-11-28", "Independence Day"), | ||
) | ||
|
||
def test_2024(self): | ||
self.assertHolidays( | ||
Mauritania(years=2024), | ||
("2024-01-01", "New Year's Day"), | ||
("2024-04-10", "Eid al-Fitr (estimated)"), | ||
("2024-04-11", "Eid al-Fitr (estimated)"), | ||
("2024-05-01", "Labor Day"), | ||
("2024-05-25", "Africa Day"), | ||
("2024-06-16", "Eid al-Adha (estimated)"), | ||
("2024-06-17", "Eid al-Adha (estimated)"), | ||
("2024-07-07", "Islamic New Year (estimated)"), | ||
("2024-09-15", "Mawlid al-Nabi (estimated)"), | ||
("2024-11-28", "Independence Day"), | ||
) |