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 Mauritania holidays #1884

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Available Countries
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

We currently support 148 country codes. The standard way to refer to a country
We currently support 149 country codes. The standard way to refer to a country
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
for a subdivision its `ISO 3166-2 code`_. Some countries have common or foreign
names or abbreviations as aliases for their subdivisions. These are defined in
Expand Down Expand Up @@ -625,6 +625,11 @@ All other default values are highlighted with bold:
-
-
-
* - Mauritania
- MR
-
-
-
* - Mexico
- MX
-
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
from .maldives import Maldives, MV, MDV
from .malta import Malta, MT, MLT
from .marshall_islands import MarshallIslands, MH, MHL, HolidaysMH
from .mauritania import Mauritania, MR, MRT
from .mexico import Mexico, MX, MEX
from .moldova import Moldova, MD, MDA
from .monaco import Monaco, MC, MCO
Expand Down
82 changes: 82 additions & 0 deletions holidays/countries/mauritania.py
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_holiday_may_25("Africa Day")
kasya marked this conversation as resolved.
Show resolved Hide resolved

# 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
1 change: 1 addition & 0 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"maldives": ("Maldives", "MV", "MDV"),
"malta": ("Malta", "MT", "MLT"),
"marshall_islands": ("MarshallIslands", "MH", "MHL", "HolidaysMH"),
"mauritania": ("Mauritania", "MR", "MRT"),
"mexico": ("Mexico", "MX", "MEX"),
"moldova": ("Moldova", "MD", "MDA"),
"monaco": ("Monaco", "MC", "MCO"),
Expand Down
78 changes: 78 additions & 0 deletions tests/countries/test_mauritania.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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):
self.assertHolidayName("Independence Day", (f"{year}-11-28" for year in range(1960, 2050)))
kasya marked this conversation as resolved.
Show resolved Hide resolved

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"),
)
Loading