From 433084e91a374b0176773e89ca63f210053b1d76 Mon Sep 17 00:00:00 2001 From: abh31000 Date: Thu, 11 May 2023 17:47:09 +0100 Subject: [PATCH 1/7] Added Algeria holidays --- README.rst | 5 +- holidays/countries/__init__.py | 1 + holidays/countries/algeria.py | 85 +++++++++++++++++++++++++++++++++ tests/countries/test_algeria.py | 72 ++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 holidays/countries/algeria.py create mode 100644 tests/countries/test_algeria.py diff --git a/README.rst b/README.rst index 45896df47..015089465 100644 --- a/README.rst +++ b/README.rst @@ -107,7 +107,7 @@ Available Countries .. _ISO 3166-1 alpha-2 code: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes .. _ISO 3166-2 code: https://en.wikipedia.org/wiki/ISO_3166-2 -We currently support 121 country codes. The standard way to refer to a country +We currently support 122 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`_. The following countries and subdivisions are available: @@ -123,6 +123,9 @@ subdivisions are available: * - Albania - AL - None + * - Algeria + - DZ + - None * - American Samoa - AS - None; Can also be loaded as country US, subdivision AS diff --git a/holidays/countries/__init__.py b/holidays/countries/__init__.py index d16ee4eba..4bc50c7d2 100644 --- a/holidays/countries/__init__.py +++ b/holidays/countries/__init__.py @@ -10,6 +10,7 @@ # License: MIT (see LICENSE file) from .albania import Albania, AL, ALB +from .algeria import Algeria, DZ, DZA from .american_samoa import AmericanSamoa, AS, ASM, HolidaysAS from .andorra import Andorra, AD, AND from .angola import Angola, AO, AGO diff --git a/holidays/countries/algeria.py b/holidays/countries/algeria.py new file mode 100644 index 000000000..651dd70ad --- /dev/null +++ b/holidays/countries/algeria.py @@ -0,0 +1,85 @@ +from holidays.constants import JAN, JUL, NOV +from holidays.holiday_base import HolidayBase +from holidays.holiday_groups import IslamicHolidays, InternationalHolidays + + +class Algeria(HolidayBase, IslamicHolidays, InternationalHolidays): + """ + References: + - https://en.wikipedia.org/wiki/Public_holidays_in_Algeria + """ + + country = "DZ" + + 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") + + # Amazigh New Year / Yennayer + # In January 2018, Algeria declared Yennayer a national holiday + if year >= 2018: + self._add_holiday("Amazigh New Year", JAN, 12) + + # Labour Day + self._add_labor_day("Labour Day") + + # Independance Day + if year >= 1962: + self._add_holiday("Independance Day", JUL, 5) + + # Revolution Day + if year > 1962: + self._add_holiday("Revolution Day", NOV, 1) + + # Islamic New Year + self._add_islamic_new_year_day("Islamic New Year") + + # Ashura + self._add_ashura_day("Ashura Day") + + # Mawlid / Prophet's Birthday + self._add_mawlid_day("Prophet's Birthday") + + # As of April 30, 2023. Algeria has 3 days of Eid holidays + # (https://www.horizons.dz/english/archives/amp/12021) + if year < 2023: + # Eid al-Fitr - Feast Festive + self._add_eid_al_fitr_day("Eid al-Fitr") + self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") + # Eid al-Adha - Scarfice Festive + self._add_eid_al_adha_day("Eid al-Adha") + self._add_eid_al_adha_day_two("Eid al-Adha Holiday") + + elif year == 2023: + # Eid al-Fitr - Feast Festive + self._add_eid_al_fitr_day("Eid al-Fitr") + self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") + # Eid al-Adha - Scarfice Festive + self._add_eid_al_adha_day("Eid al-Adha") + self._add_eid_al_adha_day_two("Eid al-Adha Holiday") + self._add_eid_al_adha_day_three("Eid al-Adha Holiday") + + elif year > 2023: + # Eid al-Fitr - Feast Festive + self._add_eid_al_fitr_day("Eid al-Fitr") + self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") + self._add_eid_al_fitr_day_three("Eid al-Fitr Holiday") + # Eid al-Adha - Scarfice Festive + self._add_eid_al_adha_day("Eid al-Adha") + self._add_eid_al_adha_day_two("Eid al-Adha Holiday") + self._add_eid_al_adha_day_three("Eid al-Adha Holiday") + + +class DZ(Algeria): + pass + + +class DZA(Algeria): + pass diff --git a/tests/countries/test_algeria.py b/tests/countries/test_algeria.py new file mode 100644 index 000000000..66d49563b --- /dev/null +++ b/tests/countries/test_algeria.py @@ -0,0 +1,72 @@ +from holidays.countries.algeria import Algeria, DZ, DZA +from tests.common import TestCase + + +class TestAlgeria(TestCase): + @classmethod + def setUpClass(cls): + super().setUpClass(Algeria) + + def test_country_aliases(self): + self.assertCountryAliases(Algeria, DZ, DZA) + + def test_2022(self): + self.assertHoliday("2022-01-01") + self.assertHoliday("2022-01-12") + self.assertHoliday("2022-05-01") + self.assertHoliday("2022-05-02") + self.assertHoliday("2022-05-03") + self.assertHoliday("2022-07-05") + self.assertHoliday("2022-07-09") + self.assertHoliday("2022-07-10") + self.assertHoliday("2022-11-01") + + def test_new_year_day(self): + self.assertHoliday("2022-01-01", "2023-01-01") + + def test_independance_day(self): + self.assertNoHoliday("1961-07-05") + self.assertHoliday("1962-07-05") + + def test_revolution_day(self): + self.assertNoHoliday("1962-11-01") + self.assertHoliday("1963-11-01") + + def test_amazigh_new_year(self): + self.assertNoHoliday("2017-01-12") + self.assertHoliday("2018-01-12") + self.assertHoliday("2023-01-12") + + def test_labour_day(self): + self.assertHoliday("2021-05-01") + self.assertHoliday("2022-05-01") + self.assertHoliday("2023-05-01") + self.assertNoHoliday("2023-05-02") + + def test_islamic_holidays(self): + # Eid al-Fitr - Feast Festive + self.assertHoliday("2023-04-21") + self.assertHoliday("2023-04-22") + self.assertNoHoliday("2023-04-23") + + # Eid al-Adha - Scarfice Festive + self.assertHoliday("2023-06-29") + self.assertHoliday("2023-06-30") + self.assertHoliday("2023-06-28") + self.assertNoHoliday("2023-07-02") + + # Islamic New Year + self.assertHoliday( + "2008-01-10", + "2008-12-29", + "2020-08-20", + ) + # Ashura + self.assertHoliday("2023-07-28") + self.assertNoHoliday("2023-07-29") + + # Mawlid / Prophet's Birthday + self.assertHoliday("2021-10-18") + self.assertHoliday("2023-09-27") + self.assertNoHoliday("2021-10-19") + self.assertNoHoliday("2023-09-28") From d2dec9ea4f5c6a3a187f8bb6d0bcd24cf8ac4b9e Mon Sep 17 00:00:00 2001 From: abh31000 Date: Thu, 11 May 2023 18:27:21 +0100 Subject: [PATCH 2/7] Forgot to run make tox --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e6707e3bb..f6cd220e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: exclude: ^(docs|holidays/countries/__init__.py|scripts/l10n/msgfmt.py) - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.2.0 + rev: v1.3.0 hooks: - id: mypy additional_dependencies: [types-all] From 7063a0c6beb98b3fc2f0ac2c568551df14190b71 Mon Sep 17 00:00:00 2001 From: abh31000 Date: Thu, 11 May 2023 17:45:42 +0100 Subject: [PATCH 3/7] Typo in holidays/countries/algeria.py Co-authored-by: ~Jhellico --- holidays/countries/algeria.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holidays/countries/algeria.py b/holidays/countries/algeria.py index 651dd70ad..a4f276f3c 100644 --- a/holidays/countries/algeria.py +++ b/holidays/countries/algeria.py @@ -30,9 +30,9 @@ def _populate(self, year): # Labour Day self._add_labor_day("Labour Day") - # Independance Day + # Independence Day if year >= 1962: - self._add_holiday("Independance Day", JUL, 5) + self._add_holiday("Independence Day", JUL, 5) # Revolution Day if year > 1962: From 9f283ed9569c5903e6fa057e97df74534addf914 Mon Sep 17 00:00:00 2001 From: abh31000 Date: Thu, 11 May 2023 17:47:05 +0100 Subject: [PATCH 4/7] Update holidays/countries/algeria.py Co-authored-by: ~Jhellico --- holidays/countries/algeria.py | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/holidays/countries/algeria.py b/holidays/countries/algeria.py index a4f276f3c..99ad6b8ac 100644 --- a/holidays/countries/algeria.py +++ b/holidays/countries/algeria.py @@ -49,31 +49,16 @@ def _populate(self, year): # As of April 30, 2023. Algeria has 3 days of Eid holidays # (https://www.horizons.dz/english/archives/amp/12021) - if year < 2023: - # Eid al-Fitr - Feast Festive - self._add_eid_al_fitr_day("Eid al-Fitr") - self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") - # Eid al-Adha - Scarfice Festive - self._add_eid_al_adha_day("Eid al-Adha") - self._add_eid_al_adha_day_two("Eid al-Adha Holiday") - - elif year == 2023: - # Eid al-Fitr - Feast Festive - self._add_eid_al_fitr_day("Eid al-Fitr") - self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") - # Eid al-Adha - Scarfice Festive - self._add_eid_al_adha_day("Eid al-Adha") - self._add_eid_al_adha_day_two("Eid al-Adha Holiday") - self._add_eid_al_adha_day_three("Eid al-Adha Holiday") - - elif year > 2023: - # Eid al-Fitr - Feast Festive - self._add_eid_al_fitr_day("Eid al-Fitr") - self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") + # Eid al-Fitr - Feast Festive + self._add_eid_al_fitr_day("Eid al-Fitr") + self._add_eid_al_fitr_day_two("Eid al-Fitr Holiday") + if year >= 2024: self._add_eid_al_fitr_day_three("Eid al-Fitr Holiday") - # Eid al-Adha - Scarfice Festive - self._add_eid_al_adha_day("Eid al-Adha") - self._add_eid_al_adha_day_two("Eid al-Adha Holiday") + + # Eid al-Adha - Scarfice Festive + self._add_eid_al_adha_day("Eid al-Adha") + self._add_eid_al_adha_day_two("Eid al-Adha Holiday") + if year >= 2023: self._add_eid_al_adha_day_three("Eid al-Adha Holiday") From 1e316d138b76910aee943d625c48c913126dfa63 Mon Sep 17 00:00:00 2001 From: abh31000 Date: Thu, 11 May 2023 17:53:22 +0100 Subject: [PATCH 5/7] Update holidays/countries/algeria.py Co-authored-by: ~Jhellico --- holidays/countries/algeria.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holidays/countries/algeria.py b/holidays/countries/algeria.py index 99ad6b8ac..74ee7f2c3 100644 --- a/holidays/countries/algeria.py +++ b/holidays/countries/algeria.py @@ -35,7 +35,7 @@ def _populate(self, year): self._add_holiday("Independence Day", JUL, 5) # Revolution Day - if year > 1962: + if year >= 1963: self._add_holiday("Revolution Day", NOV, 1) # Islamic New Year From ae568964bd7a95e7dd311e2939b4d7fb600627c6 Mon Sep 17 00:00:00 2001 From: abh31000 Date: Thu, 11 May 2023 19:45:24 +0100 Subject: [PATCH 6/7] -Merged latest beta branch from remote repo and added new entry for Algeria in holidays/registry.py -Fixed typo in holidays/countries/algeria.py --- holidays/registry.py | 1 + tests/countries/test_algeria.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/holidays/registry.py b/holidays/registry.py index ca8ee3976..79ff37dfd 100644 --- a/holidays/registry.py +++ b/holidays/registry.py @@ -18,6 +18,7 @@ COUNTRIES: RegistryDict = { "albania": ("Albania", "AL", "ALB"), + "algeria": ("Algeria", "DZ", "DZA"), "american_samoa": ("AmericanSamoa", "AS", "ASM", "HolidaysAS"), "andorra": ("Andorra", "AD", "AND"), "angola": ("Angola", "AO", "AGO"), diff --git a/tests/countries/test_algeria.py b/tests/countries/test_algeria.py index 66d49563b..f9aa9081c 100644 --- a/tests/countries/test_algeria.py +++ b/tests/countries/test_algeria.py @@ -24,7 +24,7 @@ def test_2022(self): def test_new_year_day(self): self.assertHoliday("2022-01-01", "2023-01-01") - def test_independance_day(self): + def test_independence_day(self): self.assertNoHoliday("1961-07-05") self.assertHoliday("1962-07-05") From 2dc14a290195c8e646e1d5369619a1028965ad94 Mon Sep 17 00:00:00 2001 From: abh31000 Date: Fri, 12 May 2023 17:06:49 +0100 Subject: [PATCH 7/7] Addressing issues from latest review --- holidays/countries/algeria.py | 2 +- tests/countries/test_algeria.py | 96 ++++++++++++++++++++++----------- 2 files changed, 67 insertions(+), 31 deletions(-) diff --git a/holidays/countries/algeria.py b/holidays/countries/algeria.py index 74ee7f2c3..31143b61e 100644 --- a/holidays/countries/algeria.py +++ b/holidays/countries/algeria.py @@ -3,7 +3,7 @@ from holidays.holiday_groups import IslamicHolidays, InternationalHolidays -class Algeria(HolidayBase, IslamicHolidays, InternationalHolidays): +class Algeria(HolidayBase, InternationalHolidays, IslamicHolidays): """ References: - https://en.wikipedia.org/wiki/Public_holidays_in_Algeria diff --git a/tests/countries/test_algeria.py b/tests/countries/test_algeria.py index f9aa9081c..6622846bc 100644 --- a/tests/countries/test_algeria.py +++ b/tests/countries/test_algeria.py @@ -11,22 +11,33 @@ def test_country_aliases(self): self.assertCountryAliases(Algeria, DZ, DZA) def test_2022(self): - self.assertHoliday("2022-01-01") - self.assertHoliday("2022-01-12") - self.assertHoliday("2022-05-01") - self.assertHoliday("2022-05-02") - self.assertHoliday("2022-05-03") - self.assertHoliday("2022-07-05") - self.assertHoliday("2022-07-09") - self.assertHoliday("2022-07-10") - self.assertHoliday("2022-11-01") + self.assertHoliday( + "2022-01-01", + "2022-01-12", + "2022-05-01", + "2022-05-02", + "2022-05-03", + "2022-07-05", + "2022-07-09", + "2022-07-10", + "2022-11-01", + ) def test_new_year_day(self): - self.assertHoliday("2022-01-01", "2023-01-01") + self.assertHoliday( + "2022-01-01", + "2023-01-01", + ) def test_independence_day(self): - self.assertNoHoliday("1961-07-05") - self.assertHoliday("1962-07-05") + self.assertNoHoliday( + "1961-07-05", + "1962-07-04", + ) + self.assertHoliday( + "1962-07-05", + "1963-07-05", + ) def test_revolution_day(self): self.assertNoHoliday("1962-11-01") @@ -34,26 +45,46 @@ def test_revolution_day(self): def test_amazigh_new_year(self): self.assertNoHoliday("2017-01-12") - self.assertHoliday("2018-01-12") - self.assertHoliday("2023-01-12") + self.assertHoliday( + "2018-01-12", + "2023-01-12", + ) def test_labour_day(self): - self.assertHoliday("2021-05-01") - self.assertHoliday("2022-05-01") - self.assertHoliday("2023-05-01") - self.assertNoHoliday("2023-05-02") + self.assertNoHoliday( + "2021-05-02", + "2022-05-04", + "2023-05-02", + ) + self.assertHoliday( + "2021-05-01", + "2022-05-01", + "2023-05-01", + ) def test_islamic_holidays(self): # Eid al-Fitr - Feast Festive - self.assertHoliday("2023-04-21") - self.assertHoliday("2023-04-22") - self.assertNoHoliday("2023-04-23") + self.assertNoHoliday("2023-04-20") + self.assertHoliday( + "2023-04-21", + "2023-04-22", + ) # Eid al-Adha - Scarfice Festive - self.assertHoliday("2023-06-29") - self.assertHoliday("2023-06-30") - self.assertHoliday("2023-06-28") - self.assertNoHoliday("2023-07-02") + self.assertNoHoliday( + "2023-06-27", + "2023-07-02", + "2024-07-15", + "2024-07-19", + ) + self.assertHoliday( + "2023-06-28", + "2023-06-29", + "2023-06-30", + "2024-06-16", + "2024-06-17", + "2024-06-18", + ) # Islamic New Year self.assertHoliday( @@ -61,12 +92,17 @@ def test_islamic_holidays(self): "2008-12-29", "2020-08-20", ) + # Ashura - self.assertHoliday("2023-07-28") self.assertNoHoliday("2023-07-29") + self.assertHoliday("2023-07-28") # Mawlid / Prophet's Birthday - self.assertHoliday("2021-10-18") - self.assertHoliday("2023-09-27") - self.assertNoHoliday("2021-10-19") - self.assertNoHoliday("2023-09-28") + self.assertNoHoliday( + "2021-10-19", + "2023-09-28", + ) + self.assertHoliday( + "2021-10-18", + "2023-09-27", + )