Skip to content

Commit 7d3c700

Browse files
kasyaKJhellico
andauthored
Add Mauritania holidays (#1884)
Co-authored-by: ~Jhellico <[email protected]>
1 parent fa3feb8 commit 7d3c700

File tree

5 files changed

+170
-1
lines changed

5 files changed

+170
-1
lines changed

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Available Countries
146146
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
147147
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
148148

149-
We currently support 148 country codes. The standard way to refer to a country
149+
We currently support 149 country codes. The standard way to refer to a country
150150
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
151151
for a subdivision its `ISO 3166-2 code`_. Some countries have common or foreign
152152
names or abbreviations as aliases for their subdivisions. These are defined in
@@ -625,6 +625,11 @@ All other default values are highlighted with bold:
625625
-
626626
-
627627
-
628+
* - Mauritania
629+
- MR
630+
-
631+
-
632+
-
628633
* - Mexico
629634
- MX
630635
-

holidays/countries/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
from .maldives import Maldives, MV, MDV
102102
from .malta import Malta, MT, MLT
103103
from .marshall_islands import MarshallIslands, MH, MHL, HolidaysMH
104+
from .mauritania import Mauritania, MR, MRT
104105
from .mexico import Mexico, MX, MEX
105106
from .moldova import Moldova, MD, MDA
106107
from .monaco import Monaco, MC, MCO

holidays/countries/mauritania.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# holidays
2+
# --------
3+
# A fast, efficient Python library for generating country, province and state
4+
# specific sets of holidays on the fly. It aims to make determining whether a
5+
# specific date is a holiday as fast and flexible as possible.
6+
#
7+
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
8+
# dr-prodigy <[email protected]> (c) 2017-2023
9+
# ryanss <[email protected]> (c) 2014-2017
10+
# Website: https://github.com/vacanza/python-holidays
11+
# License: MIT (see LICENSE file)
12+
13+
# python-holidays
14+
# ---------------
15+
# A fast, efficient Python library for generating country, province and state
16+
# specific sets of holidays on the fly. It aims to make determining whether a
17+
# specific date is a holiday as fast and flexible as possible.
18+
#
19+
# Authors: dr-prodigy <[email protected]> (c) 2017-2023
20+
# ryanss <[email protected]> (c) 2014-2017
21+
# Website: https://github.com/dr-prodigy/python-holidays
22+
# License: MIT (see LICENSE file)
23+
24+
from holidays.calendars.gregorian import FRI, SAT
25+
from holidays.groups import InternationalHolidays, IslamicHolidays
26+
from holidays.holiday_base import HolidayBase
27+
28+
29+
class Mauritania(HolidayBase, InternationalHolidays, IslamicHolidays):
30+
"""
31+
References:
32+
- https://en.wikipedia.org/wiki/Public_holidays_in_Mauritania
33+
- https://www.timeanddate.com/holidays/mauritania/
34+
"""
35+
36+
country = "MR"
37+
weekend = {FRI, SAT}
38+
39+
def __init__(self, *args, **kwargs):
40+
InternationalHolidays.__init__(self)
41+
IslamicHolidays.__init__(self)
42+
43+
super().__init__(*args, **kwargs)
44+
45+
def _populate(self, year):
46+
super()._populate(year)
47+
48+
# New Year's Day.
49+
self._add_new_years_day("New Year's Day")
50+
51+
# Labor Day.
52+
self._add_labor_day("Labor Day")
53+
54+
# Africa Day.
55+
self._add_africa_day("Africa Day")
56+
57+
# Independence Day.
58+
if year >= 1960:
59+
self._add_holiday_nov_28("Independence Day")
60+
61+
# Islamic holidays.
62+
# Eid al-Fitr.
63+
self._add_eid_al_fitr_day("Eid al-Fitr")
64+
self._add_eid_al_fitr_day_two("Eid al-Fitr")
65+
66+
# Eid al-Adha.
67+
self._add_eid_al_adha_day("Eid al-Adha")
68+
self._add_eid_al_adha_day_two("Eid al-Adha")
69+
70+
# Muharram/Islamic New Year.
71+
self._add_islamic_new_year_day("Islamic New Year")
72+
73+
# Prophet Muhammad's Birthday.
74+
self._add_mawlid_day("Mawlid al-Nabi")
75+
76+
77+
class MR(Mauritania):
78+
pass
79+
80+
81+
class MRT(Mauritania):
82+
pass

holidays/registry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"maldives": ("Maldives", "MV", "MDV"),
109109
"malta": ("Malta", "MT", "MLT"),
110110
"marshall_islands": ("MarshallIslands", "MH", "MHL", "HolidaysMH"),
111+
"mauritania": ("Mauritania", "MR", "MRT"),
111112
"mexico": ("Mexico", "MX", "MEX"),
112113
"moldova": ("Moldova", "MD", "MDA"),
113114
"monaco": ("Monaco", "MC", "MCO"),

tests/countries/test_mauritania.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# holidays
2+
# --------
3+
# A fast, efficient Python library for generating country, province and state
4+
# specific sets of holidays on the fly. It aims to make determining whether a
5+
# specific date is a holiday as fast and flexible as possible.
6+
#
7+
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
8+
# dr-prodigy <[email protected]> (c) 2017-2023
9+
# ryanss <[email protected]> (c) 2014-2017
10+
# Website: https://github.com/vacanza/python-holidays
11+
# License: MIT (see LICENSE file)
12+
13+
# python-holidays
14+
# ---------------
15+
# A fast, efficient Python library for generating country, province and state
16+
# specific sets of holidays on the fly. It aims to make determining whether a
17+
# specific date is a holiday as fast and flexible as possible.
18+
#
19+
# Authors: dr-prodigy <[email protected]> (c) 2017-2023
20+
# ryanss <[email protected]> (c) 2014-2017
21+
# Website: https://github.com/dr-prodigy/python-holidays
22+
# License: MIT (see LICENSE file)
23+
24+
from unittest import TestCase
25+
26+
from holidays.countries.mauritania import Mauritania, MR, MRT
27+
from tests.common import CommonCountryTests
28+
29+
30+
class TestMauritania(CommonCountryTests, TestCase):
31+
@classmethod
32+
def setUpClass(cls):
33+
super().setUpClass(Mauritania, years=range(1950, 2050))
34+
35+
def test_country_aliases(self):
36+
self.assertAliases(Mauritania, MR, MRT)
37+
38+
def test_new_years_day(self):
39+
self.assertHolidayName("New Year's Day", (f"{year}-01-01" for year in range(1950, 2050)))
40+
41+
def test_labor_day(self):
42+
self.assertHolidayName("Labor Day", (f"{year}-05-01" for year in range(1950, 2050)))
43+
44+
def test_africa_day(self):
45+
self.assertHolidayName("Africa Day", (f"{year}-05-25" for year in range(1950, 2050)))
46+
47+
def test_independence_day(self):
48+
name = "Independence Day"
49+
self.assertHolidayName(name, (f"{year}-11-28" for year in range(1960, 2050)))
50+
self.assertNoHolidayName(name, range(1950, 1960))
51+
52+
def test_2023(self):
53+
self.assertHolidays(
54+
Mauritania(years=2023),
55+
("2023-01-01", "New Year's Day"),
56+
("2023-04-21", "Eid al-Fitr (estimated)"),
57+
("2023-04-22", "Eid al-Fitr (estimated)"),
58+
("2023-05-01", "Labor Day"),
59+
("2023-05-25", "Africa Day"),
60+
("2023-06-28", "Eid al-Adha (estimated)"),
61+
("2023-06-29", "Eid al-Adha (estimated)"),
62+
("2023-07-19", "Islamic New Year (estimated)"),
63+
("2023-09-27", "Mawlid al-Nabi (estimated)"),
64+
("2023-11-28", "Independence Day"),
65+
)
66+
67+
def test_2024(self):
68+
self.assertHolidays(
69+
Mauritania(years=2024),
70+
("2024-01-01", "New Year's Day"),
71+
("2024-04-10", "Eid al-Fitr (estimated)"),
72+
("2024-04-11", "Eid al-Fitr (estimated)"),
73+
("2024-05-01", "Labor Day"),
74+
("2024-05-25", "Africa Day"),
75+
("2024-06-16", "Eid al-Adha (estimated)"),
76+
("2024-06-17", "Eid al-Adha (estimated)"),
77+
("2024-07-07", "Islamic New Year (estimated)"),
78+
("2024-09-15", "Mawlid al-Nabi (estimated)"),
79+
("2024-11-28", "Independence Day"),
80+
)

0 commit comments

Comments
 (0)