From c28872f7e8b449fe390da1fa801af66204bf6833 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Thu, 16 Nov 2023 16:32:09 +0100 Subject: [PATCH 1/5] Transfer creation of holiday locale to country class Holidays are now defined uniformly via a DSL. Signed-off-by: Thomas Lauf --- src/holidata/__init__.py | 20 +- src/holidata/holidays/AT.py | 129 ++++ src/holidata/holidays/BE.py | 111 +++ src/holidata/holidays/BR.py | 346 ++++++++++ src/holidata/holidays/CA.py | 206 ++++++ src/holidata/holidays/CH.py | 117 ++++ src/holidata/holidays/CO.py | 106 +++ src/holidata/holidays/CZ.py | 94 +++ src/holidata/holidays/DE.py | 157 +++++ src/holidata/holidays/DK.py | 63 ++ src/holidata/holidays/EE.py | 68 ++ src/holidata/holidays/ES/AN.py | 86 +++ src/holidata/holidays/ES/AR.py | 90 +++ src/holidata/holidays/ES/AS.py | 83 +++ src/holidata/holidays/ES/CB.py | 78 +++ src/holidata/holidays/ES/CE.py | 98 +++ src/holidata/holidays/ES/CL.py | 108 +++ src/holidata/holidays/ES/CM.py | 59 ++ src/holidata/holidays/ES/CN.py | 65 ++ src/holidata/holidays/ES/CT.py | 36 + src/holidata/holidays/ES/EX.py | 89 +++ src/holidata/holidays/ES/GA.py | 47 ++ src/holidata/holidays/ES/IB.py | 47 ++ src/holidata/holidays/ES/MC.py | 79 +++ src/holidata/holidays/ES/MD.py | 101 +++ src/holidata/holidays/ES/ML.py | 112 +++ src/holidata/holidays/ES/NC.py | 58 ++ src/holidata/holidays/ES/PV.py | 54 ++ src/holidata/holidays/ES/RI.py | 67 ++ src/holidata/holidays/ES/VC.py | 60 ++ src/holidata/holidays/ES/__init__.py | 140 +++- src/holidata/holidays/ES/es-ES.py | 982 --------------------------- src/holidata/holidays/FI.py | 126 ++++ src/holidata/holidays/FR.py | 63 ++ src/holidata/holidays/GB.py | 160 +++++ src/holidata/holidays/GR.py | 88 +++ src/holidata/holidays/HR.py | 74 ++ src/holidata/holidays/HU.py | 136 ++++ src/holidata/holidays/IS.py | 94 +++ src/holidata/holidays/IT.py | 63 ++ src/holidata/holidays/NL.py | 117 ++++ src/holidata/holidays/NO.py | 88 +++ src/holidata/holidays/NZ.py | 145 ++++ src/holidata/holidays/PL.py | 72 ++ src/holidata/holidays/PT.py | 73 ++ src/holidata/holidays/RU.py | 48 ++ src/holidata/holidays/SE.py | 98 +++ src/holidata/holidays/SI.py | 85 +++ src/holidata/holidays/SK.py | 78 +++ src/holidata/holidays/TR.py | 124 ++++ src/holidata/holidays/US.py | 108 +++ src/holidata/holidays/ZA.py | 135 ++++ src/holidata/holidays/__init__.py | 35 - src/holidata/holidays/cs-CZ.py | 80 --- src/holidata/holidays/da-DK.py | 24 - src/holidata/holidays/de-AT.py | 36 - src/holidata/holidays/de-BE.py | 24 - src/holidata/holidays/de-CH.py | 32 - src/holidata/holidays/de-DE.py | 99 --- src/holidata/holidays/el-GR.py | 47 -- src/holidata/holidays/en-CA.py | 74 -- src/holidata/holidays/en-GB.py | 164 ----- src/holidata/holidays/en-NZ.py | 139 ---- src/holidata/holidays/en-US.py | 25 - src/holidata/holidays/en-ZA.py | 91 --- src/holidata/holidays/es-CO.py | 101 --- src/holidata/holidays/es-US.py | 25 - src/holidata/holidays/et-EE.py | 29 - src/holidata/holidays/fi-FI.py | 52 -- src/holidata/holidays/fr-BE.py | 24 - src/holidata/holidays/fr-CA.py | 77 --- src/holidata/holidays/fr-FR.py | 24 - src/holidata/holidays/holidays.py | 100 +-- src/holidata/holidays/hr-HR.py | 38 -- src/holidata/holidays/hu-HU.py | 261 ------- src/holidata/holidays/is-IS.py | 73 -- src/holidata/holidays/it-IT.py | 24 - src/holidata/holidays/nb-NO.py | 29 - src/holidata/holidays/nl-BE.py | 24 - src/holidata/holidays/nl-NL.py | 81 --- src/holidata/holidays/pl-PL.py | 29 - src/holidata/holidays/pt-BR.py | 101 --- src/holidata/holidays/pt-PT.py | 26 - src/holidata/holidays/ru-RU.py | 21 - src/holidata/holidays/sk-SK.py | 27 - src/holidata/holidays/sl-SI.py | 46 -- src/holidata/holidays/sv-FI.py | 52 -- src/holidata/holidays/sv-SE.py | 73 -- src/holidata/holidays/tr-TR.py | 111 --- tests/test_holidata.py | 10 +- tests/test_holidays.py | 10 +- 91 files changed, 4936 insertions(+), 3333 deletions(-) create mode 100644 src/holidata/holidays/ES/AN.py create mode 100644 src/holidata/holidays/ES/AR.py create mode 100644 src/holidata/holidays/ES/AS.py create mode 100644 src/holidata/holidays/ES/CB.py create mode 100644 src/holidata/holidays/ES/CE.py create mode 100644 src/holidata/holidays/ES/CL.py create mode 100644 src/holidata/holidays/ES/CM.py create mode 100644 src/holidata/holidays/ES/CN.py create mode 100644 src/holidata/holidays/ES/CT.py create mode 100644 src/holidata/holidays/ES/EX.py create mode 100644 src/holidata/holidays/ES/GA.py create mode 100644 src/holidata/holidays/ES/IB.py create mode 100644 src/holidata/holidays/ES/MC.py create mode 100644 src/holidata/holidays/ES/MD.py create mode 100644 src/holidata/holidays/ES/ML.py create mode 100644 src/holidata/holidays/ES/NC.py create mode 100644 src/holidata/holidays/ES/PV.py create mode 100644 src/holidata/holidays/ES/RI.py create mode 100644 src/holidata/holidays/ES/VC.py delete mode 100644 src/holidata/holidays/ES/es-ES.py delete mode 100644 src/holidata/holidays/cs-CZ.py delete mode 100644 src/holidata/holidays/da-DK.py delete mode 100644 src/holidata/holidays/de-AT.py delete mode 100644 src/holidata/holidays/de-BE.py delete mode 100644 src/holidata/holidays/de-CH.py delete mode 100644 src/holidata/holidays/de-DE.py delete mode 100644 src/holidata/holidays/el-GR.py delete mode 100644 src/holidata/holidays/en-CA.py delete mode 100644 src/holidata/holidays/en-GB.py delete mode 100644 src/holidata/holidays/en-NZ.py delete mode 100644 src/holidata/holidays/en-US.py delete mode 100644 src/holidata/holidays/en-ZA.py delete mode 100644 src/holidata/holidays/es-CO.py delete mode 100644 src/holidata/holidays/es-US.py delete mode 100644 src/holidata/holidays/et-EE.py delete mode 100644 src/holidata/holidays/fi-FI.py delete mode 100644 src/holidata/holidays/fr-BE.py delete mode 100644 src/holidata/holidays/fr-CA.py delete mode 100644 src/holidata/holidays/fr-FR.py delete mode 100644 src/holidata/holidays/hr-HR.py delete mode 100644 src/holidata/holidays/hu-HU.py delete mode 100644 src/holidata/holidays/is-IS.py delete mode 100644 src/holidata/holidays/it-IT.py delete mode 100644 src/holidata/holidays/nb-NO.py delete mode 100644 src/holidata/holidays/nl-BE.py delete mode 100644 src/holidata/holidays/nl-NL.py delete mode 100644 src/holidata/holidays/pl-PL.py delete mode 100644 src/holidata/holidays/pt-BR.py delete mode 100644 src/holidata/holidays/pt-PT.py delete mode 100644 src/holidata/holidays/ru-RU.py delete mode 100644 src/holidata/holidays/sk-SK.py delete mode 100644 src/holidata/holidays/sl-SI.py delete mode 100644 src/holidata/holidays/sv-FI.py delete mode 100644 src/holidata/holidays/sv-SE.py delete mode 100644 src/holidata/holidays/tr-TR.py diff --git a/src/holidata/__init__.py b/src/holidata/__init__.py index 9d1a7f2..cee49ea 100644 --- a/src/holidata/__init__.py +++ b/src/holidata/__init__.py @@ -1,6 +1,6 @@ -from .holidays import * from .emitters import Emitter -from .holidays.holidays import LocaleWrapper +from .holidays import * +from .holidays.holidays import Locale def get_country_for(identifier): @@ -12,15 +12,6 @@ def get_country_for(identifier): return country_class() -def get_locale_for(identifier): - locale_class = Locale.get(identifier) - - if not locale_class: - raise ValueError(f"No plugin found for locale '{identifier}'!") - - return locale_class() - - def get_emitter_for(identifier): emitter_class = Emitter.get(identifier) @@ -30,14 +21,11 @@ def get_emitter_for(identifier): return emitter_class() -def create_locale_for(country_id=None, lang_id=None): +def create_locale_for(country_id, lang_id=None): country = get_country_for(country_id) lang_id = country.validate_language_or_get_default(lang_id) - if hasattr(country, "get_holidays_of"): - return LocaleWrapper(country, lang_id) - - return get_locale_for(f"{lang_id}-{country_id}") + return Locale(country, lang_id) def parse_year(year): diff --git a/src/holidata/holidays/AT.py b/src/holidata/holidays/AT.py index 63d9ce3..e47988c 100644 --- a/src/holidata/holidays/AT.py +++ b/src/holidata/holidays/AT.py @@ -9,3 +9,132 @@ class AT(Country): default_lang = "de" regions = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Neujahr") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Heilige drei Könige") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Josef") \ + .in_regions(["2", "6", "7", "8"]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Staatsfeiertag") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Florian") \ + .in_regions(["4"]) \ + .on("05-04") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Mariä Himmelfahrt") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Rupert") \ + .in_regions(["5"]) \ + .on("09-24") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Tag der Volksabstimmung") \ + .in_regions(["2"]) \ + .on("10-10") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Nationalfeiertag") \ + .on("10-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Allerheiligen") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Martin") \ + .in_regions(["1"]) \ + .on("11-11") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Leopold") \ + .in_regions(["9", "3"]) \ + .on("11-15") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Mariä Empfängnis") \ + .on("12-08") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Heiliger Abend") \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Christtag") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Stefanitag") \ + .on("12-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Silvester") \ + .on("12-31") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Karfreitag") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ostersonntag") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ostermontag") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Christi Himmelfahrt") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pfingstsonntag") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pfingstmontag") \ + .on("50 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Fronleichnam") \ + .on("60 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/BE.py b/src/holidata/holidays/BE.py index c796b5f..fa4f676 100644 --- a/src/holidata/holidays/BE.py +++ b/src/holidata/holidays/BE.py @@ -7,3 +7,114 @@ class BE(Country): id = "BE" languages = ["de", "fr", "nl"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_names({ + "de": "Neujahr", + "fr": "Nouvel An", + "nl": "Nieuwjaar", + }) \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "de": "Tag der Arbeit", + "fr": "Fête du Travail", + "nl": "Dag van de arbeid", + }) \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "de": "Nationalfeiertag", + "fr": "Fête nationale", + "nl": "Nationale feestdag", + }) \ + .on("07-21") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "de": "Mariä Himmelfahrt", + "fr": "Assomption", + "nl": "Onze Lieve Vrouw hemelvaart", + }) \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "de": "Allerheiligen", + "fr": "Toussaint", + "nl": "Allerheiligen", + }) \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "de": "Waffenstillstand", + "fr": "Jour de l'armistice", + "nl": "Wapenstilstand", + }) \ + .on("11-11") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "de": "Weihnacht", + "fr": "Noël", + "nl": "Kerstmis", + }) \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "de": "Ostern", + "fr": "Pâques", + "nl": "Pasen", + }) \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "de": "Ostermontag", + "fr": "Lundi de Pâques", + "nl": "Paasmaandag", + }) \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "de": "Christi Himmelfahrt", + "fr": "Ascension", + "nl": "Onze Lieve Heer hemelvaart", + }) \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "de": "Pfingsten", + "fr": "Pentecôte", + "nl": "Pinksteren", + }) \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "de": "Pfingstmontag", + "fr": "Lundi de Pentecôte", + "nl": "Pinkstermaandag", + }) \ + .on("50 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/BR.py b/src/holidata/holidays/BR.py index 2ce6e93..552c400 100644 --- a/src/holidata/holidays/BR.py +++ b/src/holidata/holidays/BR.py @@ -2,6 +2,41 @@ from .holidays import Country +# Information gathered from Brazilian legislation. + +# National holidays: +# Law 10.607/2002: http://www.planalto.gov.br/ccivil_03/leis/2002/l10607.htm +# Law 6.802/1980: http://www.planalto.gov.br/ccivil_03/leis/l6802.htm + +# State holidays +# AC: State laws 1.538/2004, 1.411/2001, 14/1964, 1.526/2004, and 57/1965 +# AL: State laws 5.508/1993, 5.509/1993, 5.724/1995, and Decree 68.782 (30/dec/2019) +# AP: State law 667/2002 and Art. 355 of the Constitution of the Federative Republic of Brazil +# AM: State laws 25/1977 and 84/2010 +# BA: Art. 6 of the Constitution of the Federative Republic of Brazil +# CE: State laws 9.093/1995, 9.093/1995 and Art. 18 of the Constitution of the State of Ceará +# DF: District law 963/1995 +# ES: State law 11.010/2019 +# GO: State law 20.756/2020 +# MA: State law 2.457/1964 +# MT: State law 7.879/2002 +# MS: State law 10/1979 +# MG: Art. 256 of the Constitution of the State of Minas Gerais +# PA: State law 5.999/1996 +# PB: State law 3.489/1967 +# PR: State law 4.658/1962 +# PE: State law 13.835/2009 +# PI: State law 176/1937 +# RJ: State laws 5.243/2008, 5.198/2008, and 4.007/2002 +# RN: State laws 7.831/2000 and 8.913/2006 +# RS: Art. 6 of the Constitution of the State of Rio Grande do Sul and Decree 36.180 (18/set/1995) +# RO: State laws 2.291/2010 and 1.026/2001 +# RR: Art. 9 of the Constitution of the State of Roraima +# SC: State laws 12.906/2004 and 10.306/1996 +# SP: State law 9.497/1997 +# SE: Art. 269 of the Constitution of the State of Sergipe +# TO: State laws 98/1989, 960/1998, 627/1993 + class BR(Country): id = "BR" @@ -10,3 +45,314 @@ class BR(Country): regions = ["AC", "AL", "AP", "AM", "BA", "CE", "DF", "ES", "GO", "MA", "MT", "MS", "MG", "PA", "PB", "PR", "PE", "PI", "RJ", "RN", "RS", "RO", "RR", "SC", "SP", "SE", "TO"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Confraternização Universal") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Criação do Estado de Rondônia") \ + .in_regions(["RO"]) \ + .on("01-04") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia do Evangélico no Acre") \ + .in_regions(["AC"]) \ + .on("01-23") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Revolução Pernambucana de 1817") \ + .in_regions(["PE"]) \ + .on("03-06") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia Internacional da Mulher") \ + .in_regions(["AC"]) \ + .on("03-08") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Autonomia do Estado de Tocantins") \ + .in_regions(["TO"]) \ + .on("03-18") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia de São José") \ + .in_regions(["AP", "CE"]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Abolição da Escravidão no Ceará") \ + .in_regions(["CE"]) \ + .on("03-25") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Fundação de Brasília") \ + .in_regions(["DF"]) \ + .on("04-21") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Execução de Tiradentes") \ + .in_regions(["MG"]) \ + .on("04-21") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Tiradentes") \ + .on("04-21") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dia de São Jorge") \ + .in_regions(["RJ"]) \ + .on("04-23") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Dia Internacional do Trabalhador") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Aniversário do Estado do Acre") \ + .in_regions(["AC"]) \ + .on("06-15") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia do Evangélico em Rondônia") \ + .in_regions(["RO"]) \ + .on("06-18") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("São João") \ + .in_regions(["AL", "PE"]) \ + .on("06-24") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("São Pedro") \ + .in_regions(["AL"]) \ + .on("06-29") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Independência da Bahia") \ + .in_regions(["BA"]) \ + .on("07-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Emancipação Política de Sergipe") \ + .in_regions(["SE"]) \ + .on("07-08") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Revolução Constitucionalista de 1932") \ + .in_regions(["SP"]) \ + .on("07-09") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Fundação da Cidade de Goiás") \ + .in_regions(["GO"]) \ + .on("07-26") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Adesão do Maranhão à Independência do Brasil") \ + .in_regions(["MA"]) \ + .on("07-28") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Fundação do Estado da Paraíba") \ + .in_regions(["PB"]) \ + .on("08-05") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia do Rio Grande do Norte") \ + .in_regions(["RN"]) \ + .on("08-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia de Santa Catarina") \ + .in_regions(["SC"]) \ + .on("08-11") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia de Nossa Senhora da Assunção") \ + .in_regions(["CE"]) \ + .on("08-15") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Adesão do Pará à Independência do Brasil") \ + .in_regions(["PA"]) \ + .on("08-15") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia da Amazônia") \ + .in_regions(["AC"]) \ + .on("09-05") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Elevação do Amazonas à Categoria de Província") \ + .in_regions(["AM"]) \ + .on("09-05") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Independência do Brasil") \ + .on("09-07") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Nossa Senhora da Natividade") \ + .in_regions(["TO"]) \ + .on("09-08") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Criação do Território Federal do Amapá") \ + .in_regions(["AP"]) \ + .on("09-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Emancipação Política do Alagoas") \ + .in_regions(["AL"]) \ + .on("09-16") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia do Gaúcho") \ + .in_regions(["RS"]) \ + .on("09-20") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Mártires de Cunhaú e Uruaçu") \ + .in_regions(["RN"]) \ + .on("10-03") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Criação dos Estado de Roraima") \ + .in_regions(["RR"]) \ + .on("10-05") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Criação dos Estado de Tocantins") \ + .in_regions(["TO"]) \ + .on("10-05") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Criação do Estado do Mato Grosso do Sul") \ + .in_regions(["MS"]) \ + .on("10-11") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Nossa Senhora Aparecida") \ + .on("10-12") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Dia do Piauí") \ + .in_regions(["PI"]) \ + .on("10-19") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Pedra Fundamental de Goiânia") \ + .in_regions(["GO"]) \ + .on("10-24") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Finados") \ + .on("11-02") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Proclamação da República") \ + .on("11-15") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Assinatura do Tratado de Petrópolis") \ + .in_regions(["AC"]) \ + .on("11-17") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Morte de Zumbi dos Palmares") \ + .in_regions(["AL"]) \ + .on("11-20") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia da Consciência Negra") \ + .in_regions(["AM", "MT", "RJ"]) \ + .on("11-20") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Dia de Santa Catarina de Alexandria") \ + .in_regions(["SC"]) \ + .on("11-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Dia do Evangélico do Distrito Federal") \ + .in_regions(["DF"]) \ + .on("11-30") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Nossa Senhora da Conceição") \ + .in_regions(["AM"]) \ + .on("12-08") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Emancipação Política do Estado do Paraná") \ + .in_regions(["PR"]) \ + .on("12-19") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Natal") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Carnaval") \ + .on("47 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Páscoa") \ + .on("Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/CA.py b/src/holidata/holidays/CA.py index fd3799d..fb21474 100644 --- a/src/holidata/holidays/CA.py +++ b/src/holidata/holidays/CA.py @@ -1,10 +1,216 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country +# +# Information taken from various government websites around 2020-04-16 +# https://www.canada.ca/fr/emploi-developpement-social/services/normes-travail/rapports/jours-feries.html +# http://www4.gouv.qc.ca/FR/Portail/Citoyens/Evenements/travailleur-avec-salaire/Pages/jours-feries-chomes-payes.aspx +# https://www.ontario.ca/document/your-guide-employment-standards-act-0/public-holidays#section-2 +# https://www.cfib-fcei.ca/en/tools-resources/paying-employees-public-holidays-newfoundland-labrador +# https://www.princeedwardisland.ca/en/information/economic-growth-tourism-and-culture/paid-holidays +# https://www2.gnb.ca/content/dam/gnb/Departments/petl-epft/PDF/es/FactSheets/PublicHolidaysVacation.pdf +# https://www.gov.mb.ca/labour/standards/doc,gen-holidays-after-april-30-07,factsheet.html#q12 +# https://www.saskatchewan.ca/business/employment-standards/vacations-holidays-leaves-and-absences/public-statutory-holidays/list-of-saskatchewan-public-holidays +# +# Also those sites for some information +# https://www.officeholidays.com/holidays/canada/canada-remembrance-day +# https://www.timeanddate.com/holidays/canada/family-day +# https://fr.wikipedia.org/wiki/F%C3%AAtes_et_jours_f%C3%A9ri%C3%A9s_au_Canada +# +# I have not checked every province and territory website, but the wikipedia +# summary has been true for everything that I have checked, although it seems +# to be considering more holidays than the bare minimum and also counts holidays +# that are not mandated but usually observed (e.g. St-Patrick's Day in NL which +# is not statutory, but is given to government employees). +# + + class CA(Country): id = "CA" languages = ["en", "fr"] regions = ["AB", "BC", "MB", "NB", "NL", "NS", "ON", "PE", "QC", "SK", "NT", "NU", "YT"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_names({ + "en": "New Year's Day", + "fr": "Jour de l'An", + }) \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "en": "National Holiday", + "fr": "Fête Nationale", + }) \ + .in_regions(["QC"]) \ + .on("06-24") \ + .with_flags("F") + + self.define_holiday() \ + .with_names({ + "en": "Canada Day", + "fr": "Fête du Canada", + }) \ + .on("07-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "en": "Remembrance Day", + "fr": "Jour du Souvenir", + }) \ + .in_regions(["AB", "BC", "NB", "NL", "NT"]) \ + .on("11-11") \ + .with_flags("F") + + self.define_holiday() \ + .with_names({ + "en": "Christmas Day", + "fr": "Jour de Noël", + }) \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "en": "Boxing Day", + "fr": "Lendemain de Noël", + }) \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "en": "Good Friday", + "fr": "Vendredi Saint", + }) \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "en": "Easter Monday", + "fr": "Lundi de Pâques", + }) \ + .in_regions(["AB", "PE", "QC"]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_names({ + "en": "Family Day", + "fr": "Fête de la Famille", + }) \ + .in_regions(["AB", "ON", "SK", "NB"]) \ + .on("3. monday in February") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Louis Riel Day", + "fr": "Journée Louis Riel", + }) \ + .in_regions(["MB"]) \ + .on("3. monday in February") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Islander Day", + "fr": "Fête des Insulaires", + }) \ + .in_regions(["PE"]) \ + .on("3. monday in February") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "August Civic Holiday", + "fr": "Premier lundi d'août", + }) \ + .in_regions(["NT", "NU"]) \ + .on("1. monday in August") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Saskatchewan Day", + "fr": "Fête de la Saskatchewan", + }) \ + .in_regions(["SK"]) \ + .on("1. monday in August") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Heritage Day", + "fr": "Fête du Patrimoine", + }) \ + .in_regions(["AB"]) \ + .on("1. monday in August") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Heritage Day", + "fr": "Jour de la Fondation", + }) \ + .in_regions(["NS"]) \ + .on("1. monday in August") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "New Brunswick Day", + "fr": "Jour du Nouveau-Brunswick", + }) \ + .in_regions(["NB"]) \ + .on("1. monday in August") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Labour Day", + "fr": "Fête du Travail", + }) \ + .on("1. monday in September") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Thanksgiving Day", + "fr": "Jour de l'Action de grâce", + }) \ + .in_regions(["AB", "BC", "MB", "NL", "ON", "QC", "SK", "NT", "NU", "YT"]) \ + .on("2. monday in October") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "National Patriots' Day", + "fr": "Journée Nationale des Patriotes", + }) \ + .in_regions(["QC"]) \ + .on(self.first_monday_after_05_25) \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Victoria Day", + "fr": "Fête de la Reine Victoria", + }) \ + .in_regions(["AB", "BC", "MB", "NS", "ON", "SK", "NT", "NU", "YT"]) \ + .on(self.first_monday_after_05_25) \ + .with_flags("V") + + @staticmethod + def first_monday_after_05_25(year): + return SmartDayArrow(year, 5, 25).shift_to_weekday("monday", order=1, reverse=True, including=False) diff --git a/src/holidata/holidays/CH.py b/src/holidata/holidays/CH.py index 83d773e..9447146 100644 --- a/src/holidata/holidays/CH.py +++ b/src/holidata/holidays/CH.py @@ -10,3 +10,120 @@ class CH(Country): regions = ["AG", "AI", "AR", "BE", "BL", "BS", "FR", "GE", "GL", "GR", "JU", "LU", "NE", "NW", "OW", "SG", "SH", "SO", "SZ", "TI", "TG", "UR", "VD", "VS", "ZG", "ZH"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Neujahrstag") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Berchtoldstag") \ + .in_regions(["BE", "JU", "TG", "VD"]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Heilige Drei Könige") \ + .in_regions(["SZ", "TI", "UR"]) \ + .on("01-06") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Josefstag") \ + .in_regions(["NW", "SZ", "TI", "UR", "VS"]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Tag der Arbeit") \ + .in_regions(["BL", "BS", "GR", "NE", "SH", "TG", "TI", "ZH"]) \ + .on("05-01") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Bundesfeier") \ + .on("08-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Mariä Himmelfahrt") \ + .in_regions(["AI"]) \ + .on("08-15") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Mariä Himmelfahrt") \ + .in_regions(["JU", "LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"]) \ + .on("08-15") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Allerheiligen") \ + .in_regions(["AI", "GL", "JU", "LU", "NW", "OW", "SG", "SZ", "TI", "UR", "VS", "ZG"]) \ + .on("11-01") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Mariä Empfängnis") \ + .in_regions(["AI"]) \ + .on("12-08") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Mariä Empfängnis") \ + .in_regions(["LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"]) \ + .on("12-08") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Weihnachtstag") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Stephanstag") \ + .in_regions(["AI", "AR", "BE", "BL", "BS", "GL", "GR", "LU", "SG", "SH", "SZ", "TG", "TI", "UR", "ZH"]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Karfreitag") \ + .in_regions(["AG", "AI", "AR", "BE", "BL", "BS", "FR", "GE", "GL", "GR", "JU", "LU", "NE", "NW", "OW", "SG", "SH", "SO", "SZ", "TG", "UR", "VD", "ZG", "ZH"]) \ + .on("2 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Ostersonntag") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ostermontag") \ + .in_regions(["AI", "AR", "BE", "BL", "BS", "GE", "GL", "GR", "JU", "SG", "SH", "SZ", "TG", "TI", "UR", "VD", "ZH"]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Auffahrt") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pfingstsonntag") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pfingstmontag") \ + .in_regions(["AI", "AR", "BE", "BL", "BS", "GE", "GL", "GR", "JU", "SG", "SH", "SZ", "TG", "TI", "UR", "VD", "ZH"]) \ + .on("50 days after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Fronleichnam") \ + .in_regions(["AI", "JU", "LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"]) \ + .on("60 days after Easter") \ + .with_flags("RV") diff --git a/src/holidata/holidays/CO.py b/src/holidata/holidays/CO.py index 0fc6029..4aeb419 100644 --- a/src/holidata/holidays/CO.py +++ b/src/holidata/holidays/CO.py @@ -1,5 +1,6 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country @@ -8,3 +9,108 @@ class CO(Country): languages = ["es"] default_lang = "es" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Año Nuevo") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Día del Trabajo") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Grito de Independencia") \ + .on("07-20") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Batalla de Boyacá") \ + .on("08-07") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Inmaculada Concepción") \ + .on("12-08") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Navidad") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Viernes Santo") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Domingo de Pascua") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("La Ascensión del Señor") \ + .on("43 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Corpus Christi") \ + .on("64 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("El Sagrado Corazón de Jesús") \ + .on("71 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Día de los Reyes Magos") \ + .on(self.first_monday_after(1, 6)) \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Día de San José") \ + .on(self.first_monday_after(3, 19)) \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("San Pedro y San Pablo") \ + .on(self.first_monday_after(6, 29)) \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Asunción de la Virgen") \ + .on(self.first_monday_after(8, 15)) \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Día de la Raza") \ + .on(self.first_monday_after(10, 12)) \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Todos los Santos") \ + .on(self.first_monday_after(11, 1)) \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Independencia de Cartagena") \ + .on(self.first_monday_after(11, 11)) \ + .with_flags("NV") + + @staticmethod + def first_monday_after(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).shift_to_weekday("monday", including=True) + + return wrapper diff --git a/src/holidata/holidays/CZ.py b/src/holidata/holidays/CZ.py index 8bb1e91..a544281 100644 --- a/src/holidata/holidays/CZ.py +++ b/src/holidata/holidays/CZ.py @@ -2,9 +2,103 @@ from .holidays import Country +""" +source: https://www.zakonyprolidi.cz/cs/2000-245, §1 and §2. + https://www.zakonyprolidi.cz/cs/2000-245/zneni-20200201 (>2020-02-01) + https://www.zakonyprolidi.cz/cs/2000-245/zneni-20190401 (>2019-04-01) + https://www.zakonyprolidi.cz/cs/2000-245/zneni-0 (>2000-08-09) +""" + class CZ(Country): id = "CZ" languages = ["cs"] default_lang = "cs" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nový rok") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Den obnovy samostatného českého státu") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Svátek práce") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Den vítězství") \ + .on("05-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Den slovanských věrozvěstů Cyrila a Metoděje") \ + .on("07-05") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Den upálení mistra Jana Husa") \ + .on("07-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Den české státnosti") \ + .on("09-28") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Den vzniku samostatného československého státu") \ + .on("10-28") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Štědrý den") \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("1. svátek vánoční") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("2. svátek vánoční") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Velikonoční pondělí") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Velký pátek") \ + .on("2 days before Easter") \ + .since(2016) \ + .with_flags("NRV") + + """ + Until 2018, replaced by "Den boje za svobodu a demokracii a Mezinárodní den studentstva" on 2019-04-01" + """ + self.define_holiday() \ + .with_name("Den boje za svobodu a demokracii") \ + .on("11-17") \ + .until(2018) \ + .with_flags("NF") + + """ + Since 2019, replaces "Den boje za svobodu a demokracii" + """ + self.define_holiday() \ + .with_name("Den boje za svobodu a demokracii a Mezinárodní den studentstva") \ + .on("11-17") \ + .since(2019) \ + .with_flags("NF") diff --git a/src/holidata/holidays/DE.py b/src/holidata/holidays/DE.py index fd701b8..93e6551 100644 --- a/src/holidata/holidays/DE.py +++ b/src/holidata/holidays/DE.py @@ -1,5 +1,6 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country @@ -9,3 +10,159 @@ class DE(Country): default_lang = "de" regions = ["BB", "BE", "BH", "BW", "BY", "HE", "HH", "MV", "NI", "NW", "RP", "SH", "SL", "SN", "ST", "TH"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + self.default_lang = "de" + + self.define_holiday() \ + .with_name("Neujahr") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Heilige drei Könige") \ + .in_regions(["BW", "BY", "ST"]) \ + .on("01-06") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Erster Maifeiertag") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Mariä Himmelfahrt") \ + .in_region("SL") \ + .on("08-15") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Tag der Deutschen Einheit") \ + .on("10-03") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Allerheiligen") \ + .in_regions(["BW", "BY", "NW", "RP", "SL"]) \ + .on("11-01") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Heilig Abend") \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Weihnachtstag") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Zweiter Weihnachtstag") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Silvester") \ + .on("12-31") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Karfreitag") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ostern") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ostermontag") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Christi Himmelfahrt") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pfingstsonntag") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pfingstmontag") \ + .on("50 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Fronleichnam") \ + .in_regions(["BW", "BY", "HE", "NW", "RP", "SL"]) \ + .on("60 days after Easter") \ + .with_flags("RV") + + """ + 11 days before 4. sunday before 12-25: Buß- und Bettag + """ + self.define_holiday() \ + .with_name("Buß- und Bettag") \ + .in_region("SN") \ + .on(self.buss_und_bettag) \ + .with_flags("RV") + + """ + 2020-05-08: 75. Jahrestag der Befreiung vom Nationalsozialismus und der Beendigung des Zweiten Weltkrieges in Europa + Introduced 2019 for Berlin + https://gesetze.berlin.de/perma?d=jlr-FeiertGBEV6P1 + """ + self.define_holiday() \ + .with_name("75. Jahrestag der Befreiung vom Nationalsozialismus und der Beendigung des Zweiten Weltkrieges in Europa") \ + .in_region("BE") \ + .in_years([2020]) \ + .on("05-08") \ + .with_flags("F") + + """ + 03-08: Frauentag + Introduced 2019 for Berlin + https://gesetze.berlin.de/perma?d=jlr-FeiertGBEV6P1 + """ + self.define_holiday() \ + .with_name("Internationaler Frauentag") \ + .in_region("BE") \ + .since(2019) \ + .on("03-08") \ + .with_flags("F") + + """ + before 2018: 10-31: [BB, MV, SN, ST, TH] [RF] Reformationstag + since 2018: 10-31: [BB, BH, HH, MV, NI, SH, SN, ST, TH] [RF] Reformationstag + 2017: 10-31: [NRF] Reformationstag (national holiday because of 500th anniversary) + + """ + self.define_holiday() \ + .with_name("Reformationstag") \ + .in_years([2017]) \ + .on("10-31") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Reformationstag") \ + .in_regions(["BB", "MV", "SN", "ST", "TH"]) \ + .until(2016) \ + .on("10-31") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Reformationstag") \ + .in_regions(["BB", "BH", "HH", "MV", "NI", "SH", "SN", "ST", "TH"]) \ + .since(2018) \ + .on("10-31") \ + .with_flags("RF") + + @staticmethod + def buss_und_bettag(year): + return SmartDayArrow(year, 12, 25).shift_to_weekday("sunday", order=4, reverse=True).shift(days=-11) diff --git a/src/holidata/holidays/DK.py b/src/holidata/holidays/DK.py index 564eb37..3f50a1c 100644 --- a/src/holidata/holidays/DK.py +++ b/src/holidata/holidays/DK.py @@ -8,3 +8,66 @@ class DK(Country): languages = ["da"] default_lang = "da" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nytårsdag") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Grundlovsdag") \ + .on("06-05") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Juledag") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Anden juledag") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Skærtorsdag") \ + .on("3 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Langfredag") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Påskedag") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Anden påskedag") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Store bededag") \ + .on("26 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Kristi himmelfartsdag") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pinsedag") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Anden pinsedag") \ + .on("50 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/EE.py b/src/holidata/holidays/EE.py index b701c50..0ed0cf0 100644 --- a/src/holidata/holidays/EE.py +++ b/src/holidata/holidays/EE.py @@ -2,9 +2,77 @@ from .holidays import Country +""" +sources +https://www.riigiteataja.ee/akt/109032011007 (Public Holidays and Days of National Importance Act) +""" + class EE(Country): id = "EE" languages = ["et"] default_lang = "et" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Uusaasta") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Iseseisvuspäev, Eesti Vabariigi aastapäev") \ + .on("02-24") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Kevadpüha") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Võidupüha") \ + .on("06-23") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Jaanipäev") \ + .on("06-24") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Taasiseseisvumispäev") \ + .on("08-20") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Jõululaupäev") \ + .on("12-24") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Esimene jõulupüha") \ + .on("12-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Teine jõulupüha") \ + .on("12-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Suur reede") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ülestõusmispühade 1. püha") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Nelipühade 1. püha") \ + .on("49 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/ES/AN.py b/src/holidata/holidays/ES/AN.py new file mode 100644 index 0000000..4c32833 --- /dev/null +++ b/src/holidata/holidays/ES/AN.py @@ -0,0 +1,86 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class AN(Region): + def __init__(self, country): + super().__init__("AN", country) + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2017, 2023]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de Andalucía") \ + .on(self.dia_de_andalucia) \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Asunción de la Virgen") \ + .in_years([2021]) \ + .on("08-16") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2019, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011, 2016, 2022]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta Nacional de España") \ + .in_years([2014]) \ + .on("10-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015, 2020]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def dia_de_andalucia(year): + if year == 2016: + return SmartDayArrow(year, 2, 29) + elif year == 2021: + return SmartDayArrow(year, 3, 1) + else: + return SmartDayArrow(year, 2, 28) diff --git a/src/holidata/holidays/ES/AR.py b/src/holidata/holidays/ES/AR.py new file mode 100644 index 0000000..9586f0a --- /dev/null +++ b/src/holidata/holidays/ES/AR.py @@ -0,0 +1,90 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class AR(Region): + def __init__(self, country): + super().__init__("AR", country) + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2017, 2023]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Jorge / Día de Aragón") \ + .on(self.holiday_san_jorge__dia_de_aragon) \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a San Jorge / Día de Aragón") \ + .in_years([2023]) \ + .on("04-24") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Asunción de la Virgen") \ + .in_years([2021]) \ + .on("08-16") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2019, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011, 2016, 2022]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta Nacional de España") \ + .in_years([2014]) \ + .on("10-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015, 2020]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def holiday_san_jorge__dia_de_aragon(year): + if year == 2017: + return SmartDayArrow(year, 4, 24) + else: + return SmartDayArrow(year, 4, 23) diff --git a/src/holidata/holidays/ES/AS.py b/src/holidata/holidays/ES/AS.py new file mode 100644 index 0000000..b39052b --- /dev/null +++ b/src/holidata/holidays/ES/AS.py @@ -0,0 +1,83 @@ +from holidata.holidays.holidays import Region + + +class AS(Region): + def __init__(self, country): + super().__init__("AS", country) + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2017, 2023]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Asunción de la Virgen") \ + .in_years([2021]) \ + .on("08-16") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de Asturias") \ + .except_for([2019]) \ + .on("09-08") \ + .with_flags("F"), + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de Asturias") \ + .in_years([2013, 2019, 2024]) \ + .on("09-09") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015, 2020]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2019, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011, 2016, 2022]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta Nacional de España") \ + .in_years([2014]) \ + .on("10-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/CB.py b/src/holidata/holidays/ES/CB.py new file mode 100644 index 0000000..930c862 --- /dev/null +++ b/src/holidata/holidays/ES/CB.py @@ -0,0 +1,78 @@ +from holidata.holidays.holidays import Region + + +class CB(Region): + def __init__(self, country): + super().__init__("CB", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de las Instituciones de Cantabria") \ + .in_years([2011, 2016, 2017, 2018, 2020, 2021, 2022, 2023]) \ + .on("07-28") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("La Bien Aparecida") \ + .in_years([2011, 2012, 2014, 2014, 2015, 2016, 2017, 2018, 2020, 2021, 2022, 2023]) \ + .on("09-15") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .in_years([2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021, 2022, 2023, 2024]) \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .in_years([2013, 2015, 2019, 2020, 2024]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Santiago Apóstol") \ + .in_years([2012, 2013, 2014, 2019]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Santiago Apóstol / Día Nacional de Galicia") \ + .in_years([2024]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2019]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/CE.py b/src/holidata/holidays/ES/CE.py new file mode 100644 index 0000000..791d325 --- /dev/null +++ b/src/holidata/holidays/ES/CE.py @@ -0,0 +1,98 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class CE(Region): + def __init__(self, country): + super().__init__("CE", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Nuestra Señora de África") \ + .in_years([2022, 2023, 2024]) \ + .on("08-05") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de Ceuta") \ + .in_years([2016, 2017, 2019, 2020, 2021, 2022, 2023]) \ + .on("09-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Fiesta del Sacrificio (Eidul Adha)") \ + .except_for([2011]) \ + .on(self.day_of_eidul_adha) \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Sacrificio (Eidul Adha)") \ + .in_years([2011]) \ + .on("11-07") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta Nacional de España") \ + .in_years([2014]) \ + .on("10-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def day_of_eidul_adha(year): + dates = { + 2012: SmartDayArrow(year, 10, 27), + 2013: SmartDayArrow(year, 10, 15), + 2014: SmartDayArrow(year, 10, 6), + 2015: SmartDayArrow(year, 9, 25), + 2016: SmartDayArrow(year, 9, 12), + 2017: SmartDayArrow(year, 9, 1), + 2018: SmartDayArrow(year, 8, 22), + 2019: SmartDayArrow(year, 8, 12), + 2020: SmartDayArrow(year, 7, 31), + 2021: SmartDayArrow(year, 7, 20), + 2022: SmartDayArrow(year, 7, 9), + 2023: SmartDayArrow(year, 6, 29), + 2024: SmartDayArrow(year, 6, 17), + } + + return dates[year] diff --git a/src/holidata/holidays/ES/CL.py b/src/holidata/holidays/ES/CL.py new file mode 100644 index 0000000..e8e2151 --- /dev/null +++ b/src/holidata/holidays/ES/CL.py @@ -0,0 +1,108 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class CL(Region): + def __init__(self, country): + super().__init__("CL", country) + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2017, 2023]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Fiesta de Castilla y León") \ + .on(self.day_fiesta_de_castilla_y_leon) \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2012]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Santiago Apóstol / Día Nacional de Galicia") \ + .in_years([2023]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Asunción de la Virgen") \ + .in_years([2021]) \ + .on("08-16") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta Nacional de España") \ + .in_years([2014]) \ + .on("10-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015, 2020]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2019, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .in_years([2018]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2016, 2022]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Santiago Apóstol") \ + .in_years([2011]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016, 2018]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def day_fiesta_de_castilla_y_leon(year): + if year == 2017: + return SmartDayArrow(year, 4, 24) + else: + return SmartDayArrow(year, 4, 23) diff --git a/src/holidata/holidays/ES/CM.py b/src/holidata/holidays/ES/CM.py new file mode 100644 index 0000000..c0e61bd --- /dev/null +++ b/src/holidata/holidays/ES/CM.py @@ -0,0 +1,59 @@ +from holidata.holidays.holidays import Region + + +class CM(Region): + def __init__(self, country): + super().__init__("CM", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de Castilla-La Mancha") \ + .except_for([2014, 2015, 2020]) \ + .on("05-31") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Corpus Christi") \ + .in_years([2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021, 2022, 2023, 2024]) \ + .on("60 days after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2011, 2020]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .in_years([2014, 2015, 2019, 2020]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/CN.py b/src/holidata/holidays/ES/CN.py new file mode 100644 index 0000000..43462ab --- /dev/null +++ b/src/holidata/holidays/ES/CN.py @@ -0,0 +1,65 @@ +from holidata.holidays.holidays import Region + + +class CN(Region): + def __init__(self, country): + super().__init__("CN", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de Canarias") \ + .except_for([2021]) \ + .on("05-30") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .in_years([2022]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2016]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Asunción de la Virgen") \ + .in_years([2021]) \ + .on("08-16") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/CT.py b/src/holidata/holidays/ES/CT.py new file mode 100644 index 0000000..42a85cd --- /dev/null +++ b/src/holidata/holidays/ES/CT.py @@ -0,0 +1,36 @@ +from holidata.holidays.holidays import Region + + +class CT(Region): + def __init__(self, country): + super().__init__("CT", country) + + self.define_holiday() \ + .with_name("San Juan") \ + .in_years([2011, 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021, 2022, 2023, 2024]) \ + .on("06-24") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Fiesta Nacional de Cataluña") \ + .except_for([2011, 2016, 2022]) \ + .on("09-11") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes de Pascua Granada") \ + .in_years([2011, 2016, 2022]) \ + .on("50 days after Easter") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .except_for([2018]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("San Esteban") \ + .except_for([2018, 2021]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/EX.py b/src/holidata/holidays/ES/EX.py new file mode 100644 index 0000000..db46c99 --- /dev/null +++ b/src/holidata/holidays/ES/EX.py @@ -0,0 +1,89 @@ +from holidata.holidays.holidays import Region + + +class EX(Region): + def __init__(self, country): + super().__init__("EX", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Martes de Carnaval") \ + .in_years([2023, 2024]) \ + .on("47 days before Easter") \ + .with_flags("V") + + self.define_holiday() \ + .with_name("Lunes siguiente a San José") \ + .in_years([2017]) \ + .on("03-20") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de Extremadura") \ + .except_for([2019, 2024]) \ + .on("09-08") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de Extremadura") \ + .in_years([2013, 2019]) \ + .on("09-09") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2021]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta Nacional de España") \ + .in_years([2014]) \ + .on("10-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015, 2020]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2019, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011, 2016, 2022]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/GA.py b/src/holidata/holidays/ES/GA.py new file mode 100644 index 0000000..e5b9064 --- /dev/null +++ b/src/holidata/holidays/ES/GA.py @@ -0,0 +1,47 @@ +from holidata.holidays.holidays import Region + + +class GA(Region): + def __init__(self, country): + super().__init__("GA", country) + + self.define_holiday() \ + .with_name("San Juan") \ + .in_years([2013, 2016, 2020, 2022]) \ + .on("06-24") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2011, 2019, 2020, 2021]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día siguiente a San José") \ + .in_years([2015]) \ + .on("03-20") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de las Letras Gallegas") \ + .except_for([2015, 2020]) \ + .on("05-17") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Santiago Apóstol / Día Nacional de Galicia") \ + .except_for([2021]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") diff --git a/src/holidata/holidays/ES/IB.py b/src/holidata/holidays/ES/IB.py new file mode 100644 index 0000000..9854874 --- /dev/null +++ b/src/holidata/holidays/ES/IB.py @@ -0,0 +1,47 @@ +from holidata.holidays.holidays import Region + + +class IB(Region): + def __init__(self, country): + super().__init__("IB", country) + + self.define_holiday() \ + .with_name("Día de las Illes Balears") \ + .in_years([2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2021, 2022, 2023, 2024]) \ + .on("03-01") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .except_for([2014]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2015]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2013, 2014, 2016, 2019, 2020]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/MC.py b/src/holidata/holidays/ES/MC.py new file mode 100644 index 0000000..1980900 --- /dev/null +++ b/src/holidata/holidays/ES/MC.py @@ -0,0 +1,79 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class MC(Region): + def __init__(self, country): + super().__init__("MC", country) + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2017, 2023]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de la Región de Murcia") \ + .except_for([2013, 2024]) \ + .on(self.dia_de_la_region_de_murcia) \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021, 2024]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .in_years([2023]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011, 2022]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2016]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def dia_de_la_region_de_murcia(year): + if year == 2019: + return SmartDayArrow(year, 6, 10) + else: + return SmartDayArrow(year, 6, 9) diff --git a/src/holidata/holidays/ES/MD.py b/src/holidata/holidays/ES/MD.py new file mode 100644 index 0000000..3e08c17 --- /dev/null +++ b/src/holidata/holidays/ES/MD.py @@ -0,0 +1,101 @@ +from holidata.holidays.holidays import Region + + +class MD(Region): + def __init__(self, country): + super().__init__("MD", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Traslado de San José") \ + .in_years([2013]) \ + .on("03-18") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a San José") \ + .in_years([2017, 2023]) \ + .on("03-20") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Fiesta de la Comunidad de Madrid") \ + .except_for([2016, 2021]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Comunidad de Madrid") \ + .in_years([2021]) \ + .on("05-03") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Corpus Christi") \ + .in_years([2011, 2014, 2015]) \ + .on("60 days after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2012, 2015, 2021, 2023]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2016]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Santiago Apóstol") \ + .in_years([2011, 2016, 2022]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Santiago Apóstol / Día Nacional de Galicia") \ + .in_years([2024]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a Todos los Santos") \ + .in_years([2020]) \ + .on("11-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2019]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/ML.py b/src/holidata/holidays/ES/ML.py new file mode 100644 index 0000000..6d50337 --- /dev/null +++ b/src/holidata/holidays/ES/ML.py @@ -0,0 +1,112 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class ML(Region): + def __init__(self, country): + super().__init__("ML", country) + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2017]) \ + .on("01-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Estatuto de Autonomía de la Ciudad de Melilla") \ + .in_years([2020, 2021]) \ + .on("03-13") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Fiesta del Eid Fitr") \ + .in_years([2022, 2023]) \ + .on(self.day_of_eid_fitr) \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Fiesta del Sacrificio (Aid Al Adha)") \ + .in_years([2022, 2023, 2024]) \ + .on(self.holiday_aid_al_adha) \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Fiesta del Sacrificio (Aid El Kebir)") \ + .until(2021) \ + .on(self.holiday_aid_el_kebir) \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2011, 2012, 2013, 2014, 2015, 2016]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2019, 2024]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def holiday_aid_el_kebir(year): + dates = { + 2011: SmartDayArrow(year, 11, 7), + 2012: SmartDayArrow(year, 10, 26), + 2013: SmartDayArrow(year, 10, 15), + 2014: SmartDayArrow(year, 10, 4), + 2015: SmartDayArrow(year, 9, 25), + 2016: SmartDayArrow(year, 9, 12), + 2017: SmartDayArrow(year, 9, 1), + 2018: SmartDayArrow(year, 8, 22), + 2019: SmartDayArrow(year, 8, 12), + 2020: SmartDayArrow(year, 7, 31), + 2021: SmartDayArrow(year, 7, 21), + } + return dates[year] + + @staticmethod + def holiday_aid_al_adha(year): + dates = { + 2022: SmartDayArrow(year, 7, 11), + 2023: SmartDayArrow(year, 6, 29), + 2024: SmartDayArrow(year, 6, 17), + } + return dates[year] + + @staticmethod + def day_of_eid_fitr(year): + dates = { + 2022: SmartDayArrow(year, 5, 3), + 2023: SmartDayArrow(year, 4, 21), + } + return dates[year] diff --git a/src/holidata/holidays/ES/NC.py b/src/holidata/holidays/ES/NC.py new file mode 100644 index 0000000..c45df0c --- /dev/null +++ b/src/holidata/holidays/ES/NC.py @@ -0,0 +1,58 @@ +from holidata.holidays.holidays import Region + + +class NC(Region): + def __init__(self, country): + super().__init__("NC", country) + + self.define_holiday() \ + .with_name("Lunes siguiente a la Epifanía del Señor") \ + .in_years([2013, 2019]) \ + .on("01-07") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2012, 2014, 2015, 2019, 2020, 2021]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Santiago Apóstol / Día Nacional de Galicia") \ + .in_years([2023, 2024]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Santiago Apóstol") \ + .in_years([2011, 2013, 2015, 2016, 2017, 2022]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2011, 2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/PV.py b/src/holidata/holidays/ES/PV.py new file mode 100644 index 0000000..fd5df59 --- /dev/null +++ b/src/holidata/holidays/ES/PV.py @@ -0,0 +1,54 @@ +from holidata.holidays.holidays import Region + + +class PV(Region): + def __init__(self, country): + super().__init__("PV", country) + + self.define_holiday() \ + .with_name("V Centenario Vuelta al Mundo") \ + .in_years([2022]) \ + .on("09-06") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("80º aniversario del primer Gobierno Vasco") \ + .in_years([2016]) \ + .on("10-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Día del País Vasco-Euskadiko Eguna") \ + .in_years([2011, 2012, 2013, 2014]) \ + .on("10-25") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2015, 2019, 2020, 2021]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .except_for([2012]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Santiago Apóstol") \ + .in_years([2011, 2013, 2015, 2016, 2017, 2019, 2020, 2022]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Santiago Apóstol / Día Nacional de Galicia") \ + .in_years([2023, 2024]) \ + .on("07-25") \ + .with_flags("RF") + diff --git a/src/holidata/holidays/ES/RI.py b/src/holidata/holidays/ES/RI.py new file mode 100644 index 0000000..1d68a02 --- /dev/null +++ b/src/holidata/holidays/ES/RI.py @@ -0,0 +1,67 @@ +from holidata.holidays.holidays import Region +from holidata.utils import SmartDayArrow + + +class RI(Region): + def __init__(self, country): + super().__init__("RI", country) + + self.define_holiday() \ + .with_name("Día de La Rioja") \ + .on(self.dia_de_la_rioja) \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de La Rioja") \ + .in_years([2024]) \ + .on("06-10") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2012]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .in_years([2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2024]) \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .except_for([2012, 2018]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Santiago Apóstol") \ + .in_years([2011, 2016]) \ + .on("07-25") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015, 2020]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente a La Inmaculada Concepción") \ + .in_years([2013, 2019]) \ + .on("12-09") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Natividad del Señor") \ + .in_years([2022]) \ + .on("12-26") \ + .with_flags("RF") + + @staticmethod + def dia_de_la_rioja(year): + if year in [2013, 2019]: + return SmartDayArrow(year, 6, 10) + else: + return SmartDayArrow(year, 6, 9) diff --git a/src/holidata/holidays/ES/VC.py b/src/holidata/holidays/ES/VC.py new file mode 100644 index 0000000..3662012 --- /dev/null +++ b/src/holidata/holidays/ES/VC.py @@ -0,0 +1,60 @@ +from holidata.holidays.holidays import Region + + +class VC(Region): + def __init__(self, country): + super().__init__("VC", country) + + self.define_holiday() \ + .with_name("Lunes de Fallas") \ + .in_years([2013]) \ + .on("03-18") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San Juan") \ + .in_years([2019, 2020, 2021, 2022, 2023, 2024]) \ + .on("06-24") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Día de la Comunitat Valenciana") \ + .except_for([2011, 2016, 2022]) \ + .on("10-09") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San José") \ + .in_years([2011, 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020, 2021, 2022, 2024]) \ + .on("03-19") \ + .with_flags("RF") + + self.define_holiday() \ + .with_name("Jueves Santo") \ + .in_years([2011, 2016, 2017, 2022, 2023]) \ + .on("3 days before Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes de Pascua") \ + .except_for([2023]) \ + .on("1 day after Easter") \ + .with_flags("RV") + + self.define_holiday() \ + .with_name("Lunes siguiente a la Fiesta del Trabajo") \ + .in_years([2011]) \ + .on("05-02") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("Lunes siguiente al Día de la Constitución Española") \ + .in_years([2015]) \ + .on("12-07") \ + .with_flags("F") + + self.define_holiday() \ + .with_name("San Esteban") \ + .in_years([2016]) \ + .on("12-26") \ + .with_flags("RF") diff --git a/src/holidata/holidays/ES/__init__.py b/src/holidata/holidays/ES/__init__.py index 04f9086..21fd1e5 100644 --- a/src/holidata/holidays/ES/__init__.py +++ b/src/holidata/holidays/ES/__init__.py @@ -1,15 +1,151 @@ from dateutil.easter import EASTER_WESTERN +from holidata.holidays.ES.AN import AN +from holidata.holidays.ES.AR import AR +from holidata.holidays.ES.AS import AS +from holidata.holidays.ES.CB import CB +from holidata.holidays.ES.CE import CE +from holidata.holidays.ES.CL import CL +from holidata.holidays.ES.CM import CM +from holidata.holidays.ES.CN import CN +from holidata.holidays.ES.CT import CT +from holidata.holidays.ES.EX import EX +from holidata.holidays.ES.GA import GA +from holidata.holidays.ES.IB import IB +from holidata.holidays.ES.MC import MC +from holidata.holidays.ES.MD import MD +from holidata.holidays.ES.ML import ML +from holidata.holidays.ES.NC import NC +from holidata.holidays.ES.PV import PV +from holidata.holidays.ES.RI import RI +from holidata.holidays.ES.VC import VC from holidata.holidays.holidays import Country __all__ = [ - "ES", - "es-ES", + "ES" ] +""" +Information taken from government websites around 2020-06 + https://administracion.gob.es/pag_Home/atencionCiudadana/calendarios/laboral.html + http://www.seg-social.es/wps/portal/wss/internet/CalendarioLaboral + + 2011: https://www.boe.es/eli/es/res/2010/10/07/(1) + https://www.boe.es/eli/es/res/2010/11/24/(1) + 2012: https://www.boe.es/eli/es/res/2011/10/06/(1) + 2013: https://www.boe.es/eli/es/res/2012/10/30/(1) + https://www.boe.es/eli/es/res/2012/11/12/(2) + 2014: https://www.boe.es/eli/es/res/2013/11/08/(3) + https://www.boe.es/eli/es/res/2013/11/21/(1) + 2015: https://www.boe.es/eli/es/res/2014/10/17/(3) + 2016: https://www.boe.es/eli/es/res/2015/10/19/(1) + 2017: https://www.boe.es/eli/es/res/2016/10/04/(1) + 2018: https://www.boe.es/eli/es/res/2017/10/09/(1) + https://www.boe.es/eli/es/res/2017/10/09/(1)/corrigendum/20171019 + https://www.boe.es/eli/es/res/2017/10/09/(1)/corrigendum/20171025 + 2019: https://www.boe.es/eli/es/res/2018/10/16/(1) + 2020: https://www.boe.es/eli/es/res/2019/10/03/(1) + 2021: https://www.boe.es/eli/es/res/2020/10/28/(1) + 2022: https://www.boe.es/eli/es/res/2021/10/14/(3) + 2023: https://www.boe.es/eli/es/res/2022/10/07/(2) + 2024: https://www.boe.es/eli/es/res/2023/10/23/(1) + +Regional governments + [AN] https://www.juntadeandalucia.es/temas/trabajar/relaciones/calendario.html + +Also those sites for some information + https://es.wikipedia.org/wiki/Calendario_laboral +""" + class ES(Country): id = "ES" languages = ["es"] default_lang = "es" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.regions = [ + AN(self), + AR(self), + AS(self), + CB(self), + CE(self), + CL(self), + CM(self), + CN(self), + CT(self), + EX(self), + GA(self), + IB(self), + MC(self), + MD(self), + ML(self), + NC(self), + PV(self), + RI(self), + VC(self), + ] + + self.define_holiday() \ + .with_name("Año Nuevo") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Epifanía del Señor") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Fiesta del Trabajo") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Asunción de la Virgen") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Fiesta Nacional de España") \ + .on("10-12") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Todos los Santos") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Día de la Constitución Española") \ + .on("12-06") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Inmaculada Concepción") \ + .on("12-08") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Natividad del Señor") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Viernes Santo") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pascua") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Lunes siguiente al Año Nuevo") \ + .in_years([2012]) \ + .on("01-02") \ + .with_flags("NF") diff --git a/src/holidata/holidays/ES/es-ES.py b/src/holidata/holidays/ES/es-ES.py deleted file mode 100644 index 94cc9f2..0000000 --- a/src/holidata/holidays/ES/es-ES.py +++ /dev/null @@ -1,982 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow, easter -from holidata.holidays.holidays import Locale, Holiday - -""" -Information taken from government websites around 2020-06 - https://administracion.gob.es/pag_Home/atencionCiudadana/calendarios/laboral.html - http://www.seg-social.es/wps/portal/wss/internet/CalendarioLaboral - - 2011: https://www.boe.es/eli/es/res/2010/10/07/(1) - https://www.boe.es/eli/es/res/2010/11/24/(1) - 2012: https://www.boe.es/eli/es/res/2011/10/06/(1) - 2013: https://www.boe.es/eli/es/res/2012/10/30/(1) - https://www.boe.es/eli/es/res/2012/11/12/(2) - 2014: https://www.boe.es/eli/es/res/2013/11/08/(3) - https://www.boe.es/eli/es/res/2013/11/21/(1) - 2015: https://www.boe.es/eli/es/res/2014/10/17/(3) - 2016: https://www.boe.es/eli/es/res/2015/10/19/(1) - 2017: https://www.boe.es/eli/es/res/2016/10/04/(1) - 2018: https://www.boe.es/eli/es/res/2017/10/09/(1) - https://www.boe.es/eli/es/res/2017/10/09/(1)/corrigendum/20171019 - https://www.boe.es/eli/es/res/2017/10/09/(1)/corrigendum/20171025 - 2019: https://www.boe.es/eli/es/res/2018/10/16/(1) - 2020: https://www.boe.es/eli/es/res/2019/10/03/(1) - 2021: https://www.boe.es/eli/es/res/2020/10/28/(1) - 2022: https://www.boe.es/eli/es/res/2021/10/14/(3) - 2023: https://www.boe.es/eli/es/res/2022/10/07/(2) - 2024: https://www.boe.es/eli/es/res/2023/10/23/(1) - -Regional governments - [AN] https://www.juntadeandalucia.es/temas/trabajar/relaciones/calendario.html - -Also those sites for some information - https://es.wikipedia.org/wiki/Calendario_laboral -""" - - -class es_ES(Locale): - """ - 01-01: [NF] Año Nuevo - 01-06: [NRF] Epifanía del Señor - 05-01: [NF] Fiesta del Trabajo - 08-15: [NRF] Asunción de la Virgen - 10-12: [NF] Fiesta Nacional de España - 11-01: [NRF] Todos los Santos - 12-06: [NF] Día de la Constitución Española - 12-08: [NRF] Inmaculada Concepción - 12-25: [NRF] Natividad del Señor - 2 days before Easter: [NRV] Viernes Santo - Easter: [NRV] Pascua - """ - - id = "es-ES" - easter_type = EASTER_WESTERN - - def holiday_lunes_siguiente_al_ano_nuevo(self, year): - if year == 2012: - regions = [""] - elif year == 2017: - regions = ["AN", "AR", "AS", "CL", "MC", "ML"] - elif year == 2023: - regions = ["AN", "AR", "AS", "CL", "MC"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 1, 1).shift_to_weekday("monday", including=True), - "Lunes siguiente al Año Nuevo", - "NF" if regions == [""] else "F" - ) for region in regions] - - def holiday_lunes_siguiente_a_la_epifania_del_senor(self, year): - if year == 2013: - regions = ["AN", "AR", "AS", "CB", "CE", "CL", "CM", "CN", "EX", "MC", "MD", "ML", "NC"] - elif year == 2019: - regions = ["AN", "AR", "AS", "CE", "CL", "CN", "EX", "MC", "MD", "ML", "NC"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 1, 6).shift_to_weekday("monday", including=True), - "Lunes siguiente a la Epifanía del Señor", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_martes_de_carnaval(self, year): - if year in [2023, 2024]: - return [Holiday( - self.id, - "EX", - easter(year, self.easter_type).shift(days=-47), - "Martes de Carnaval", - "V" - )] - - return [] - - def holiday_dia_de_andalucia(self, year): - if year == 2016: - date = SmartDayArrow(year, 2, 29) - elif year == 2021: - date = SmartDayArrow(year, 3, 1) - else: - date = SmartDayArrow(year, 2, 28) - - return [Holiday( - self.id, - "AN", - date, - "Día de Andalucía", - "F" - )] - - def holiday_dia_de_las_illes_balears(self, year): - if year in [2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2021, 2022, 2023, 2024]: - return [Holiday( - self.id, - "IB", - SmartDayArrow(year, 3, 1), - "Día de las Illes Balears", - "F" - )] - - return [] - - def holiday_estatuto_de_autonomia_de_la_ciudad_de_melilla(self, year): - if year in [2020, 2021]: - return [Holiday( - self.id, - "ML", - SmartDayArrow(year, 3, 13), - "Estatuto de Autonomía de la Ciudad de Melilla", - "F" - )] - - return [] - - def holiday_san_jose(self, year): - if year == 2011: - regions = ["CM", "GA", "MC", "ML", "VC"] - elif year == 2012: - regions = ["CL", "MC", "MD", "ML", "NC", "RI", "VC"] - elif year == 2013: - regions = ["MC", "ML", "VC"] - elif year == 2014: - regions = ["MC", "ML", "NC", "VC"] - elif year == 2015: - regions = ["MC", "MD", "ML", "NC", "PV", "VC"] - elif year == 2016: - regions = ["MC", "ML", "VC"] - elif year == 2018: - regions = ["MC", "VC"] - elif year == 2019: - regions = ["GA", "MC", "NC", "PV", "VC"] - elif year == 2020: - regions = ["CM", "GA", "MC", "NC", "PV", "VC"] - elif year == 2021: - regions = ["EX", "GA", "MC", "MD", "NC", "PV", "VC"] - elif year == 2022: - regions = ["VC"] - elif year == 2023: - regions = ["MD"] - elif year == 2024: - regions = ["MC", "VC"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 3, 19), - "San José", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_lunes_de_fallas(self, year): - if year == 2013: - return [Holiday( - self.id, - "VC", - SmartDayArrow(year, 3, 18), - "Lunes de Fallas", - "F" - )] - - return [] - - def holiday_traslado_de_san_jose(self, year): - if year == 2013: - return [Holiday( - self.id, - "MD", - SmartDayArrow(year, 3, 18), - "Traslado de San José", - "F" - )] - - return [] - - def holiday_dia_siguente_a_san_jose(self, year): - if year == 2015: - return [Holiday( - self.id, - "GA", - SmartDayArrow(year, 3, 20), - "Día siguiente a San José", - "RF" - )] - - return [] - - def holiday_lunes_siguiente_a_san_jose(self, year): - if year == 2017: - regions = ["EX", "MD"] - elif year == 2023: - regions = ["MD"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 3, 19).shift_to_weekday("monday", True), - "Lunes siguiente a San José", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_san_jorge__dia_de_aragon(self, year): - if year == 2017: - date = SmartDayArrow(year, 4, 24) - else: - date = SmartDayArrow(year, 4, 23) - - return [Holiday( - self.id, - "AR", - date, - "San Jorge / Día de Aragón", - "RF" - )] - - def holiday_lunes_siguiente_a_san_jorge__dia_de_aragon(self, year): - if year == 2023: - date = SmartDayArrow(year, 4, 24) - else: - return [] - - return [Holiday( - self.id, - "AR", - date, - "Lunes siguiente a San Jorge / Día de Aragón", - "RF" - )] - - def holiday_fiesta_de_castilla_y_leon(self, year): - if year == 2017: - date = SmartDayArrow(year, 4, 24) - else: - date = SmartDayArrow(year, 4, 23) - - return [Holiday( - self.id, - "CL", - date, - "Fiesta de Castilla y León", - "F" - )] - - def holiday_lunes_siguiente_a_la_fiesta_del_trabajo(self, year): - if year == 2011: - regions = ["AN", "AR", "AS", "CB", "CE", "EX", "MC", "VC"] - elif year == 2016: - regions = ["AN", "AR", "AS", "CL", "CN", "EX", "MD"] - elif year == 2022: - regions = ["AN", "AR", "AS", "CL", "EX", "MC"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 5, 1).shift_to_weekday("monday", including=True), - "Lunes siguiente a la Fiesta del Trabajo", - "NF" if regions == [""] else "F" - ) for region in regions] - - def holiday_fiesta_de_la_comunidad_de_madrid(self, year): - if year in [2016, 2021]: - return [] - else: - return [Holiday( - self.id, - "MD", - SmartDayArrow(year, 5, 2), - "Fiesta de la Comunidad de Madrid", - "F" - )] - - def holiday_lunes_siguiente_al_dia_de_la_comunidad_de_madrid(self, year): - if year in [2021]: - return [Holiday( - self.id, - "MD", - SmartDayArrow(year, 5, 2).shift_to_weekday("monday", including=True), - "Lunes siguiente al Día de la Comunidad de Madrid", - "F" - )] - else: - return [] - - def holiday_dia_de_las_letras_gallegas(self, year): - if year in [2015, 2020]: - return [] - else: - return [Holiday( - self.id, - "GA", - SmartDayArrow(year, 5, 17), - "Día de las Letras Gallegas", - "F" - )] - - def holiday_dia_de_canarias(self, year): - if year in [2021]: - return [] - else: - return [Holiday( - self.id, - "CN", - SmartDayArrow(year, 5, 30), - "Día de Canarias", - "F" - )] - - def holiday_dia_de_castilla_la_mancha(self, year): - if year in [2014, 2015, 2020]: - return [] - else: - return [Holiday( - self.id, - "CM", - SmartDayArrow(year, 5, 31), - "Día de Castilla-La Mancha", - "F" - )] - - def holiday_dia_de_la_region_de_murcia(self, year): - if year in [2013, 2024]: - return [] - elif year == 2019: - date = SmartDayArrow(year, 6, 10) - else: - date = SmartDayArrow(year, 6, 9) - - return [Holiday( - self.id, - "MC", - date, - "Día de la Región de Murcia", - "F" - )] - - def holiday_dia_de_la_rioja(self, year): - if year in [2013, 2019]: - date = SmartDayArrow(year, 6, 10) - else: - date = SmartDayArrow(year, 6, 9) - - if date is not None: - return [Holiday( - self.id, - "RI", - date, - "Día de La Rioja", - "F" - )] - else: - return [] - - def holiday_lunes_siguiente_al_dia_de_la_rioja(self, year): - if year == 2024: - return [Holiday( - self.id, - "RI", - SmartDayArrow(year, 6, 10), - "Lunes siguiente al Día de La Rioja", - "F" - )] - - return [] - - def holiday_san_juan(self, year): - if year == 2011: - regions = ["CT"] - elif year == 2013: - regions = ["CT", "GA"] - elif year == 2014: - regions = ["CT"] - elif year == 2015: - regions = ["CT"] - elif year == 2016: - regions = ["CT", "GA"] - elif year == 2017: - regions = ["CT"] - elif year == 2019: - regions = ["CT", "VC"] - elif year == 2020: - regions = ["CT", "GA", "VC"] - elif year == 2021: - regions = ["CT", "VC"] - elif year == 2022: - regions = ["CT", "GA", "VC"] - elif year == 2023: - regions = ["CT", "VC"] - elif year == 2024: - regions = ["CT", "VC"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 6, 24), - "San Juan", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_santiago_apostol__dia_nacional_de_galicia(self, year): - if year == 2021: - return [] - elif year == 2023: - regions = ["CL", "GA", "NC", "PV"] - elif year == 2024: - regions = ["CB", "GA", "MD", "NC", "PV"] - else: - regions = ["GA"] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 7, 25), - "Santiago Apóstol / Día Nacional de Galicia", - "RF" - ) for region in regions] - - def holiday_santiago_apostol(self, year): - if year == 2011: - regions = ["CL", "MD", "NC", "PV", "RI"] - elif year == 2012: - regions = ["CB"] - elif year == 2013: - regions = ["CB", "NC", "PV"] - elif year == 2014: - regions = ["CB"] - elif year == 2015: - regions = ["NC", "PV"] - elif year == 2016: - regions = ["MD", "NC", "PV", "RI"] - elif year == 2017: - regions = ["NC", "PV"] - elif year == 2019: - regions = ["CB", "PV"] - elif year == 2020: - regions = ["PV"] - elif year == 2022: - regions = ["MD", "NC", "PV"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 7, 25), - "Santiago Apóstol", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_dia_de_las_instituciones_de_cantabria(self, year): - if year in [2011, 2016, 2017, 2018, 2020, 2021, 2022, 2023]: - return [Holiday( - self.id, - "CB", - SmartDayArrow(year, 7, 28), - "Día de las Instituciones de Cantabria", - "F" - )] - else: - return [] - - def holiday_nuestra_senora_de_africa(self, year): - if year in [2022, 2023, 2024]: - return [Holiday( - self.id, - "CE", - SmartDayArrow(year, 8, 5), - "Nuestra Señora de África", - "RF" - )] - else: - return [] - - def holiday_lunes_siguiente_a_la_asuncion_de_la_virgen(self, year): - if year == 2021: - regions = ["AN", "AR", "AS", "CL", "CN"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 8, 15).shift_to_weekday("monday", including=True), - "Lunes siguiente a la Asunción de la Virgen", - "RF" - ) for region in regions] - - def holiday_dia_de_ceuta(self, year): - if year in [2016, 2017, 2019, 2020, 2021, 2022, 2023]: - return [Holiday( - self.id, - "CE", - SmartDayArrow(year, 9, 2), - "Día de Ceuta", - "F" - )] - else: - return [] - - def holiday_v_centenario_vuelta_al_mundo(self, year): - if year == 2022: - return [Holiday( - self.id, - "PV", - SmartDayArrow(year, 9, 6), - "V Centenario Vuelta al Mundo", - "F" - )] - else: - return [] - - def holiday_dia_de_asturias(self, year): - if year in [2019]: - return [] - else: - return [Holiday( - self.id, - "AS", - SmartDayArrow(year, 9, 8), - "Día de Asturias", - "F" - )] - - def holiday_lunes_siguiente_al_dia_de_asturias(self, year): - if year in [2013, 2019, 2024]: - return [Holiday( - self.id, - "AS", - SmartDayArrow(year, 9, 8).shift_to_weekday("monday", including=True), - "Lunes siguiente al Día de Asturias", - "F" - )] - else: - return [] - - def holiday_dia_de_extremadura(self, year): - if year in [2019, 2024]: - return [] - else: - return [Holiday( - self.id, - "EX", - SmartDayArrow(year, 9, 8), - "Día de Extremadura", - "F" - )] - - def holiday_lunes_siguiente_al_dia_de_extremadura(self, year): - if year in [2013, 2019]: - return [Holiday( - self.id, - "EX", - SmartDayArrow(year, 9, 8).shift_to_weekday("monday", including=True), - "Lunes siguiente al Día de Extremadura", - "F" - )] - else: - return [] - - def holiday_fiesta_nacional_de_cataluna(self, year): - if year in [2011, 2016, 2022]: - return [] - else: - return [Holiday( - self.id, - "CT", - SmartDayArrow(year, 9, 11), - "Fiesta Nacional de Cataluña", - "F" - )] - - def holiday_la_bien_aparecida(self, year): - if year in [2011, 2012, 2014, 2014, 2015, 2016, 2017, 2018, 2020, 2021, 2022, 2023]: - return [Holiday( - self.id, - "CB", - SmartDayArrow(year, 9, 15), - "La Bien Aparecida", - "RF")] - else: - return [] - - def holiday_80_aniversario_del_primer_gobierno_vasco(self, year): - if year in [2016]: - return [Holiday( - self.id, - "PV", - SmartDayArrow(year, 10, 7), - "80º aniversario del primer Gobierno Vasco", - "F" - )] - else: - return [] - - def holiday_dia_de_la_comunitat_valenciana(self, year): - if year in [2011, 2016, 2022]: - return [] - else: - return [Holiday( - self.id, - "VC", - SmartDayArrow(year, 10, 9), - "Día de la Comunitat Valenciana", - "F" - )] - - def holiday_lunes_siguiente_a_la_fiesta_nacional_de_espana(self, year): - if year == 2014: - regions = ["AN", "AR", "AS", "CE", "CL", "EX"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 10, 12).shift_to_weekday("monday", including=True), - "Lunes siguiente a la Fiesta Nacional de España", - "F" - ) for region in regions] - - def holiday_dia_del_pais_vasco_euskadiko_eguna(self, year): - if year in [2011, 2012, 2013, 2014]: - return [Holiday( - self.id, - "PV", - SmartDayArrow(year, 10, 25), - "Día del País Vasco-Euskadiko Eguna", - "F" - )] - else: - return [] - - def holiday_lunes_siguiente_a_todos_los_santos(self, year): - if year == 2015: - regions = ["AN", "AR", "AS", "CB", "CE", "CL", "CN", "EX", "GA", "IB"] - elif year == 2020: - regions = ["AN", "AR", "AS", "CL", "EX", "MD"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 11, 1).shift_to_weekday("monday", including=True), - "Lunes siguiente a Todos los Santos", - "F" - ) for region in regions] - - def holiday_lunes_siguiente_al_dia_de_la_constitucion_espanola(self, year): - if year == 2015: - regions = ["AN", "AR", "AS", "CE", "CL", "CM", "EX", "IB", "MC", "ML", "RI", "VC"] - elif year == 2020: - regions = ["AN", "AR", "AS", "CE", "CL", "CN", "EX", "IB", "MC", "MD", "ML", "NC", "RI"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 12, 6).shift_to_weekday("monday", including=True), - "Lunes siguiente al Día de la Constitución Española", - "F" - ) for region in regions] - - def holiday_lunes_siguiente_a_la_inmaculada_concepcion(self, year): - if year == 2013: - regions = ["AN", "AR", "AS", "CE", "CL", "EX", "MC", "RI"] - elif year == 2019: - regions = ["AN", "AR", "AS", "CB", "CL", "EX", "MD", "ML", "RI"] - elif year == 2024: - regions = ["AN", "AR", "AS", "CL", "EX", "MC", "ML"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 12, 8).shift_to_weekday("monday", including=True), - "Lunes siguiente a La Inmaculada Concepción", - "RF" - ) for region in regions] - - def holiday_lunes_siguiente_a_la_natividad_del_senor(self, year): - if year == 2022: - regions = ["AN", "AR", "AS", "CB", "CL", "CM", "CN", "EX", "IB", "MC", "MD", "ML", "NC", "RI"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 12, 26), - "Lunes siguiente a la Natividad del Señor", - "RF" - ) for region in regions] - - def holiday_san_esteban(self, year): - if year == 2011: - regions = ["AN", "AR", "AS", "CE", "CL", "CN", "CT", "EX", "IB", "ML", "NC"] - elif year == 2012: - regions = ["CT"] - elif year == 2013: - regions = ["CT", "IB"] - elif year == 2014: - regions = ["CT", "IB"] - elif year == 2015: - regions = ["CT"] - elif year == 2016: - regions = ["AN", "AR", "AS", "CB", "CE", "CL", "CM", "CT", "EX", "IB", "MC", "MD", "ML", "NC", "VC"] - elif year == 2017: - regions = ["CT"] - elif year == 2018: - regions = ["CL"] - elif year == 2019: - regions = ["CT", "IB"] - elif year == 2020: - regions = ["CT", "IB"] - elif year == 2022: - regions = ["CT"] - elif year == 2023: - regions = ["CT"] - elif year == 2024: - regions = ["CT"] - else: - return [] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 12, 26), - "San Esteban", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_jueves_santo(self, year): - if year in [2011, 2016, 2017, 2022]: - regions = ["AN", "AR", "AS", "CB", "CE", "CL", "CM", "CN", "EX", "GA", "IB", "MC", "MD", "ML", "NC", "PV", "RI", "VC"] - elif year in [2012, 2013, 2014, 2015, 2019, 2020, 2021, 2024]: - regions = ["AN", "AR", "AS", "CB", "CE", "CL", "CM", "CN", "EX", "GA", "IB", "MC", "MD", "ML", "NC", "PV", "RI"] - elif year in [2018]: - regions = ["AN", "AR", "AS", "CE", "CL", "CM", "CN", "EX", "GA", "IB", "MC", "MD", "ML", "NC", "PV", "RI"] - elif year in [2023]: - regions = ["AN", "AR", "AS", "CB", "CE", "CL", "CM", "CN", "EX", "GA", "IB", "MC", "MD", "ML", "NC", "PV", "VC"] - else: - return [] - - return [Holiday( - self.id, - region, - easter(year, self.easter_type).shift(days=-3), - "Jueves Santo", - "NRV" if regions == [""] else "RV" - ) for region in regions] - - def holiday_lunes_de_pascua(self, year): - if year == 2011: - regions = ["CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2012: - regions = ["CT", "IB", "NC", "VC"] - elif year == 2013: - regions = ["CB", "CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2014: - regions = ["CM", "CT", "NC", "PV", "RI", "VC"] - elif year == 2015: - regions = ["CB", "CM", "CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2016: - regions = ["CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2017: - regions = ["CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2018: - regions = ["CL", "IB", "NC", "PV", "VC"] - elif year == 2019: - regions = ["CB", "CM", "CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2020: - regions = ["CB", "CM", "CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2021: - regions = ["CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2022: - regions = ["CN", "CT", "IB", "NC", "PV", "RI", "VC"] - elif year == 2023: - regions = ["CT", "IB", "MC", "NC", "PV", "RI"] - elif year == 2024: - regions = ["CB", "CT", "IB", "NC", "PV", "RI", "VC"] - else: - return [] - - return [Holiday( - self.id, - region, - easter(year, self.easter_type).shift_to_weekday("monday", including=True), - "Lunes de Pascua", - "NRV" if regions == [""] else "RV" - ) for region in regions] - - def holiday_lunes_de_pascua_granada(self, year): - if year == 2011: - date = SmartDayArrow(year, 6, 13) - elif year == 2016: - date = SmartDayArrow(year, 5, 16) - elif year == 2022: - date = SmartDayArrow(year, 6, 6) - else: - return [] - - return [Holiday( - self.id, - "CT", - date, - "Lunes de Pascua Granada", - "F" - )] - - def holiday_corpus_christi(self, year): - if year in [2012, 2013, 2016, 2017, 2019, 2020, 2021, 2022, 2023, 2024]: - regions = ["CM"] - elif year in [2011, 2014, 2015]: - regions = ["CM", "MD"] - else: - return [] - - return [Holiday( - self.id, - region, - easter(year, self.easter_type).shift(days=60), - "Corpus Christi", - "RV" - ) for region in regions] - - def holiday_eid_fitr(self, year): - if year == 2022: - date = SmartDayArrow(year, 5, 3) - elif year == 2023: - date = SmartDayArrow(year, 4, 21) - else: - return [] - - return [Holiday( - self.id, - "ML", - date, - "Fiesta del Eid Fitr", - "RV" - )] - - def holiday_eidul_adha(self, year): - if year == 2012: - date = SmartDayArrow(year, 10, 27) - elif year == 2013: - date = SmartDayArrow(year, 10, 15) - elif year == 2014: - date = SmartDayArrow(year, 10, 6) - elif year == 2015: - date = SmartDayArrow(year, 9, 25) - elif year == 2016: - date = SmartDayArrow(year, 9, 12) - elif year == 2017: - date = SmartDayArrow(year, 9, 1) - elif year == 2018: - date = SmartDayArrow(year, 8, 22) - elif year == 2019: - date = SmartDayArrow(year, 8, 12) - elif year == 2020: - date = SmartDayArrow(year, 7, 31) - elif year == 2021: - date = SmartDayArrow(year, 7, 20) - elif year == 2022: - date = SmartDayArrow(year, 7, 9) - elif year == 2023: - date = SmartDayArrow(year, 6, 29) - elif year == 2024: - date = SmartDayArrow(year, 6, 17) - else: - return [] - - return [Holiday( - self.id, - "CE", - date, - "Fiesta del Sacrificio (Eidul Adha)", - "RV" - )] - - def holiday_aid_al_adha(self, year): - if year == 2022: - date = SmartDayArrow(year, 7, 11) - elif year == 2023: - date = SmartDayArrow(year, 6, 29) - elif year == 2024: - date = SmartDayArrow(year, 6, 17) - else: - return [] - - return [Holiday( - self.id, - "ML", - date, - "Fiesta del Sacrificio (Aid Al Adha)", - "RV" - )] - - def holiday_lunes_siguiente_al_eidul_adha(self, year): - if year == 2011: - date = SmartDayArrow(year, 11, 7) - else: - return [] - - return [Holiday( - self.id, - "CE", - date, - "Lunes siguiente a la Fiesta del Sacrificio (Eidul Adha)", - "RV" - )] - - def holiday_aid_el_kebir(self, year): - if year == 2011: - date = SmartDayArrow(year, 11, 7) - elif year == 2012: - date = SmartDayArrow(year, 10, 26) - elif year == 2013: - date = SmartDayArrow(year, 10, 15) - elif year == 2014: - date = SmartDayArrow(year, 10, 4) - elif year == 2015: - date = SmartDayArrow(year, 9, 25) - elif year == 2016: - date = SmartDayArrow(year, 9, 12) - elif year == 2017: - date = SmartDayArrow(year, 9, 1) - elif year == 2018: - date = SmartDayArrow(year, 8, 22) - elif year == 2019: - date = SmartDayArrow(year, 8, 12) - elif year == 2020: - date = SmartDayArrow(year, 7, 31) - elif year == 2021: - date = SmartDayArrow(year, 7, 21) - else: - return [] - - return [Holiday( - self.id, - "ML", - date, - "Fiesta del Sacrificio (Aid El Kebir)", - "RV" - )] diff --git a/src/holidata/holidays/FI.py b/src/holidata/holidays/FI.py index f648949..870a947 100644 --- a/src/holidata/holidays/FI.py +++ b/src/holidata/holidays/FI.py @@ -1,9 +1,135 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country +""" +source: https://almanakka.helsinki.fi/en/flag-days-and-holidays-in-finland.html +""" + class FI(Country): id = "FI" languages = ["fi", "sv"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_names({ + "fi": "Uudenvuodenpäivä", + "sv": "Nyårsdagen", + }) \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "fi": "Loppiainen", + "sv": "Trettondedagen", + }) \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "fi": "Vappu", + "sv": "Första maj", + }) \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "fi": "Itsenäisyyspäivä", + "sv": "Självständighetsdagen", + }) \ + .on("12-06") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "fi": "Joulupäivä", + "sv": "Juldagen", + }) \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "fi": "Tapaninpäivä", + "sv": "Annandag jul", + }) \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "fi": "Pitkäperjantai", + "sv": "Långfredagen", + }) \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "fi": "Pääsiäispäivä", + "sv": "Påskdagen", + }) \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "fi": "2. pääsiäispäivä", + "sv": "Annandag påsk", + }) \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "fi": "Helatorstai", + "sv": "Kristi himmelfärdsdag", + }) \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_names({ + "fi": "Helluntaipäivä", + "sv": "Pingst", + }) \ + .on("49 days after Easter") \ + .with_flags("NRV") + + """ + Saturday between 20 and 26 June: Midsummer Day + """ + self.define_holiday() \ + .with_names({ + "fi": "Juhannuspäivä", + "sv": "Midsommardagen", + }) \ + .on(self.midsummer_day) \ + .with_flags("NRV") + + """ + Saturday between 31 October and 6 November: All Saints' Day + """ + self.define_holiday() \ + .with_names({ + "fi": "Pyhäinpäivä", + "sv": "Alla helgons dag", + }) \ + .on(self.all_saints_day) \ + .with_flags("NRV") + + @staticmethod + def midsummer_day(year): + return SmartDayArrow(year, 6, 19).shift_to_weekday("saturday", order=1, reverse=False) + + @staticmethod + def all_saints_day(year): + return SmartDayArrow(year, 10, 30).shift_to_weekday("saturday", order=1, reverse=False) diff --git a/src/holidata/holidays/FR.py b/src/holidata/holidays/FR.py index 4b046fb..8cacb7b 100644 --- a/src/holidata/holidays/FR.py +++ b/src/holidata/holidays/FR.py @@ -8,3 +8,66 @@ class FR(Country): languages = ["fr"] default_lang = "fr" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Jour de l'an") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Fête du premier mai") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Armistice 1945") \ + .on("05-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Fête nationale") \ + .on("07-14") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Assomption") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Toussaint") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Armistice 1918") \ + .on("11-11") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Noël") \ + .on("12-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Lundi de Pâques") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Ascension") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pentecôte") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Lundi de Pentecôte") \ + .on("50 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/GB.py b/src/holidata/holidays/GB.py index d1310bd..6a5ba51 100644 --- a/src/holidata/holidays/GB.py +++ b/src/holidata/holidays/GB.py @@ -1,5 +1,6 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import month_reference, SmartDayArrow from .holidays import Country @@ -8,3 +9,162 @@ class GB(Country): languages = ["en"] default_lang = "en" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("New Year's Day") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("New Year's Day (observed)") \ + .on(self.monday_after(month=1, day=1)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_weekend(month=1, day=1)) + + self.define_holiday() \ + .with_name("Christmas Day") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Christmas Day (observed)") \ + .on(self.monday_after(month=12, day=25)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_saturday(month=12, day=25)) + + self.define_holiday() \ + .with_name("Christmas Day (observed)") \ + .on(self.tuesday_after(month=12, day=25)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_sunday(month=12, day=25)) + + self.define_holiday() \ + .with_name("Boxing Day") \ + .on("12-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Boxing Day (observed)") \ + .on(self.monday_after(month=12, day=26)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_saturday(month=12, day=26)) + + self.define_holiday() \ + .with_name("Boxing Day (observed)") \ + .on(self.tuesday_after(month=12, day=26)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_sunday(month=12, day=26)) + + self.define_holiday() \ + .with_name("Good Friday") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Easter Monday") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Early May Bank Holiday") \ + .on("1. monday in may") \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("August Bank Holiday") \ + .on("1. last monday in august") \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Spring Bank Holiday") \ + .on(self.date_of_spring_bank_holiday) \ + .with_flags("NV") + + """ + 2023-05-08: Bank holiday for the coronation of King Charles III + """ + self.define_holiday() \ + .with_name("Coronation of King Charles III") \ + .in_years([2023]) \ + .on("05-08") \ + .with_flags("NV") + + """ + 2012-06-05: Queen's Diamond Jubilee + """ + self.define_holiday() \ + .with_name("Queen's Diamond Jubilee") \ + .in_years([2012]) \ + .on("06-05") \ + .with_flags("NV") + + """ + 2022-06-03: Queen's Platinum Jubilee + """ + self.define_holiday() \ + .with_name("Queen's Platinum Jubilee") \ + .in_years([2022]) \ + .on("06-03") \ + .with_flags("NV") + + """ + 2022-09-19: State Funeral of Queen Elizabeth II + """ + self.define_holiday() \ + .with_name("State Funeral of Queen Elizabeth II") \ + .in_years([2022]) \ + .on("09-19") \ + .with_flags("NF") + + @staticmethod + def date_of_spring_bank_holiday(year): + """ + 1. last monday in May + 2012: Moved to June 4, because of Queen’s Diamond Jubilee + 2022: Moved to June 2, because of Queen's Platinum Jubilee + """ + if year == 2012: + return SmartDayArrow(year, 6, 4) + elif year == 2022: + return SmartDayArrow(year, 6, 2) + else: + return month_reference(year, "may", first=False) \ + .shift_to_weekday("monday", order=1, reverse=True, including=True) + + @staticmethod + def monday_after(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).shift_to_weekday("monday", including=True) + + return wrapper + + @staticmethod + def tuesday_after(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).shift_to_weekday("tuesday", including=True) + + return wrapper + + @staticmethod + def date_is_on_weekend(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() in ["saturday", "sunday"] + + return wrapper + + @staticmethod + def date_is_on_saturday(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() == "saturday" + + return wrapper + + @staticmethod + def date_is_on_sunday(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() == "sunday" + + return wrapper diff --git a/src/holidata/holidays/GR.py b/src/holidata/holidays/GR.py index c57ac65..9dbb168 100644 --- a/src/holidata/holidays/GR.py +++ b/src/holidata/holidays/GR.py @@ -1,6 +1,7 @@ from dateutil.easter import EASTER_ORTHODOX from .holidays import Country +from holidata.utils import SmartDayArrow, easter class GR(Country): @@ -8,3 +9,90 @@ class GR(Country): languages = ["el"] default_lang = "el" easter_type = EASTER_ORTHODOX + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Πρωτοχρονιά") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Θεοφάνεια") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Ευαγγελισμός της Θεοτόκου και Εθνική Ημέρα Ανεξαρτησίας της Ελλάδας") \ + .on("03-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Κοίμηση της Θεοτόκου") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Ημέρα του ΌΧΙ") \ + .on("10-28") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Χριστούγεννα") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Επόμενη ημέρα Χριστουγέννων") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Καθαρά Δευτέρα") \ + .on("48 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Μεγάλη Παρασκευή") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Μεγάλο Σάββατο") \ + .on("1 day before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Πάσχα") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Δευτέρα του Πάσχα") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Δευτέρα του Αγίου Πνεύματος") \ + .on("50 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Πρωτομαγιά") \ + .on(self.date_for_may_day) \ + .with_flags("NF") + + def date_for_may_day(self, year): + """ + Postponed if it collides with Easter + """ + date = SmartDayArrow(year, 5, 1) + easter_date = easter(year, self.easter_type) + + if date == easter_date: + date = date.shift(days=2) + elif date == easter_date.shift(days=1): + date = date.shift(days=1) + + return date diff --git a/src/holidata/holidays/HR.py b/src/holidata/holidays/HR.py index a0e3b9d..1ff8233 100644 --- a/src/holidata/holidays/HR.py +++ b/src/holidata/holidays/HR.py @@ -8,3 +8,77 @@ class HR(Country): languages = ["hr"] default_lang = "hr" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nova Godina") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Sveta tri kralja") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Praznik rada") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dan državnosti") \ + .on("05-30") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dan antifašističke borbe") \ + .on("06-22") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dan pobjede i domovinske zahvalnosti i Dan hrvatskih branitelja") \ + .on("08-05") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Velika Gospa") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Dan svih svetih") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Božić") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Sveti Stjepan") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Uskrs") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Uskršnji ponedjeljak") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Tijelovo") \ + .on("60 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Dan sjećanja na žrtve Domovinskog rata i Dan sjećanja na žrtvu Vukovara i Škabrnje") \ + .since(2020) \ + .on("11-18") \ + .with_flags("NF") diff --git a/src/holidata/holidays/HU.py b/src/holidata/holidays/HU.py index c502bcc..a2e3087 100644 --- a/src/holidata/holidays/HU.py +++ b/src/holidata/holidays/HU.py @@ -2,9 +2,145 @@ from .holidays import Country +""" +sources: +- Hungarian Constitution - Article J (1) + https://www.keh.hu/magyarorszag_alaptorvenye/1515-Magyarorszag_Alaptorvenye +- 2017. évi XIII. törvény egyes törvényeknek a nagypéntek munkaszüneti nappá történő nyilvánításával összefüggő módosításáról + https://mkogy.jogtar.hu/jogszabaly?docid=A1700013.TV +""" + class HU(Country): id = "HU" languages = ["hu"] default_lang = "hu" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Újév") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Az 1848-as forradalom ünnepe") \ + .on("03-15") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("A munka ünnepe") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Az államalapítás ünnepe") \ + .on("08-20") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Az 1956-os forradalom ünnepe") \ + .on("10-23") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Mindenszentek") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Karácsony") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Karácsony") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Húsvét") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Húsvéthétfő") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pünkösd") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pünkösdhétfő") \ + .on("50 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Nagypéntek") \ + .since(2017)\ + .on("2 days before Easter") \ + .with_flags("NRV") + + for year, listing in self.holiday_munkaszuneti_nap().items(): + for date, note in listing: + self.define_holiday() \ + .with_name("Munkaszüneti nap") \ + .in_years([year]) \ + .on("{month:02d}-{day:02d}".format(**date)) \ + .with_flags("NF") \ + .annotated_with(note) + + @staticmethod + def holiday_munkaszuneti_nap(): + """ + Non-Working days (Munkaszüneti nap) + When a public holiday falls on a Tuesday or a Thursday, a special decree swaps the preceding Monday or the + following Friday (respectively) with a not too distant Saturday + 2015: 28/2014. (IX. 24.) NGM rendelet a 2015. évi munkaszüneti napok körüli munkarendről + 2016: 8/2015. (VI. 29.) NGM rendelet a 2016. évi munkaszüneti napok körüli munkarendről + 2018: 9/2017. (V. 19.) NGM rendelet a 2018. évi munkaszüneti napok körüli munkarendről + 2019: 6/2018. (VIII. 23.) PM rendelet a 2019. évi munkaszüneti napok körüli munkarendről + 2020: 7/2019. (VI. 25.) PM rendelet a 2020. évi munkaszüneti napok körüli munkarendről + 2021: 14/2020. (V. 13.) ITM rendelet a 2021. évi munkaszüneti napok körüli munkarendről + 2022: 23/2021. (VI. 1.) ITM rendelet a 2022. évi munkaszüneti napok körüli munkarendről + """ + return { + 2015: [ + ({"month": 1, "day": 2}, "2015-01-10 munkanap"), + ({"month": 8, "day": 21}, "2015-08-08 munkanap"), + ({"month": 12, "day": 24}, "2015-12-12 munkanap"), + ], + 2016: [ + ({"month": 3, "day": 14}, "2016-03-05 munkanap"), + ({"month": 10, "day": 31}, "2016-10-15 munkanap"), + ], + 2018: [ + ({"month": 3, "day": 16}, "2018-03-10 munkanap"), + ({"month": 4, "day": 30}, "2018-04-21 munkanap"), + ({"month": 10, "day": 22}, "2018-10-13 munkanap"), + ({"month": 11, "day": 2}, "2018-11-10 munkanap"), + ({"month": 12, "day": 24}, "2018-12-01 munkanap"), + ({"month": 12, "day": 31}, "2018-12-15 munkanap"), + ], + 2019: [ + ({"month": 8, "day": 19}, "2019-08-10 munkanap"), + ({"month": 12, "day": 24}, "2019-12-07 munkanap"), + ({"month": 12, "day": 27}, "2019-12-14 munkanap"), + ], + 2020: [ + ({"month": 8, "day": 21}, "2020-08-29 munkanap"), + ({"month": 12, "day": 24}, "2020-12-12 munkanap"), + ], + 2021: [ + ({"month": 12, "day": 24}, "2021-12-11 munkanap") + ], + 2022: [ + ({"month": 3, "day": 14}, "2022-03-26 munkanap"), + ({"month": 10, "day": 31}, "2022-10-15 munkanap"), + ] + } diff --git a/src/holidata/holidays/IS.py b/src/holidata/holidays/IS.py index d458ede..78bf5f6 100644 --- a/src/holidata/holidays/IS.py +++ b/src/holidata/holidays/IS.py @@ -1,5 +1,6 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country @@ -8,3 +9,96 @@ class IS(Country): languages = ["is"] default_lang = "is" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nýársdagur") \ + .on("01-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Verkalýðsdagurinn") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Þjóðhátíðardagurinn") \ + .on("06-17") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Jóladagur") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Annar dagur jóla") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Skírdagur") \ + .on("3 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Föstudagurinn langi") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Páskadagur") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Annar dagur páska") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Uppstigningardagur") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Hvítasunnudagur") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Annar dagur hvítasunnu") \ + .on("50 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Frídagur verslunarmanna") \ + .on("1. monday in August") \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Sumardagurinn fyrsti") \ + .on(self.first_thursday_after_04_18) \ + .with_flags("NV") + + """ + Both, Christmas Eve (_aðfangadagur jóla_) and New Year's Eve (_gamlársdagur_) are public holidays in Iceland from 13:00 only. + They're included as full-day holidays, but with an explanatory note. + """ + self.define_holiday() \ + .with_name("Aðfangadagur jóla") \ + .on("12-24") \ + .with_flags("NRF") \ + .annotated_with("Holiday from 13:00") + + self.define_holiday() \ + .with_name("Gamlársdagur") \ + .on("12-31") \ + .with_flags("NF") \ + .annotated_with("Holiday from 13:00") + + @staticmethod + def first_thursday_after_04_18(year): + return SmartDayArrow(year, 4, 18).shift_to_weekday("thursday") diff --git a/src/holidata/holidays/IT.py b/src/holidata/holidays/IT.py index 4d71595..d658ad8 100644 --- a/src/holidata/holidays/IT.py +++ b/src/holidata/holidays/IT.py @@ -8,3 +8,66 @@ class IT(Country): languages = ["it"] default_lang = "it" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Capodanno") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Epifania") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Festa della liberazione") \ + .on("04-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Festa del lavoro") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Festa della repubblica") \ + .on("06-02") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Assunzione (ferragosto)") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Ognissanti") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Immacolata concezione") \ + .on("12-08") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Natale") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("S.to Stefano") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Pasqua") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pasquetta") \ + .on("1 day after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/NL.py b/src/holidata/holidays/NL.py index 9e822d4..6d9c7db 100644 --- a/src/holidata/holidays/NL.py +++ b/src/holidata/holidays/NL.py @@ -1,5 +1,6 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country @@ -8,3 +9,119 @@ class NL(Country): languages = ["nl"] default_lang = "nl" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nieuwjaarsdag") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dodenherdenking") \ + .on("05-04") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Bevrijdingsdag") \ + .on("05-05") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Sinterklaas") \ + .on("12-05") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Eerste Kerstdag") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Tweede Kerstdag") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Goede Vrijdag") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Eerste Paasdag") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Tweede Paasdag") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Hemelvaartsdag") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Eerste Pinksterdag") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Tweede Pinksterdag") \ + .on("50 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Koninginnedag") \ + .until(2013) \ + .on(self.koninginnedag) \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Koningsdag") \ + .since(2014) \ + .on(self.koningsdag) \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Koninkrijksdag") \ + .on(self.koninkrijksdag) \ + .with_flags("NV") + + @staticmethod + def koninginnedag(year): + """ + 04-30 or saturday before, if it falls on sunday + """ + date = SmartDayArrow(year, 4, 30) + + if date.weekday() == "sunday": + date = date.shift(days=-1) + + return date + + @staticmethod + def koningsdag(year): + """ + 04-27 or saturday before if it falls on sunday + """ + date = SmartDayArrow(year, 4, 27) + + if date.weekday() == "sunday": + date = date.shift(days=-1) + + return date + + @staticmethod + def koninkrijksdag(year): + """ + 04-27 or monday after if it falls on sunday + """ + date = SmartDayArrow(year, 12, 15) + + if date.weekday() == "sunday": + date = date.shift(days=1) + + return date diff --git a/src/holidata/holidays/NO.py b/src/holidata/holidays/NO.py index ad394d3..f7997ac 100644 --- a/src/holidata/holidays/NO.py +++ b/src/holidata/holidays/NO.py @@ -8,3 +8,91 @@ class NO(Country): languages = ["nb"] default_lang = "nb" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nyttårsdag") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Offentlig Høytidsdag") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Frigjøringsdag 1945") \ + .on("05-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Grunnlovsdag") \ + .on("05-17") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Julaften") \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Juledag") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Juledag") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Nyttårsaften") \ + .on("12-31") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Fastelavn") \ + .on("49 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Palmesøndag") \ + .on("7 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Skjærtorsdag") \ + .on("3 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Langfredag") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Påskedag") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Påskedag") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Kristi Himmelfartsdag") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pinsedag") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pinsedag") \ + .on("50 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/NZ.py b/src/holidata/holidays/NZ.py index 83c2c7c..cf34ada 100644 --- a/src/holidata/holidays/NZ.py +++ b/src/holidata/holidays/NZ.py @@ -1,6 +1,7 @@ from dateutil.easter import EASTER_WESTERN from .holidays import Country +from ..utils import SmartDayArrow class NZ(Country): @@ -8,3 +9,147 @@ class NZ(Country): languages = ["en"] default_lang = "en" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("New Year's Day") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("New Year's Day (observed)") \ + .on(self.monday_after(month=1, day=1)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_weekend(month=1, day=1)) + + self.define_holiday() \ + .with_name("Day after New Year's Day") \ + .on(self.day_after_new_years_day) \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Waitangi Day") \ + .on("02-06") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Waitangi Day (observed)") \ + .since(2017) \ + .on(self.monday_after(month=2, day=6)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_weekend(month=2, day=6)) + + self.define_holiday() \ + .with_name("ANZAC Day") \ + .on("04-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("ANZAC Day (observed)") \ + .since(2016) \ + .on(self.monday_after(month=4, day=25)) \ + .with_flags("NV") \ + .on_condition(self.date_is_on_weekend(month=4, day=25)) + + self.define_holiday() \ + .with_name("Christmas Day") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Christmas Day (observed)") \ + .on(self.tuesday_after(month=12, day=25)) \ + .with_flags("NV") \ + .on_condition(self.date_is_sunday(month=12, day=25)) + + self.define_holiday() \ + .with_name("Christmas Day (observed)") \ + .on(self.monday_after(month=12, day=25)) \ + .with_flags("NV") \ + .on_condition(self.date_is_saturday(month=12, day=25)) + + self.define_holiday() \ + .with_name("Boxing Day") \ + .on("12-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Boxing Day (observed)") \ + .on(self.tuesday_after(month=12, day=26)) \ + .with_flags("NV") \ + .on_condition(self.date_is_sunday(month=12, day=26)) + + self.define_holiday() \ + .with_name("Boxing Day (observed)") \ + .on(self.monday_after(month=12, day=26)) \ + .with_flags("NV") \ + .on_condition(self.date_is_saturday(month=12, day=26)) + + self.define_holiday() \ + .with_name("Good Friday") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Easter Monday") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Queen's Birthday") \ + .on("1. monday in june") \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Labour Day") \ + .on("4. monday in october") \ + .with_flags("NV") + + @staticmethod + def date_is_on_weekend(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() in ["saturday", "sunday"] + + return wrapper + + @staticmethod + def date_is_saturday(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() == "saturday" + + return wrapper + + @staticmethod + def date_is_sunday(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() == "sunday" + + return wrapper + + @staticmethod + def monday_after(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).shift_to_weekday("monday", including=True) + + return wrapper + + @staticmethod + def tuesday_after(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).shift_to_weekday("tuesday", including=True) + + return wrapper + + @staticmethod + def day_after_new_years_day(year): + date = SmartDayArrow(year, 1, 2) + + if date.weekday() in ["sunday", "monday"]: + return date.shift_to_weekday("tuesday", including=True) + + elif date.weekday() == "saturday": + return date.shift_to_weekday("monday", including=True) + + return date diff --git a/src/holidata/holidays/PL.py b/src/holidata/holidays/PL.py index ecd7dea..4628e7d 100644 --- a/src/holidata/holidays/PL.py +++ b/src/holidata/holidays/PL.py @@ -2,9 +2,81 @@ from .holidays import Country +""" +source: http://prawo.sejm.gov.pl/isap.nsf/download.xsp/WDU20150000090/O/D20150090.pdf +""" + class PL(Country): id = "PL" languages = ["pl"] default_lang = "pl" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nowy Rok") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Trzech Króli") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Święto Pracy") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Święto Konstytucji Trzeciego Maja") \ + .on("05-03") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Wniebowzięcie Najświętszej Maryi Panny") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Wszystkich Świętych") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Narodowe Święto Niepodległości") \ + .on("11-11") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Boże Narodzenie (pierwszy dzień)") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Boże Narodzenie (drugi dzień)") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Wielkanoc") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Poniedziałek Wielkanocny") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Zielone Świątki") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Boże Ciało") \ + .on("60 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/PT.py b/src/holidata/holidays/PT.py index e234535..4bd16fc 100644 --- a/src/holidata/holidays/PT.py +++ b/src/holidata/holidays/PT.py @@ -8,3 +8,76 @@ class PT(Country): languages = ["pt"] default_lang = "pt" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Ano Novo") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dia da Liberdade") \ + .on("04-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dia do Trabalhador") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dia de Portugal") \ + .on("06-10") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Assunção de Nossa Senhora") \ + .on("08-15") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Implantação da República") \ + .on("10-05") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dia de Todos os Santos") \ + .on("11-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Restauração da Independência") \ + .on("12-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Imaculada Conceição") \ + .on("12-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Natal") \ + .on("12-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Carnaval") \ + .on("47 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Sexta-feira Santa") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Páscoa") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Corpo de Deus") \ + .on("60 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/RU.py b/src/holidata/holidays/RU.py index eb8120f..4b63cb2 100644 --- a/src/holidata/holidays/RU.py +++ b/src/holidata/holidays/RU.py @@ -8,3 +8,51 @@ class RU(Country): languages = ["ru"] default_lang = "ru" easter_type = EASTER_ORTHODOX + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Новый Год") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Рождество Христово") \ + .on("01-07") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("День защитника Отечества") \ + .on("02-23") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Международный женский день") \ + .on("03-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Праздник весны и труда") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("День Победы") \ + .on("05-09") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("День России") \ + .on("06-12") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("День народного единства") \ + .on("11-04") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Пасха") \ + .on("Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/SE.py b/src/holidata/holidays/SE.py index abe8775..225db83 100644 --- a/src/holidata/holidays/SE.py +++ b/src/holidata/holidays/SE.py @@ -1,5 +1,6 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country @@ -8,3 +9,100 @@ class SE(Country): languages = ["sv"] default_lang = "sv" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Nyårsdagen") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Trettondedag jul") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Första maj") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Nationaldagen") \ + .on("06-06") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Julafton") \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Juldagen") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Annandag jul") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Nyårsafton") \ + .on("12-31") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Långfredagen") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Påskdagen") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Annandag påsk") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Kristi himmelsfärdsdag") \ + .on("39 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Pingstdagen") \ + .on("49 days after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Midsommarafton") \ + .on(self.day_before_midsommar) \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Midsommardagen") \ + .on(self.midsommar) \ + .with_flags("NV") + + self.define_holiday() \ + .with_name("Alla helgons dag") \ + .on(self.saturday_after_10_31) \ + .with_flags("NRV") + + @staticmethod + def midsommar(year): + """ + Find the Saturday between 20 and 26 June + """ + return SmartDayArrow(year, 6, 19).shift_to_weekday("saturday", order=1, reverse=False) + + def day_before_midsommar(self, year): + return self.midsommar(year).shift(days=-1) + + @staticmethod + def saturday_after_10_31(year): + return SmartDayArrow(year, 10, 30).shift_to_weekday("saturday", order=1, reverse=False) diff --git a/src/holidata/holidays/SI.py b/src/holidata/holidays/SI.py index bcbd232..74d1e25 100644 --- a/src/holidata/holidays/SI.py +++ b/src/holidata/holidays/SI.py @@ -8,3 +8,88 @@ class SI(Country): languages = ["sl"] default_lang = "sl" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Novo leto") \ + .on("01-01") \ + .with_flags("NF") + + """ + From 1955 until May 2012, when the National Assembly of Slovenia passed the Public Finance Balance Act, + 2 January was a work-free day. It was reintroduced in 2017. + 2012<: https://www.uradni-list.si/1/objava.jsp?sop=2012-01-1700 + 2016<: https://www.uradni-list.si/1/objava.jsp?sop=2016-01-3568 + """ + self.define_holiday() \ + .with_name("Novo leto") \ + .on("01-02") \ + .except_for([2013, 2014, 2015, 2016]) \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Prešernov dan") \ + .on("02-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dan upora proti okupatorju") \ + .on("04-27") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Praznik dela") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Praznik dela") \ + .on("05-02") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dan državnosti") \ + .on("06-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Marijino vnebovzetje") \ + .on("08-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Dan reformacije") \ + .on("10-31") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Dan spomina na mrtve") \ + .on("11-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Božič") \ + .on("12-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Dan samostojnosti in enotnosti") \ + .on("12-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Velikonočna nedelja") \ + .on("Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Velikonočni ponedeljek") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Binkošti") \ + .on("50 days after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/SK.py b/src/holidata/holidays/SK.py index fac5835..6c43987 100644 --- a/src/holidata/holidays/SK.py +++ b/src/holidata/holidays/SK.py @@ -8,3 +8,81 @@ class SK(Country): languages = ["sk"] default_lang = "sk" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Deň vzniku Slovenskej republiky") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Zjavenie Pána / Traja králi") \ + .on("01-06") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Sviatok práce") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Deň víťazstva nad fašizmom") \ + .on("05-08") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Sviatok svätého Cyrila a Metoda") \ + .on("07-05") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Výročie SNP") \ + .on("08-29") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Deň Ústavy Slovenskej republiky") \ + .on("09-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Sedembolestná Panna Mária") \ + .on("09-15") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Sviatok všetkých svätých") \ + .on("11-01") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Deň boja za slobodu a demokraciu") \ + .on("11-17") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Štedrý deň") \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Prvý sviatok vianočný") \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Druhý sviatok vianočný") \ + .on("12-26") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_name("Veľký piatok") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Veľkonočný pondelok") \ + .on("1 day after Easter") \ + .with_flags("NRV") diff --git a/src/holidata/holidays/TR.py b/src/holidata/holidays/TR.py index c0bf8a1..eb7055e 100644 --- a/src/holidata/holidays/TR.py +++ b/src/holidata/holidays/TR.py @@ -1,6 +1,13 @@ from dateutil.easter import EASTER_WESTERN from .holidays import Country +from holidata.utils import SmartDayArrow + +""" +sources: +law on national holidays and general holidays: https://www.mevzuat.gov.tr/mevzuat?MevzuatNo=2429&MevzuatTur=1&MevzuatTertip=5 +dates for holidays 'Ramazan Bayramı' and 'Kurban Bayramı': https://vakithesaplama.diyanet.gov.tr/dini_gunler.php +""" class TR(Country): @@ -8,3 +15,120 @@ class TR(Country): languages = ["tr"] default_lang = "tr" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Yılbaşı") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Ulusal Egemenlik ve Çocuk Bayramı") \ + .on("04-23") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Emek ve Dayanışma Günü") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Atatürk'ü Anma, Gençlik ve Spor Bayramı") \ + .on("05-19") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Zafer Bayramı") \ + .on("08-30") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Cumhuriyet Bayramı") \ + .on("10-29") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Demokrasi ve Milli Birlik Günü") \ + .on("07-15") \ + .since(2017) \ + .with_flags("NF") + + """ + Ramazan Bayramı 1.-3. Gün + """ + for i in [1, 2, 3]: + self.define_holiday() \ + .with_name(f"Ramazan Bayramı ({i}. Gün)") \ + .on(self.ramazan_bayrami_day(i)) \ + .with_flags("NRV") + + """ + Kurban Bayramı 1.-4. Gün + """ + for i in [1, 2, 3, 4]: + self.define_holiday() \ + .with_name(f"Kurban Bayramı ({i}. Gün)") \ + .on(self.kurban_bayrami_day(i)) \ + .with_flags("NRV") + + def ramazan_bayrami_day(self, ordinal): + def ramazan_bayrami_reference_shifted(year): + return self.__ramazan_bayrami_reference(year).shift(days=ordinal) + + return ramazan_bayrami_reference_shifted + + def kurban_bayrami_day(self, ordinal): + def kurban_bayrami_reference_shifted(year): + return self.__kurban_bayrami_reference(year).shift(days=ordinal) + + return kurban_bayrami_reference_shifted + + @staticmethod + def __ramazan_bayrami_reference(year): + ramazan_bayrami_reference = { + 2011: SmartDayArrow(2011, 8, 29), + 2012: SmartDayArrow(2012, 8, 18), + 2013: SmartDayArrow(2013, 8, 7), + 2014: SmartDayArrow(2014, 7, 27), + 2015: SmartDayArrow(2015, 7, 16), + 2016: SmartDayArrow(2016, 7, 4), + 2017: SmartDayArrow(2017, 6, 24), + 2018: SmartDayArrow(2018, 6, 14), + 2019: SmartDayArrow(2019, 6, 4), + 2020: SmartDayArrow(2020, 5, 23), + 2021: SmartDayArrow(2021, 5, 12), + 2022: SmartDayArrow(2022, 5, 1), + 2023: SmartDayArrow(2023, 4, 20), + 2024: SmartDayArrow(2024, 4, 9), + 2025: SmartDayArrow(2025, 3, 29), + 2026: SmartDayArrow(2026, 3, 19), + 2027: SmartDayArrow(2027, 3, 8), + } + + return ramazan_bayrami_reference[year] + + @staticmethod + def __kurban_bayrami_reference(year): + kurban_bayrami_reference = { + 2011: SmartDayArrow(2011, 11, 5), + 2012: SmartDayArrow(2012, 10, 24), + 2013: SmartDayArrow(2013, 10, 14), + 2014: SmartDayArrow(2014, 10, 3), + 2015: SmartDayArrow(2015, 9, 23), + 2016: SmartDayArrow(2016, 9, 11), + 2017: SmartDayArrow(2017, 8, 31), + 2018: SmartDayArrow(2018, 8, 20), + 2019: SmartDayArrow(2019, 8, 10), + 2020: SmartDayArrow(2020, 7, 30), + 2021: SmartDayArrow(2021, 7, 19), + 2022: SmartDayArrow(2022, 7, 8), + 2023: SmartDayArrow(2023, 6, 27), + 2024: SmartDayArrow(2024, 6, 15), + 2025: SmartDayArrow(2025, 6, 5), + 2026: SmartDayArrow(2026, 5, 26), + 2027: SmartDayArrow(2027, 5, 15), + } + + return kurban_bayrami_reference[year] diff --git a/src/holidata/holidays/US.py b/src/holidata/holidays/US.py index ae7113a..b7dd6de 100644 --- a/src/holidata/holidays/US.py +++ b/src/holidata/holidays/US.py @@ -12,3 +12,111 @@ class US(Country): "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY", "DC", "AS", "GU", "MP", "PR", "UM", "VI"] easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_names({ + "en": "New Year's Day", + "es": "Año Neuvo", + }) \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "en": "Independence Day", + "es": "Día de la Independiencia", + }) \ + .on("07-04") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "en": "Veterans Day", + "es": "Día de los Veteranos", + }) \ + .on("11-11") \ + .with_flags("NF") + + self.define_holiday() \ + .with_names({ + "en": "Christmas Eve", + "es": "Nochebuena", + }) \ + .on("12-24") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "en": "Christmas Day", + "es": "Navidad", + }) \ + .on("12-25") \ + .with_flags("NRF") + + self.define_holiday() \ + .with_names({ + "en": "Birthday of Martin Luther King, Jr.", + "es": "Cumpleaños de Martin Luther King, Jr.", + }) \ + .on("3. monday in January") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Washington's Birthday", + "es": "Día del Presidente", + }) \ + .on("3. monday in February") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Patriots' Day", + "es": "Día del Patriota", + }) \ + .in_regions(["MA", "ME"]) \ + .on("3. monday in April") \ + .with_flags("V") + + self.define_holiday() \ + .with_names({ + "en": "Memorial Day", + "es": "Día de los Caídos", + }) \ + .on("1. last monday in May") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Labor Day", + "es": "Día del Trabajo", + }) \ + .on("1. monday in September") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Columbus Day", + "es": "Día de Columbus", + }) \ + .on("2. monday in October") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Thanksgiving Day", + "es": "Día de Acción de Gracias", + }) \ + .on("4. thursday in November") \ + .with_flags("NV") + + self.define_holiday() \ + .with_names({ + "en": "Day after Thanksgiving", + "es": "Día después de Acción de Gracias", + }) \ + .on("4. friday in November") \ + .with_flags("NV") diff --git a/src/holidata/holidays/ZA.py b/src/holidata/holidays/ZA.py index 6a303f7..e6b0505 100644 --- a/src/holidata/holidays/ZA.py +++ b/src/holidata/holidays/ZA.py @@ -1,9 +1,144 @@ from dateutil.easter import EASTER_WESTERN +from holidata.utils import SmartDayArrow from .holidays import Country class ZA(Country): id = "ZA" languages = ["en"] + default_lang = "en" easter_type = EASTER_WESTERN + + def __init__(self): + super().__init__() + + self.define_holiday() \ + .with_name("Christmas Day") \ + .on("12-25") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Good Friday") \ + .on("2 days before Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("Family Day") \ + .on("1 day after Easter") \ + .with_flags("NRV") + + self.define_holiday() \ + .with_name("New Year's Day") \ + .on("01-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("New Year's Day (Supplement)") \ + .on("01-02") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=1, day=1)) + + self.define_holiday() \ + .with_name("Human Rights Day") \ + .on("03-21") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Human Rights Day (Supplement)") \ + .on("03-22") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=3, day=21)) + + self.define_holiday() \ + .with_name("Freedom Day") \ + .on("04-27") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Freedom Day (Supplement)") \ + .on("04-28") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=4, day=27)) + + self.define_holiday() \ + .with_name("Worker's Day") \ + .on("05-01") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Worker's Day (Supplement)") \ + .on("05-02") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=5, day=1)) + + self.define_holiday() \ + .with_name("Youth Day") \ + .on("06-16") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Youth Day (Supplement)") \ + .on("06-17") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=6, day=16)) + + self.define_holiday() \ + .with_name("National Women's Day") \ + .on("08-09") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("National Women's Day (Supplement)") \ + .on("08-10") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=8, day=9)) + + self.define_holiday() \ + .with_name("Heritage Day") \ + .on("09-24") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Heritage Day (Supplement)") \ + .on("09-25") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=9, day=24)) + + self.define_holiday() \ + .with_name("Day of Reconciliation") \ + .on("12-16") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Day of Reconciliation (Supplement)") \ + .on("12-17") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=12, day=16)) + + self.define_holiday() \ + .with_name("Day of Goodwill") \ + .on("12-26") \ + .with_flags("NF") + + self.define_holiday() \ + .with_name("Day of Goodwill (Supplement)") \ + .on("12-27") \ + .with_flags("NF") \ + .annotated_with("Supplement holiday") \ + .on_condition(self.date_is_on_sunday(month=12, day=26)) + + @staticmethod + def date_is_on_sunday(month, day): + def wrapper(year): + return SmartDayArrow(year, month, day).weekday() == "sunday" + + return wrapper diff --git a/src/holidata/holidays/__init__.py b/src/holidata/holidays/__init__.py index d07a4ee..f4cf0f4 100644 --- a/src/holidata/holidays/__init__.py +++ b/src/holidata/holidays/__init__.py @@ -36,39 +36,4 @@ "US", "ZA", "Locale", - "cs-CZ", - "da-DK", - "de-AT", - "de-BE", - "de-CH", - "de-DE", - "el-GR", - "en-CA", - "en-GB", - "en-NZ", - "en-US", - "en-ZA", - "es-CO", - "es-US", - "et-EE", - "fi-FI", - "fr-BE", - "fr-CA", - "fr-FR", - "hr-HR", - "hu-HU", - "is-IS", - "it-IT", - "nb-NO", - "nl-BE", - "nl-NL", - "pl-PL", - "pt-BR", - "pt-PT", - "ru-RU", - "sk-SK", - "sl-SI", - "sv-FI", - "sv-SE", - "tr-TR", ] diff --git a/src/holidata/holidays/cs-CZ.py b/src/holidata/holidays/cs-CZ.py deleted file mode 100644 index b5aa644..0000000 --- a/src/holidata/holidays/cs-CZ.py +++ /dev/null @@ -1,80 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import easter, SmartDayArrow -from .holidays import Locale, Holiday - -""" -source: https://www.zakonyprolidi.cz/cs/2000-245, §1 and §2. - https://www.zakonyprolidi.cz/cs/2000-245/zneni-20200201 (>2020-02-01) - https://www.zakonyprolidi.cz/cs/2000-245/zneni-20190401 (>2019-04-01) - https://www.zakonyprolidi.cz/cs/2000-245/zneni-0 (>2000-08-09) -""" - - -class cs_CZ(Locale): - """ - 01-01: [NF] Nový rok - 01-01: [NF] Den obnovy samostatného českého státu - 05-01: [NF] Svátek práce - 05-08: [NF] Den vítězství - 07-05: [NRF] Den slovanských věrozvěstů Cyrila a Metoděje - 07-06: [NRF] Den upálení mistra Jana Husa - 09-28: [NRF] Den české státnosti - 10-28: [NF] Den vzniku samostatného československého státu - 12-24: [NRF] Štědrý den - 12-25: [NRF] 1. svátek vánoční - 12-26: [NRF] 2. svátek vánoční - 1 day after Easter: [NRV] Velikonoční pondělí - """ - - id = "cs-CZ" - easter_type = EASTER_WESTERN - - def holiday_velky_patek(self, year): - """ - 2 days before Easter: [NRV] Velký pátek - Since 2016 - """ - if year >= 2016: - return [Holiday( - self.id, - "", - easter(year, self.easter_type).shift(days=-2), - "Velký pátek", - "NRV" - )] - - return [] - - def holiday_den_boje_za_svobodu_a_demokracii(self, year): - """ - 11-17: [NF] Den boje za svobodu a demokracii - Until 2018, replaced by "Den boje za svobodu a demokracii a Mezinárodní den studentstva" on 2019-04-01 - """ - if year <= 2018: - return [Holiday( - self.id, - "", - SmartDayArrow(year, 11, 17), - "Den boje za svobodu a demokracii", - "NF" - )] - - return [] - - def holiday_den_boje_za_svobodu_a_demokracii_a_mezinarodni_den_studentstva(self, year): - """ - 11-17: [NF] Den boje za svobodu a demokracii a Mezinárodní den studentstva - Since 2019, replaces "Den boje za svobodu a demokracii" - """ - if year >= 2019: - return [Holiday( - self.id, - "", - SmartDayArrow(year, 11, 17), - "Den boje za svobodu a demokracii a Mezinárodní den studentstva", - "NF" - )] - - return [] diff --git a/src/holidata/holidays/da-DK.py b/src/holidata/holidays/da-DK.py deleted file mode 100644 index 37ead68..0000000 --- a/src/holidata/holidays/da-DK.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class da_DK(Locale): - """ - 01-01: [NF] Nytårsdag - 06-05: [NF] Grundlovsdag - 12-25: [NRF] Juledag - 12-26: [NRF] Anden juledag - 3 days before Easter: [NRV] Skærtorsdag - 2 days before Easter: [NRV] Langfredag - Easter: [NRV] Påskedag - 1 day after Easter: [NRV] Anden påskedag - 26 days after Easter: [NRV] Store bededag - 39 days after Easter: [NRV] Kristi himmelfartsdag - 49 days after Easter: [NRV] Pinsedag - 50 days after Easter: [NRV] Anden pinsedag - """ - - id = "da-DK" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/de-AT.py b/src/holidata/holidays/de-AT.py deleted file mode 100644 index c4527c9..0000000 --- a/src/holidata/holidays/de-AT.py +++ /dev/null @@ -1,36 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class de_AT(Locale): - """ - 01-01: [NF] Neujahr - 01-06: [NRF] Heilige drei Könige - 03-19: [2,6,7,8] [RF] Josef - 05-01: [NF] Staatsfeiertag - 05-04: [4] [F] Florian - 08-15: [NRF] Mariä Himmelfahrt - 09-24: [5] [F] Rupert - 10-10: [2] [F] Tag der Volksabstimmung - 10-26: [NF] Nationalfeiertag - 11-01: [NRF] Allerheiligen - 11-11: [1] [F] Martin - 11-15: [9,3] [F] Leopold - 12-08: [NRF] Mariä Empfängnis - 12-24: [NRF] Heiliger Abend - 12-25: [NRF] Christtag - 12-26: [NF] Stefanitag - 12-31: [NF] Silvester - 2 days before Easter: [NRV] Karfreitag - Easter: [NRV] Ostersonntag - 1 day after Easter: [NRV] Ostermontag - 39 days after Easter: [NRV] Christi Himmelfahrt - 49 days after Easter: [NRV] Pfingstsonntag - 50 days after Easter: [NRV] Pfingstmontag - 60 days after Easter: [NRV] Fronleichnam - """ - - id = "de-AT" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/de-BE.py b/src/holidata/holidays/de-BE.py deleted file mode 100644 index 5f76474..0000000 --- a/src/holidata/holidays/de-BE.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class de_BE(Locale): - """ - 01-01: [NF] Neujahr - 05-01: [NF] Tag der Arbeit - 07-21: [NF] Nationalfeiertag - 08-15: [NRF] Mariä Himmelfahrt - 11-01: [NRF] Allerheiligen - 11-11: [NF] Waffenstillstand - 12-25: [NRF] Weihnacht - Easter: [NRV] Ostern - 1 day after Easter: [NRV] Ostermontag - 39 days after Easter: [NRV] Christi Himmelfahrt - 49 days after Easter: [NRV] Pfingsten - 50 days after Easter: [NRV] Pfingstmontag - """ - - id = "de-BE" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/de-CH.py b/src/holidata/holidays/de-CH.py deleted file mode 100644 index 626736d..0000000 --- a/src/holidata/holidays/de-CH.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class de_CH(Locale): - """ - 01-01: [NF] Neujahrstag - 01-02: [BE,JU,TG,VD] [F] Berchtoldstag - 01-06: [SZ,TI,UR] [RF] Heilige Drei Könige - 03-19: [NW,SZ,TI,UR,VS] [RF] Josefstag - 05-01: [BL,BS,GR,NE,SH,TG,TI,ZH] [F] Tag der Arbeit - 08-01: [NF] Bundesfeier - 08-15: [AI] [RF] Mariä Himmelfahrt - 08-15: [JU,LU,NW,OW,SZ,TI,UR,VS,ZG] [RF] Mariä Himmelfahrt - 11-01: [AI,GL,JU,LU,NW,OW,SG,SZ,TI,UR,VS,ZG] [RF] Allerheiligen - 12-08: [AI] [RF] Mariä Empfängnis - 12-08: [LU,NW,OW,SZ,TI,UR,VS,ZG] [RF] Mariä Empfängnis - 12-25: [NRF] Weihnachtstag - 12-26: [AI,AR,BE,BL,BS,GL,GR,LU,SG,SH,SZ,TG,TI,UR,ZH] [RF] Stephanstag - 2 days before Easter: [AG,AI,AR,BE,BL,BS,FR,GE,GL,GR,JU,LU,NE,NW,OW,SG,SH,SO,SZ,TG,UR,VD,ZG,ZH] [RV] Karfreitag - Easter: [NRV] Ostersonntag - 1 day after Easter: [AI,AR,BE,BL,BS,GE,GL,GR,JU,SG,SH,SZ,TG,TI,UR,VD,ZH] [RV] Ostermontag - 39 days after Easter: [NRV] Auffahrt - 49 days after Easter: [NRV] Pfingstsonntag - 50 days after Easter: [AI,AR,BE,BL,BS,GE,GL,GR,JU,SG,SH,SZ,TG,TI,UR,VD,ZH] [RV] Pfingstmontag - 60 days after Easter: [AI,JU,LU,NW,OW,SZ,TI,UR,VS,ZG] [RV] Fronleichnam - """ - - id = "de-CH" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/de-DE.py b/src/holidata/holidays/de-DE.py deleted file mode 100644 index 75d7254..0000000 --- a/src/holidata/holidays/de-DE.py +++ /dev/null @@ -1,99 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - - -class de_DE(Locale): - """ - 01-01: [NF] Neujahr - 01-06: [BW,BY,ST] [RF] Heilige drei Könige - 05-01: [NF] Erster Maifeiertag - 08-15: [SL] [RF] Mariä Himmelfahrt - 10-03: [NRF] Tag der Deutschen Einheit - 11-01: [BW,BY,NW,RP,SL] [RF] Allerheiligen - 12-24: [NRF] Heilig Abend - 12-25: [NRF] Weihnachtstag - 12-26: [NRF] Zweiter Weihnachtstag - 12-31: [NF] Silvester - 2 days before Easter: [NRV] Karfreitag - Easter: [NRV] Ostern - 1 day after Easter: [NRV] Ostermontag - 39 days after Easter: [NRV] Christi Himmelfahrt - 49 days after Easter: [NRV] Pfingstsonntag - 50 days after Easter: [NRV] Pfingstmontag - 60 days after Easter: [BW,BY,HE,NW,RP,SL] [RV] Fronleichnam - """ - - id = "de-DE" - easter_type = EASTER_WESTERN - - def holiday_buss_und_bettag(self, year): - """11 days before 4. sunday before 12-25: [SN] [RV] Buß- und Bettag""" - - return [Holiday( - self.id, - "SN", - SmartDayArrow(year, 12, 25).shift_to_weekday("sunday", order=4, reverse=True).shift(days=-11), - "Buß- und Bettag", - "RV" - )] - - def holiday_reformationstag(self, year): - """ - before 2018: 10-31: [BB, MV, SN, ST, TH] [RF] Reformationstag - since 2018: 10-31: [BB, BH, HH, MV, NI, SH, SN, ST, TH] [RF] Reformationstag - 2017: 10-31: [NRF] Reformationstag (national holiday because of 500th anniversary) - - """ - if year == 2017: - regions = [""] - elif year < 2018: - regions = ["BB", "MV", "SN", "ST", "TH"] - else: - regions = ["BB", "BH", "HH", "MV", "NI", "SH", "SN", "ST", "TH"] - - return [Holiday( - self.id, - region, - SmartDayArrow(year, 10, 31), - "Reformationstag", - "NRF" if regions == [""] else "RF" - ) for region in regions] - - def holiday_frauentag(self, year): - """ - 03-08: [BE] [F] Frauentag - - Introduced 2019 for Berlin - https://gesetze.berlin.de/perma?d=jlr-FeiertGBEV6P1 - """ - if year >= 2019: - return [Holiday( - self.id, - "BE", - SmartDayArrow(year, 3, 8), - "Internationaler Frauentag", - "F" - )] - - return [] - - def holiday_tag_der_befreiung(self, year): - """ - 2020-05-08: [BE] [F] 75. Jahrestag der Befreiung vom Nationalsozialismus und der Beendigung des Zweiten Weltkrieges in Europa - - Introduced 2019 for Berlin - https://gesetze.berlin.de/perma?d=jlr-FeiertGBEV6P1 - """ - if year == 2020: - return [Holiday( - self.id, - "BE", - SmartDayArrow(year, 5, 8), - "75. Jahrestag der Befreiung vom Nationalsozialismus und der Beendigung des Zweiten Weltkrieges in Europa", - "F" - )] - - return [] diff --git a/src/holidata/holidays/el-GR.py b/src/holidata/holidays/el-GR.py deleted file mode 100644 index 7dda89c..0000000 --- a/src/holidata/holidays/el-GR.py +++ /dev/null @@ -1,47 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_ORTHODOX - -from holidata.utils import SmartDayArrow, easter -from .holidays import Holiday, Locale - - -class el_GR(Locale): - """ - 01-01: [NF] Πρωτοχρονιά - 01-06: [NRF] Θεοφάνεια - 03-25: [NF] Ευαγγελισμός της Θεοτόκου και Εθνική Ημέρα Ανεξαρτησίας της Ελλάδας - 08-15: [NRF] Κοίμηση της Θεοτόκου - 10-28: [NF] Ημέρα του ΌΧΙ - 12-25: [NRF] Χριστούγεννα - 12-26: [NRF] Επόμενη ημέρα Χριστουγέννων - 48 days before Easter: [NRV] Καθαρά Δευτέρα - 2 days before Easter: [NRV] Μεγάλη Παρασκευή - 1 day before Easter: [NRV] Μεγάλο Σάββατο - Easter: [NRV] Πάσχα - 1 day after Easter: [NRV] Δευτέρα του Πάσχα - 50 days after Easter: [NRV] Δευτέρα του Αγίου Πνεύματος - """ - - id = "el-GR" - easter_type = EASTER_ORTHODOX - - def holiday_may_day(self, year): - """ - 05-01: [NF] Πρωτομαγιά - Postponed if it collides with Easter - """ - date = SmartDayArrow(year, 5, 1) - easter_date = easter(year, self.easter_type) - - if date == easter_date: - date = date.shift(days=2) - elif date == easter_date.shift(days=1): - date = date.shift(days=1) - - return [Holiday( - self.id, - "", - date, - "Πρωτομαγιά", - "NF" - )] diff --git a/src/holidata/holidays/en-CA.py b/src/holidata/holidays/en-CA.py deleted file mode 100644 index 32b0655..0000000 --- a/src/holidata/holidays/en-CA.py +++ /dev/null @@ -1,74 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - - -# -# Information taken from various government websites around 2020-04-16 -# https://www.canada.ca/fr/emploi-developpement-social/services/normes-travail/rapports/jours-feries.html -# http://www4.gouv.qc.ca/FR/Portail/Citoyens/Evenements/travailleur-avec-salaire/Pages/jours-feries-chomes-payes.aspx -# https://www.ontario.ca/document/your-guide-employment-standards-act-0/public-holidays#section-2 -# https://www.cfib-fcei.ca/en/tools-resources/paying-employees-public-holidays-newfoundland-labrador -# https://www.princeedwardisland.ca/en/information/economic-growth-tourism-and-culture/paid-holidays -# https://www2.gnb.ca/content/dam/gnb/Departments/petl-epft/PDF/es/FactSheets/PublicHolidaysVacation.pdf -# -# Also those sites for some information -# https://www.officeholidays.com/holidays/canada/canada-remembrance-day -# https://www.timeanddate.com/holidays/canada/family-day -# https://fr.wikipedia.org/wiki/F%C3%AAtes_et_jours_f%C3%A9ri%C3%A9s_au_Canada -# -# I have not checked every province and territory website, but the wikipedia -# summary has been true for everything that I have checked, although it seems -# to be considering more holidays than the bare minimum and also counts holidays -# that are not mandated but usually observed (e.g. St-Patrick's Day in NL which -# is not statutory, but is given to government employees). -# - - -class en_CA(Locale): - """ - 01-01: [NF] New Year's Day - 06-24: [QC] [F] National Holiday - 07-01: [NF] Canada Day - 11-11: [AB,BC,NB,NL,NT] [F] Remembrance Day - 12-25: [NRF] Christmas Day - 12-26: [NRF] Boxing Day - 2 days before Easter: [NRV] Good Friday - 1 day after Easter: [AB,PE,QC] [RV] Easter Monday - 3. monday in February: [AB,ON,SK,NB] [V] Family Day - 3. monday in February: [MB] [V] Louis Riel Day - 3. monday in February: [PE] [V] Islander Day - 1. monday in August: [NT,NU] [V] August Civic Holiday - 1. monday in August: [SK] [V] Saskatchewan Day - 1. monday in August: [AB,NS] [V] Heritage Day - 1. monday in August: [NB] [V] New Brunswick Day - 1. monday in September: [NV] Labour Day - 2. monday in October: [AB,BC,MB,NL,ON,QC,SK,NT,NU,YT] [V] Thanksgiving Day - """ - - id = "en-CA" - easter_type = EASTER_WESTERN - - def holiday_patriot_s_day(self, year): - return [Holiday( - locale=self.id, - region="QC", - date=SmartDayArrow(year, 5, 25).shift_to_weekday( - "monday", order=1, reverse=True, including=False), - description="National Patriots' Day", - flags="V", - notes="")] - - def holiday_victoria_day(self, year): - return [Holiday( - locale=self.id, - region=region, - date=SmartDayArrow(year, 5, 25).shift_to_weekday( - "monday", order=1, reverse=True, including=False), - description="Victoria Day", - flags="V", - notes="" - ) for region in ["AB", "BC", "MB", "NS", "ON", "SK", "NT", "NU", "YT"] - ] diff --git a/src/holidata/holidays/en-GB.py b/src/holidata/holidays/en-GB.py deleted file mode 100644 index 65e1ac5..0000000 --- a/src/holidata/holidays/en-GB.py +++ /dev/null @@ -1,164 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow, month_reference -from .holidays import Holiday, Locale - - -class en_GB(Locale): - """ - 01-01: [NF] New Year's Day - 12-25: [NRF] Christmas Day - 12-26: [NF] Boxing Day - 2 days before Easter: [NRV] Good Friday - 1 day after Easter: [NRV] Easter Monday - 1. monday in may: [NV] Early May Bank Holiday - 1. last monday in august: [NV] August Bank Holiday - """ - - id = "en-GB" - easter_type = EASTER_WESTERN - - def holiday_new_years_day_observed(self, year): - date = SmartDayArrow(year, 1, 1) - - if date.weekday() in ["saturday", "sunday"]: - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="New Year's Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_spring_bank_holiday(self, year): - """ - 1. last monday in may: [NV] Spring Bank Holiday - 2012: Moved to June 4, because of Queen’s Diamond Jubilee - 2022: Moved to June 2, because of Queen's Platinum Jubilee - """ - if year == 2012: - date = SmartDayArrow(year, 6, 4) - elif year == 2022: - date = SmartDayArrow(year, 6, 2) - else: - date = month_reference(year, - "may", - first=False) \ - .shift_to_weekday("monday", - order=1, - reverse=True, - including=True) - - return [Holiday( - locale=self.id, - region="", - date=date, - description="Spring Bank Holiday", - flags="NV", - notes="")] - - def holiday_christmas_day_observed(self, year): - date = SmartDayArrow(year, 12, 25) - - if date.weekday() == "saturday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="Christmas Day (observed)", - flags="NV", - notes="")] - - elif date.weekday() == "sunday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("tuesday", including=True), - description="Christmas Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_boxing_day_observed(self, year): - date = SmartDayArrow(year, 12, 26) - - if date.weekday() == "sunday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("tuesday", including=True), - description="Boxing Day (observed)", - flags="NV", - notes="")] - - elif date.weekday() == "saturday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="Boxing Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_coronation_charles_iii(self, year): - """ - 2023-05-08: Bank holiday for the coronation of King Charles III - """ - if year == 2023: - return [Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 5, 8), - description="Coronation of King Charles III", - flags="NV", - notes="")] - - return [] - - def holiday_queens_diamond_jubilee(self, year): - """ - 2012-06-05: Queen's Diamond Jubilee - """ - if year == 2012: - return [Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 6, 5), - description="Queen's Diamond Jubilee", - flags="NV", - notes="")] - - return [] - - def holiday_queens_platinum_jubilee(self, year): - """ - 2022-06-03: Queen's Platinum Jubilee - """ - if year == 2022: - return [Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 6, 3), - description="Queen's Platinum Jubilee", - flags="NV", - notes="")] - - return [] - - def holiday_state_funeral_of_queen_elizabeth_ii(self, year): - if year == 2022: - return [Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 9, 19), - description="State Funeral of Queen Elizabeth II", - flags="NF", - notes="")] - - return [] diff --git a/src/holidata/holidays/en-NZ.py b/src/holidata/holidays/en-NZ.py deleted file mode 100644 index 757615d..0000000 --- a/src/holidata/holidays/en-NZ.py +++ /dev/null @@ -1,139 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - - -class en_NZ(Locale): - """ - 01-01: [NF] New Year's Day - 02-06: [NF] Waitangi Day - 04-25: [NF] ANZAC Day - 12-25: [NRF] Christmas Day - 12-26: [NF] Boxing Day - 2 days before Easter: [NRV] Good Friday - 1 day after Easter: [NRV] Easter Monday - 1. monday in june: [NV] Queen's Birthday - 4. monday in october: [NV] Labour Day - """ - - id = "en-NZ" - easter_type = EASTER_WESTERN - - def holiday_new_years_day_observed(self, year): - date = SmartDayArrow(year, 1, 1) - - if date.weekday() in ["saturday", "sunday"]: - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="New Year's Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_after_new_years_day(self, year): - date = SmartDayArrow(year, 1, 2) - - if date.weekday() in ["sunday", "monday"]: - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("tuesday", including=True), - description="Day after New Year's Day", - flags="NV", - notes="")] - - elif date.weekday() == "saturday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="Day after New Year's Day", - flags="NV", - notes="")] - - return [Holiday( - locale=self.id, - region="", - date=date, - description="Day after New Year's Day", - flags="NV", - notes="")] - - def holiday_waitangi_day_observed(self, year): - date = SmartDayArrow(year, 2, 6) - - if year > 2016 and date.weekday() in ["saturday", "sunday"]: - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="Waitangi Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_anzac_day_observed(self, year): - date = SmartDayArrow(year, 4, 25) - - if year > 2015 and date.weekday() in ["saturday", "sunday"]: - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="ANZAC Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_christmas_day_observed(self, year): - date = SmartDayArrow(year, 12, 25) - - if date.weekday() == "sunday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("tuesday", including=True), - description="Christmas Day (observed)", - flags="NV", - notes="")] - - elif date.weekday() == "saturday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="Christmas Day (observed)", - flags="NV", - notes="")] - - return [] - - def holiday_boxing_day_observed(self, year): - date = SmartDayArrow(year, 12, 26) - - if date.weekday() == "sunday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("tuesday", including=True), - description="Boxing Day (observed)", - flags="NV", - notes="")] - - elif date.weekday() == "saturday": - return [Holiday( - locale=self.id, - region="", - date=date.shift_to_weekday("monday", including=True), - description="Boxing Day (observed)", - flags="NV", - notes="")] - - return [] diff --git a/src/holidata/holidays/en-US.py b/src/holidata/holidays/en-US.py deleted file mode 100644 index 6cf3d7c..0000000 --- a/src/holidata/holidays/en-US.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class en_US(Locale): - """ - 01-01: [NF] New Year's Day - 07-04: [NF] Independence Day - 11-11: [NF] Veterans Day - 12-24: [NRF] Christmas Eve - 12-25: [NRF] Christmas Day - 3. monday in January: [NV] Birthday of Martin Luther King, Jr. - 3. monday in February: [NV] Washington's Birthday - 3. monday in April: [MA,ME] [V] Patriots' Day - 1. last monday in May: [NV] Memorial Day - 1. monday in September: [NV] Labor Day - 2. monday in October: [NV] Columbus Day - 4. thursday in November: [NV] Thanksgiving Day - 4. friday in November: [NV] Day after Thanksgiving - """ - - id = "en-US" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/en-ZA.py b/src/holidata/holidays/en-ZA.py deleted file mode 100644 index b04eb24..0000000 --- a/src/holidata/holidays/en-ZA.py +++ /dev/null @@ -1,91 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - -""" -Public Holidays Act (Act No 36 of 1994). -sources: -https://www.gov.za/sites/default/files/gcis_document/201409/act36of1994.pdf -https://www.gov.za/sites/default/files/gcis_document/201409/act48of1995.pdf -""" - - -class en_ZA(Locale): - """ - 12-25: [NF] Christmas Day - 2 days before Easter: [NRV] Good Friday - 1 day after Easter: [NRV] Family Day - """ - - id = "en-ZA" - easter_type = EASTER_WESTERN - - def holiday_new_years_day(self, year): - """01-01: [NF] New Year's Day""" - return self.get_holidays(SmartDayArrow(year, 1, 1), "New Year's Day") - - def holiday_human_rights_day(self, year): - """03-21: [NF] Human Rights Day""" - return self.get_holidays(SmartDayArrow(year, 3, 21), "Human Rights Day") - - def holiday_freedom_day(self, year): - """04-27: [NF] Freedom Day""" - return self.get_holidays(SmartDayArrow(year, 4, 27), "Freedom Day") - - def holiday_workers_day(self, year): - """05-01: [NF] Worker's Day""" - return self.get_holidays(SmartDayArrow(year, 5, 1), "Worker's Day") - - def holiday_youth_day(self, year): - """06-16: [NF] Youth Day""" - return self.get_holidays(SmartDayArrow(year, 6, 16), "Youth Day") - - def holiday_national_womens_day(self, year): - """08-09: [NF] National Women's Day""" - return self.get_holidays(SmartDayArrow(year, 8, 9), "National Women's Day") - - def holiday_heritage_day(self, year): - """09-24: [NF] Heritage Day""" - return self.get_holidays(SmartDayArrow(year, 9, 24), "Heritage Day") - - def holiday_day_of_reconciliation(self, year): - """12-16: [NF] Day of Reconciliation""" - return self.get_holidays(SmartDayArrow(year, 12, 16), "Day of Reconciliation") - - def holiday_day_of_goodwill(self, year): - """12-26: [NF] Day of Goodwill""" - return self.get_holidays(SmartDayArrow(year, 12, 26), "Day of Goodwill") - - def get_holidays(self, original_date, description): - """ - Applies section 2.1 of the Public Holidays Act (Act No 36 of 1994): - 'Whenever any public holiday falls on a Sunday, the following Monday shall be a public holiday.' - """ - if original_date.weekday() == "sunday": - supplement_date = original_date.shift(days=1) - return [ - Holiday( - locale=self.id, - region="", - date=original_date, - description=description, - flags="NF", - notes=""), - Holiday( - locale=self.id, - region="", - date=supplement_date, - description=description + " (Supplement)", - flags="NF", - notes="Supplement holiday") - ] - else: - return [Holiday( - locale=self.id, - region='', - date=original_date, - description=description, - flags="NF", - notes="")] diff --git a/src/holidata/holidays/es-CO.py b/src/holidata/holidays/es-CO.py deleted file mode 100644 index fd9fba2..0000000 --- a/src/holidata/holidays/es-CO.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - -""" -LEY 51 DE 1983 -http://www.suin-juriscol.gov.co/viewDocument.asp?id=1605519 -""" - - -class es_CO(Locale): - """ - 01-01: [NF] Año Nuevo - 05-01: [NF] Día del Trabajo - 07-20: [NF] Grito de Independencia - 08-07: [NF] Batalla de Boyacá - 12-08: [NRF] Inmaculada Concepción - 12-25: [NRF] Navidad - 3 days before Easter: [NRV] Jueves Santo - 2 days before Easter: [NRV] Viernes Santo - Easter: [NRV] Domingo de Pascua - 43 days after Easter: [NRV] La Ascensión del Señor - 64 days after Easter: [NRV] Corpus Christi - 71 days after Easter: [NRV] El Sagrado Corazón de Jesús - """ - - id = "es-CO" - easter_type = EASTER_WESTERN - - def holiday_reyes(self, year): - """First Monday after January 6.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 1, 6).shift_to_weekday("monday", including=True), - "Día de los Reyes Magos", - "NRV" - )] - - def holiday_san_jose(self, year): - """First Monday after March 19.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 3, 19).shift_to_weekday("monday", including=True), - "Día de San José", - "NRV" - )] - - def holiday_san_pedro_san_pablo(self, year): - """First Monday after June 29.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 6, 29).shift_to_weekday("monday", including=True), - "San Pedro y San Pablo", - "NRV" - )] - - def holiday_asuncion(self, year): - """First Monday after August 15.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 8, 15).shift_to_weekday("monday", including=True), - "Asunción de la Virgen", - "NRV" - )] - - def holiday_dia_raza(self, year): - """First Monday after October 12.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 10, 12).shift_to_weekday("monday", including=True), - "Día de la Raza", - "NV" - )] - - def holiday_todos_santos(self, year): - """First Monday after November 1.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 11, 1).shift_to_weekday("monday", including=True), - "Todos los Santos", - "NRV" - )] - - def holiday_independencia_cartagena(self, year): - """First Monday after November 11.""" - return [Holiday( - self.id, - "", - SmartDayArrow(year, 11, 11).shift_to_weekday("monday", including=True), - "Independencia de Cartagena", - "NV" - )] - diff --git a/src/holidata/holidays/es-US.py b/src/holidata/holidays/es-US.py deleted file mode 100644 index 61b8981..0000000 --- a/src/holidata/holidays/es-US.py +++ /dev/null @@ -1,25 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class es_US(Locale): - """ - 01-01: [NF] Año Neuvo - 07-04: [NF] Día de la Independiencia - 11-11: [NF] Día de los Veteranos - 12-24: [NRF] Nochebuena - 12-25: [NRF] Navidad - 3. monday in January: [NV] Cumpleaños de Martin Luther King, Jr. - 3. monday in February: [NV] Día del Presidente - 3. monday in April: [MA,ME] [V] Día del Patriota - 1. last monday in May: [NV] Día de los Caídos - 1. monday in September: [NV] Día del Trabajo - 2. monday in October: [NV] Día de Columbus - 4. thursday in November: [NV] Día de Acción de Gracias - 4. friday in November: [NV] Día después de Acción de Gracias - """ - - id = "es-US" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/et-EE.py b/src/holidata/holidays/et-EE.py deleted file mode 100644 index 8dc7884..0000000 --- a/src/holidata/holidays/et-EE.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - -""" -sources -https://www.riigiteataja.ee/akt/109032011007 (Public Holidays and Days of National Importance Act) -""" - - -class et_EE(Locale): - """ - 01-01: [NF] Uusaasta - 02-24: [NF] Iseseisvuspäev, Eesti Vabariigi aastapäev - 05-01: [NF] Kevadpüha - 06-23: [NF] Võidupüha - 06-24: [NF] Jaanipäev - 08-20: [NF] Taasiseseisvumispäev - 12-24: [NF] Jõululaupäev - 12-25: [NF] Esimene jõulupüha - 12-26: [NF] Teine jõulupüha - 2 days before Easter: [NRV] Suur reede - Easter: [NRV] Ülestõusmispühade 1. püha - 49 days after Easter: [NRV] Nelipühade 1. püha - """ - - id = "et-EE" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/fi-FI.py b/src/holidata/holidays/fi-FI.py deleted file mode 100644 index 3b06575..0000000 --- a/src/holidata/holidays/fi-FI.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - -""" -source: https://almanakka.helsinki.fi/en/flag-days-and-holidays-in-finland.html -""" - - -class fi_FI(Locale): - """ - 01-01: [NF] Uudenvuodenpäivä - 01-06: [NRF] Loppiainen - 05-01: [NF] Vappu - 12-06: [NF] Itsenäisyyspäivä - 12-25: [NRF] Joulupäivä - 12-26: [NRF] Tapaninpäivä - 2 days before Easter: [NRV] Pitkäperjantai - Easter: [NRV] Pääsiäispäivä - 1 day after Easter: [NRV] 2. pääsiäispäivä - 39 days after Easter: [NRV] Helatorstai - 49 days after Easter: [NRV] Helluntaipäivä - """ - - id = "fi-FI" - easter_type = EASTER_WESTERN - - def holiday_juhannuspaeivae(self, year): - """ - Saturday between 20 and 26 June: Juhannuspäivä (Midsummer Day) - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 6, 19).shift_to_weekday("saturday", order=1, reverse=False), - "Juhannuspäivä", - "NRV" - )] - - def holiday_pyhaeinpaeivae(self, year): - """ - Saturday between 31 October and 6 November: Pyhäinpäivä (All Saints' Day) - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 10, 30).shift_to_weekday("saturday", order=1, reverse=False), - "Pyhäinpäivä", - "NRV" - )] diff --git a/src/holidata/holidays/fr-BE.py b/src/holidata/holidays/fr-BE.py deleted file mode 100644 index ff77967..0000000 --- a/src/holidata/holidays/fr-BE.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class fr_BE(Locale): - """ - 01-01: [NF] Nouvel An - 05-01: [NF] Fête du Travail - 07-21: [NF] Fête nationale - 08-15: [NRF] Assomption - 11-01: [NRF] Toussaint - 11-11: [NF] Jour de l'armistice - 12-25: [NRF] Noël - Easter: [NRV] Pâques - 1 day after Easter: [NRV] Lundi de Pâques - 39 days after Easter: [NRV] Ascension - 49 days after Easter: [NRV] Pentecôte - 50 days after Easter: [NRV] Lundi de Pentecôte - """ - - id = "fr-BE" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/fr-CA.py b/src/holidata/holidays/fr-CA.py deleted file mode 100644 index aa4d8a4..0000000 --- a/src/holidata/holidays/fr-CA.py +++ /dev/null @@ -1,77 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - - -# -# Information taken from various government websites around 2020-04-16 -# https://www.canada.ca/fr/emploi-developpement-social/services/normes-travail/rapports/jours-feries.html -# http://www4.gouv.qc.ca/FR/Portail/Citoyens/Evenements/travailleur-avec-salaire/Pages/jours-feries-chomes-payes.aspx -# https://www.ontario.ca/document/your-guide-employment-standards-act-0/public-holidays#section-2 -# https://www.cfib-fcei.ca/en/tools-resources/paying-employees-public-holidays-newfoundland-labrador -# https://www.princeedwardisland.ca/en/information/economic-growth-tourism-and-culture/paid-holidays -# https://www2.gnb.ca/content/dam/gnb/Departments/petl-epft/PDF/es/FactSheets/PublicHolidaysVacation.pdf -# https://www.gov.mb.ca/labour/standards/doc,gen-holidays-after-april-30-07,factsheet.html#q12 -# https://www.saskatchewan.ca/business/employment-standards/vacations-holidays-leaves-and-absences/public-statutory-holidays/list-of-saskatchewan-public-holidays -# -# Also those sites for some information -# https://www.officeholidays.com/holidays/canada/canada-remembrance-day -# https://www.timeanddate.com/holidays/canada/family-day -# https://fr.wikipedia.org/wiki/F%C3%AAtes_et_jours_f%C3%A9ri%C3%A9s_au_Canada -# -# I have not checked every province and territory website, but the wikipedia -# summary has been true for everything that I have checked, although it seems -# to be considering more holidays than the bare minimum and also counts holidays -# that are not mandated but usually observed (e.g. St-Patrick's Day in NL which -# is not statutory, but is given to government employees). -# - - -class fr_CA(Locale): - """ - 01-01: [NF] Jour de l'An - 06-24: [QC] [F] Fête Nationale - 07-01: [NF] Fête du Canada - 11-11: [AB,BC,NB,NL,NT] [F] Jour du Souvenir - 12-25: [NRF] Jour de Noël - 12-26: [NRF] Lendemain de Noël - 2 days before Easter: [NRV] Vendredi Saint - 1 day after Easter: [AB,PE,QC] [RV] Lundi de Pâques - 3. monday in February: [AB,ON,SK,NB] [V] Fête de la Famille - 3. monday in February: [MB] [V] Journée Louis Riel - 3. monday in February: [PE] [V] Fête des Insulaires - 1. monday in August: [NT,NU] [V] Premier lundi d'août - 1. monday in August: [AB] [V] Fête du Patrimoine - 1. monday in August: [SK] [V] Fête de la Saskatchewan - 1. monday in August: [NS] [V] Jour de la Fondation - 1. monday in August: [NB] [V] Jour du Nouveau-Brunswick - 1. monday in September: [NV] Fête du Travail - 2. monday in October: [AB,BC,MB,NL,ON,QC,SK,NT,NU,YT] [V] Jour de l'Action de grâce - """ - - id = "fr-CA" - easter_type = EASTER_WESTERN - - def holiday_journee_nationale_des_patriotes(self, year): - return [Holiday( - locale=self.id, - region="QC", - date=SmartDayArrow(year, 5, 25).shift_to_weekday( - "monday", order=1, reverse=True, including=False), - description="Journée Nationale des Patriotes", - flags="V", - notes="")] - - def holiday_fete_de_la_reine_victoria(self, year): - return [Holiday( - locale=self.id, - region=region, - date=SmartDayArrow(year, 5, 25).shift_to_weekday( - "monday", order=1, reverse=True, including=False), - description="Fête de la Reine Victoria", - flags="V", - notes="" - ) for region in ["AB", "BC", "MB", "NS", "ON", "SK", "NT", "NU", "YT"] - ] diff --git a/src/holidata/holidays/fr-FR.py b/src/holidata/holidays/fr-FR.py deleted file mode 100644 index 2f6e4f4..0000000 --- a/src/holidata/holidays/fr-FR.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class fr_FR(Locale): - """ - 01-01: [NF] Jour de l'an - 05-01: [NF] Fête du premier mai - 05-08: [NF] Armistice 1945 - 07-14: [NF] Fête nationale - 08-15: [NRF] Assomption - 11-01: [NRF] Toussaint - 11-11: [NF] Armistice 1918 - 12-25: [NF] Noël - 1 day after Easter: [NRV] Lundi de Pâques - 39 days after Easter: [NRV] Ascension - 49 days after Easter: [NRV] Pentecôte - 50 days after Easter: [NRV] Lundi de Pentecôte - """ - - id = "fr-FR" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/holidays.py b/src/holidata/holidays/holidays.py index a522554..af2cd24 100644 --- a/src/holidata/holidays/holidays.py +++ b/src/holidata/holidays/holidays.py @@ -249,105 +249,7 @@ def get_holidays_of(self, year, lang): yield holiday -class Locale(metaclass=PluginMount): - """ - Represents holidays in a given locale. - """ - id = None - easter_type = None - - fixed_regex = re.compile(r"^\s*(?P\d\d)-(?P\d\d): " - r"(\[(?P[^]]+)\]\s+)?" - r"\[(?P[A-Z]*)\] (?P.*)$", re.UNICODE) - nth_weekday_regex = re.compile(r"^\s*(?P\d+)\.(?P last | )" - r"(?P[a-z]+) in (?P[a-zA-Z]+):\s+" - r"(\[(?P[^]]+)\]\s+)?" - r"\[(?P[A-Z]*)\] (?P.*)$", re.UNICODE) - easter_shift_regex = re.compile(r"^\s*((?P\d+) day(s)? (?P(before|after)) )?Easter:\s+" - r"(\[(?P[^]]+)\]\s+)?" - r"\[(?P[A-Z]*)\] (?P.*)$", re.UNICODE) - - def __init__(self): - if self.id is None: - raise ValueError(f"Locale {self.__class__.__name__} does not provide an id!") - - @staticmethod - def get(identifier): - return Locale.get_plugin(identifier, "id") - - def get_holidays_of(self, year): - """ - Yield all the Holiday objects corresponding to the definitions in the - self.__doc__ and also as given by the dynamic self.holiday_* methods. - """ - # First process lines in the __doc__ - for line in self.__doc__.splitlines(): - # Skip empty lines - if not line.strip(): - continue - - holidata = self._parse_holidata(line, year) - - if holidata is None: - print(f"Following line could not be processed: '{line}'") - continue - - for region in holidata["regions"]: - yield Holiday( - locale=self.id, - region=region, - date=holidata["date"], - description=holidata["description"], - flags=holidata["flags"], - notes=holidata["notes"], - ) - - # Second, call holiday functions - for method in [getattr(self, func) for func in dir(self) if func.startswith("holiday_")]: - holidays = method(year) - - for holiday in holidays: - yield holiday - - def _parse_holidata(self, line, year): - function_map = [ - (self.fixed_regex, self._date_from_fixed_reference), - (self.nth_weekday_regex, self._date_from_weekday_reference), - (self.easter_shift_regex, self._date_from_easter_reference), - ] - - for reg_exp, create_date_from in function_map: - m = reg_exp.search(line) - if m is not None: - return dict(regions=([x.strip() for x in m.group("regions").split(",")] if m.group("regions") is not None else [""]), - date=create_date_from(m, year), - description=m.group("description"), - flags=m.group("flags"), - notes="") - - return None - - def _date_from_fixed_reference(self, m, year): - return SmartDayArrow(year, int(m.group("month")), int(m.group("day"))) - - def _date_from_weekday_reference(self, m, year): - return month_reference(year, - m.group("month"), - first=m.group("last").strip() == "") \ - .shift_to_weekday(m.group("weekday"), - order=int(m.group("order")), - reverse=m.group("last").strip() == "last", - including=True) - - def _date_from_easter_reference(self, m, year): - if self.easter_type is None: - raise ValueError(f"Locale {self.__class__.__name__} does not provide its easter type (WESTERN|ORTHODOX)") - - return easter(year, self.easter_type) \ - .shift(days=int((m.group("days")) if m.group("days") is not None else 0) * (1 if m.group("direction") == "after" else -1)) - - -class LocaleWrapper: +class Locale: def __init__(self, country, lang): self.country = country self.lang = lang diff --git a/src/holidata/holidays/hr-HR.py b/src/holidata/holidays/hr-HR.py deleted file mode 100644 index 41af628..0000000 --- a/src/holidata/holidays/hr-HR.py +++ /dev/null @@ -1,38 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - - -class hr_HR(Locale): - """ - 01-01: [NF] Nova Godina - 01-06: [NRF] Sveta tri kralja - 05-01: [NF] Praznik rada - 05-30: [NF] Dan državnosti - 06-22: [NF] Dan antifašističke borbe - 08-05: [NF] Dan pobjede i domovinske zahvalnosti i Dan hrvatskih branitelja - 08-15: [NRF] Velika Gospa - 11-01: [NRF] Dan svih svetih - 12-25: [NRF] Božić - 12-26: [NRF] Sveti Stjepan - Easter: [NRV] Uskrs - 1 day after Easter: [NRV] Uskršnji ponedjeljak - 60 days after Easter: [NRV] Tijelovo - """ - - id = "hr-HR" - easter_type = EASTER_WESTERN - - def holiday_dan_sjecanja_na_zrtve_domovinskog_rata_i_dan_sjecanja_na_zrtvu_vukovara_i_skabrnje(self, year): - if year >= 2020: - return [Holiday( - self.id, - "", - SmartDayArrow(year, 11, 18), - "Dan sjećanja na žrtve Domovinskog rata i Dan sjećanja na žrtvu Vukovara i Škabrnje", - "NF" - )] - - return [] diff --git a/src/holidata/holidays/hu-HU.py b/src/holidata/holidays/hu-HU.py deleted file mode 100644 index 8820fcd..0000000 --- a/src/holidata/holidays/hu-HU.py +++ /dev/null @@ -1,261 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import easter, SmartDayArrow -from .holidays import Locale, Holiday - -""" -sources: -- Hungarian Constitution - Article J (1) - https://www.keh.hu/magyarorszag_alaptorvenye/1515-Magyarorszag_Alaptorvenye -- 2017. évi XIII. törvény egyes törvényeknek a nagypéntek munkaszüneti nappá történő nyilvánításával összefüggő módosításáról - https://mkogy.jogtar.hu/jogszabaly?docid=A1700013.TV -""" - - -class hu_HU(Locale): - """ - 01-01: [NF] Újév - 03-15: [NF] Az 1848-as forradalom ünnepe - 05-01: [NF] A munka ünnepe - 08-20: [NF] Az államalapítás ünnepe - 10-23: [NF] Az 1956-os forradalom ünnepe - 11-01: [NRF] Mindenszentek - 12-25: [NRF] Karácsony - 12-26: [NRF] Karácsony - Easter: [NRV] Húsvét - 1 day after Easter: [NRV] Húsvéthétfő - 49 days after Easter: [NRV] Pünkösd - 50 days after Easter: [NRV] Pünkösdhétfő - """ - - id = "hu-HU" - easter_type = EASTER_WESTERN - - def holiday_nagypentek(self, year): - """ - 2 days before Easter: [NRV] Nagypéntek (since 2017) - """ - if year >= 2017: - return [Holiday( - self.id, - "", - easter(year, self.easter_type).shift(days=-2), - "Nagypéntek", - "NRV" - )] - - return [] - - def holiday_munkaszuneti_nap(self, year): - """ - Non-Working days (Munkaszüneti nap) - When a public holiday falls on a Tuesday or a Thursday, a special decree swaps the preceding Monday or the - following Friday (respectively) with a not too distant Saturday - 2015: 28/2014. (IX. 24.) NGM rendelet a 2015. évi munkaszüneti napok körüli munkarendről - 2016: 8/2015. (VI. 29.) NGM rendelet a 2016. évi munkaszüneti napok körüli munkarendről - 2018: 9/2017. (V. 19.) NGM rendelet a 2018. évi munkaszüneti napok körüli munkarendről - 2019: 6/2018. (VIII. 23.) PM rendelet a 2019. évi munkaszüneti napok körüli munkarendről - 2020: 7/2019. (VI. 25.) PM rendelet a 2020. évi munkaszüneti napok körüli munkarendről - 2021: 14/2020. (V. 13.) ITM rendelet a 2021. évi munkaszüneti napok körüli munkarendről - 2022: 23/2021. (VI. 1.) ITM rendelet a 2022. évi munkaszüneti napok körüli munkarendről - """ - if year == 2015: - """ - 01-02, swapped with 01-10 - 08-21, swapped with 08-08 - 12-24, swapped with 12-12 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 1, 2), - description="Munkaszüneti nap", - flags="NF", - notes="2015-01-10 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 8, 21), - description="Munkaszüneti nap", - flags="NF", - notes="2015-08-08 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 24), - description="Munkaszüneti nap", - flags="NF", - notes="2015-12-12 munkanap" - )] - if year == 2016: - """ - 03-14, swapped with 03-05 - 10-31, swapped with 10-15 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 3, 14), - description="Munkaszüneti nap", - flags="NF", - notes="2016-03-05 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 10, 31), - description="Munkaszüneti nap", - flags="NF", - notes="2016-10-15 munkanap" - )] - if year == 2018: - """ - 03-16, swapped with 03-10 - 04-30, swapped with 04-21 - 10-22, swapped with 10-13 - 11-02, swapped with 11-10 - 12-24, swapped with 12-01 - 12-31, swapped with 12-15 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 3, 16), - description="Munkaszüneti nap", - flags="NF", - notes="2018-03-10 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 4, 30), - description="Munkaszüneti nap", - flags="NF", - notes="2018-04-21 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 10, 22), - description="Munkaszüneti nap", - flags="NF", - notes="2018-10-13 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 11, 2), - description="Munkaszüneti nap", - flags="NF", - notes="2018-11-10 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 24), - description="Munkaszüneti nap", - flags="NF", - notes="2018-12-01 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 31), - description="Munkaszüneti nap", - flags="NF", - notes="2018-12-15 munkanap" - )] - if year == 2019: - """ - 08-19, swapped with 08-10 - 12-24, swapped with 12-07 - 12-27, swapped with 12-14 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 8, 19), - description="Munkaszüneti nap", - flags="NF", - notes="2019-08-10 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 24), - description="Munkaszüneti nap", - flags="NF", - notes="2019-12-07 munkanap" - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 27), - description="Munkaszüneti nap", - flags="NF", - notes="2019-12-14 munkanap" - )] - if year == 2020: - """ - 08-21, swapped with 08-29 - 12-24, swapped with 12-12 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 8, 21), - description="Munkaszüneti nap", - flags="NF", - notes="2020-08-29 munkanap"), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 24), - description="Munkaszüneti nap", - flags="NF", - notes="2020-12-12 munkanap" - )] - if year == 2021: - """ - 12-24, swapped with 12-11 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 24), - description="Munkaszüneti nap", - flags="NF", - notes="2021-12-11 munkanap" - )] - if year == 2022: - """ - 03-14, swapped with 03-26 - 10-31, swapped with 10-15 - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 3, 14), - description="Munkaszüneti nap", - flags="NF", - notes="2022-03-26 munkanap"), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 10, 31), - description="Munkaszüneti nap", - flags="NF", - notes="2022-10-15 munkanap" - )] - - return [] diff --git a/src/holidata/holidays/is-IS.py b/src/holidata/holidays/is-IS.py deleted file mode 100644 index 77ba536..0000000 --- a/src/holidata/holidays/is-IS.py +++ /dev/null @@ -1,73 +0,0 @@ -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - - -class is_IS(Locale): - """ - 01-01: [NRF] Nýársdagur - 05-01: [NF] Verkalýðsdagurinn - 06-17: [NF] Þjóðhátíðardagurinn - 12-25: [NRF] Jóladagur - 12-26: [NRF] Annar dagur jóla - 3 days before Easter: [NRV] Skírdagur - 2 days before Easter: [NRV] Föstudagurinn langi - Easter: [NRV] Páskadagur - 1 day after Easter: [NRV] Annar dagur páska - 39 days after Easter: [NRV] Uppstigningardagur - 49 days after Easter: [NRV] Hvítasunnudagur - 50 days after Easter: [NRV] Annar dagur hvítasunnu - 1. monday in August: [NV] Frídagur verslunarmanna - """ - - id = "is-IS" - easter_type = EASTER_WESTERN - - def holiday_first_day_of_summer(self, year): - """ - Calculate sumardagurinn fyrsti (first day of summer). - - The holiday falls on the first Thursday after the 18th of April. - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 4, 18).shift_to_weekday("thursday"), - description="Sumardagurinn fyrsti", - flags="NV", - notes="", - ) - ] - - def holiday_half_days(self, year): - """ - Define half-day holidays. - - Both Christmas Eve (_aðfangadagur jóla_) and New Year's Eve - (_gamlársdagur_) are public holidays in Iceland from 13:00 only. - They're included as full-day holidays, but with an explanatory - note. - - 12-24: [NRF] Aðfangadagur jóla - 12-31: [NF] Gamlársdagur - """ - return [ - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 24), - description="Aðfangadagur jóla", - flags="NRF", - notes="Holiday from 13:00", - ), - Holiday( - locale=self.id, - region="", - date=SmartDayArrow(year, 12, 31), - description="Gamlársdagur", - flags="NF", - notes="Holiday from 13:00", - ), - ] diff --git a/src/holidata/holidays/it-IT.py b/src/holidata/holidays/it-IT.py deleted file mode 100644 index 76a9a8e..0000000 --- a/src/holidata/holidays/it-IT.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class it_IT(Locale): - """ - 01-01: [NF] Capodanno - 01-06: [NRF] Epifania - 04-25: [NF] Festa della liberazione - 05-01: [NF] Festa del lavoro - 06-02: [NF] Festa della repubblica - 08-15: [NRF] Assunzione (ferragosto) - 11-01: [NRF] Ognissanti - 12-08: [NRF] Immacolata concezione - 12-25: [NRF] Natale - 12-26: [NRF] S.to Stefano - Easter: [NRV] Pasqua - 1 day after Easter: [NRV] Pasquetta - """ - - id = "it-IT" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/nb-NO.py b/src/holidata/holidays/nb-NO.py deleted file mode 100644 index 69810e3..0000000 --- a/src/holidata/holidays/nb-NO.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class nb_NO(Locale): - """ - 01-01: [NF] Nyttårsdag - 05-01: [NF] Offentlig Høytidsdag - 05-08: [NF] Frigjøringsdag 1945 - 05-17: [NF] Grunnlovsdag - 12-24: [NRF] Julaften - 12-25: [NRF] Juledag - 12-26: [NRF] Juledag - 12-31: [NF] Nyttårsaften - 49 days before Easter: [NRV] Fastelavn - 7 days before Easter: [NRV] Palmesøndag - 3 days before Easter: [NRV] Skjærtorsdag - 2 days before Easter: [NRV] Langfredag - Easter: [NRV] Påskedag - 1 day after Easter: [NRV] Påskedag - 39 days after Easter: [NRV] Kristi Himmelfartsdag - 49 days after Easter: [NRV] Pinsedag - 50 days after Easter: [NRV] Pinsedag - """ - - id = "nb-NO" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/nl-BE.py b/src/holidata/holidays/nl-BE.py deleted file mode 100644 index fedd7f2..0000000 --- a/src/holidata/holidays/nl-BE.py +++ /dev/null @@ -1,24 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class nl_BE(Locale): - """ - 01-01: [NF] Nieuwjaar - 05-01: [NF] Dag van de arbeid - 07-21: [NF] Nationale feestdag - 08-15: [NRF] Onze Lieve Vrouw hemelvaart - 11-01: [NRF] Allerheiligen - 11-11: [NF] Wapenstilstand - 12-25: [NRF] Kerstmis - Easter: [NRV] Pasen - 1 day after Easter: [NRV] Paasmaandag - 39 days after Easter: [NRV] Onze Lieve Heer hemelvaart - 49 days after Easter: [NRV] Pinksteren - 50 days after Easter: [NRV] Pinkstermaandag - """ - - id = "nl-BE" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/nl-NL.py b/src/holidata/holidays/nl-NL.py deleted file mode 100644 index caf35a6..0000000 --- a/src/holidata/holidays/nl-NL.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Holiday, Locale - - -class nl_NL(Locale): - """ - 01-01: [NF] Nieuwjaarsdag - 05-04: [NF] Dodenherdenking - 05-05: [NF] Bevrijdingsdag - 12-05: [NRF] Sinterklaas - 12-25: [NRF] Eerste Kerstdag - 12-26: [NRF] Tweede Kerstdag - 2 days before Easter: [NRV] Goede Vrijdag - Easter: [NRV] Eerste Paasdag - 1 day after Easter: [NRV] Tweede Paasdag - 39 days after Easter: [NRV] Hemelvaartsdag - 49 days after Easter: [NRV] Eerste Pinksterdag - 50 days after Easter: [NRV] Tweede Pinksterdag - """ - - id = "nl-NL" - easter_type = EASTER_WESTERN - - def holiday_koninginnedag(self, year): - """ - 04-27 or saturday before, if it falls on sunday: [NF] Koninginnedag - Until 2013 - """ - if year > 2013: - return [] - - date = SmartDayArrow(year, 4, 30) - - if date.weekday() == "sunday": - date = date.shift(days=-1) - - return [Holiday( - locale=self.id, - region="", - date=date, - description="Koninginnedag", - flags="NV", - notes="")] - - def holiday_koningsdag(self, year): - """ - 04-27 or saturday before if it falls on sunday: [NF] Koningsdag - Since 2014 - """ - if year < 2014: - return [] - - date = SmartDayArrow(year, 4, 27) - - if date.weekday() == "sunday": - date = date.shift(days=-1) - - return [Holiday( - locale=self.id, - region="", - date=date, - description="Koningsdag", - flags="NV", - notes="")] - - def holiday_koninkrijksdag(self, year): - date = SmartDayArrow(year, 12, 15) - - if date.weekday() == "sunday": - date = date.shift(days=1) - - return [Holiday( - locale=self.id, - region="", - date=date, - description="Koninkrijksdag", - flags="NV", - notes="")] diff --git a/src/holidata/holidays/pl-PL.py b/src/holidata/holidays/pl-PL.py deleted file mode 100644 index b583d25..0000000 --- a/src/holidata/holidays/pl-PL.py +++ /dev/null @@ -1,29 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - -""" -source: http://prawo.sejm.gov.pl/isap.nsf/download.xsp/WDU20150000090/O/D20150090.pdf -""" - - -class pl_PL(Locale): - """ - 01-01: [NF] Nowy Rok - 01-06: [NRF] Trzech Króli - 05-01: [NF] Święto Pracy - 05-03: [NF] Święto Konstytucji Trzeciego Maja - 08-15: [NRF] Wniebowzięcie Najświętszej Maryi Panny - 11-01: [NRF] Wszystkich Świętych - 11-11: [NF] Narodowe Święto Niepodległości - 12-25: [NRF] Boże Narodzenie (pierwszy dzień) - 12-26: [NRF] Boże Narodzenie (drugi dzień) - Easter: [NRV] Wielkanoc - 1 day after Easter: [NRV] Poniedziałek Wielkanocny - 49 days after Easter: [NRV] Zielone Świątki - 60 days after Easter: [NRV] Boże Ciało - """ - - id = "pl-PL" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/pt-BR.py b/src/holidata/holidays/pt-BR.py deleted file mode 100644 index c8644fb..0000000 --- a/src/holidata/holidays/pt-BR.py +++ /dev/null @@ -1,101 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -# Information gathered from Brazilian legislation. - -# National holidays: -# Law 10.607/2002: http://www.planalto.gov.br/ccivil_03/leis/2002/l10607.htm -# Law 6.802/1980: http://www.planalto.gov.br/ccivil_03/leis/l6802.htm - -# State holidays -# AC: State laws 1.538/2004, 1.411/2001, 14/1964, 1.526/2004, and 57/1965 -# AL: State laws 5.508/1993, 5.509/1993, 5.724/1995, and Decree 68.782 (30/dec/2019) -# AP: State law 667/2002 and Art. 355 of the Constitution of the Federative Republic of Brazil -# AM: State laws 25/1977 and 84/2010 -# BA: Art. 6 of the Constitution of the Federative Republic of Brazil -# CE: State laws 9.093/1995, 9.093/1995 and Art. 18 of the Constitution of the State of Ceará -# DF: District law 963/1995 -# ES: State law 11.010/2019 -# GO: State law 20.756/2020 -# MA: State law 2.457/1964 -# MT: State law 7.879/2002 -# MS: State law 10/1979 -# MG: Art. 256 of the Constitution of the State of Minas Gerais -# PA: State law 5.999/1996 -# PB: State law 3.489/1967 -# PR: State law 4.658/1962 -# PE: State law 13.835/2009 -# PI: State law 176/1937 -# RJ: State laws 5.243/2008, 5.198/2008, and 4.007/2002 -# RN: State laws 7.831/2000 and 8.913/2006 -# RS: Art. 6 of the Constitution of the State of Rio Grande do Sul and Decree 36.180 (18/set/1995) -# RO: State laws 2.291/2010 and 1.026/2001 -# RR: Art. 9 of the Constitution of the State of Roraima -# SC: State laws 12.906/2004 and 10.306/1996 -# SP: State law 9.497/1997 -# SE: Art. 269 of the Constitution of the State of Sergipe -# TO: State laws 98/1989, 960/1998, 627/1993 - - -class pt_BR(Locale): - """ - 01-01: [NF] Confraternização Universal - 01-04: [RO] [F] Criação do Estado de Rondônia - 01-23: [AC] [RF] Dia do Evangélico no Acre - 03-06: [PE] [F] Revolução Pernambucana de 1817 - 03-08: [AC] [F] Dia Internacional da Mulher - 03-18: [TO] [F] Autonomia do Estado de Tocantins - 03-19: [AP, CE] [RF] Dia de São José - 03-25: [CE] [F] Abolição da Escravidão no Ceará - 04-21: [DF] [F] Fundação de Brasília - 04-21: [MG] [F] Execução de Tiradentes - 04-21: [NF] Tiradentes - 04-23: [RJ] [RF] Dia de São Jorge - 05-01: [NF] Dia Internacional do Trabalhador - 06-15: [AC] [F] Aniversário do Estado do Acre - 06-18: [RO] [RF] Dia do Evangélico em Rondônia - 06-24: [AL, PE] [RF] São João - 06-29: [AL] [RF] São Pedro - 07-02: [BA] [F] Independência da Bahia - 07-08: [SE] [F] Emancipação Política de Sergipe - 07-09: [SP] [F] Revolução Constitucionalista de 1932 - 07-26: [GO] [F] Fundação da Cidade de Goiás - 07-28: [MA] [F] Adesão do Maranhão à Independência do Brasil - 08-05: [PB] [F] Fundação do Estado da Paraíba - 08-07: [RN] [F] Dia do Rio Grande do Norte - 08-11: [SC] [F] Dia de Santa Catarina - 08-15: [CE] [RF] Dia de Nossa Senhora da Assunção - 08-15: [PA] [F] Adesão do Pará à Independência do Brasil - 09-05: [AC] [F] Dia da Amazônia - 09-05: [AM] [F] Elevação do Amazonas à Categoria de Província - 09-07: [NF] Independência do Brasil - 09-08: [TO] [F] Nossa Senhora da Natividade - 09-13: [AP] [F] Criação do Território Federal do Amapá - 09-16: [AL] [F] Emancipação Política do Alagoas - 09-20: [RS] [F] Dia do Gaúcho - 10-03: [RN] [F] Mártires de Cunhaú e Uruaçu - 10-05: [RR] [F] Criação dos Estado de Roraima - 10-05: [TO] [F] Criação dos Estado de Tocantins - 10-11: [MS] [F] Criação do Estado do Mato Grosso do Sul - 10-12: [NRF] Nossa Senhora Aparecida - 10-19: [PI] [F] Dia do Piauí - 10-24: [GO] [F] Pedra Fundamental de Goiânia - 11-02: [NRF] Finados - 11-15: [NF] Proclamação da República - 11-17: [AC] [F] Assinatura do Tratado de Petrópolis - 11-20: [AL] [F] Morte de Zumbi dos Palmares - 11-20: [AM, MT, RJ] [F] Dia da Consciência Negra - 11-25: [SC] [RF] Dia de Santa Catarina de Alexandria - 11-30: [DF] [RF] Dia do Evangélico do Distrito Federal - 12-08: [AM] [RF] Nossa Senhora da Conceição - 12-19: [PR] [F] Emancipação Política do Estado do Paraná - 12-25: [NRF] Natal - 47 days before Easter: [NRV] Carnaval - Easter: [NRV] Páscoa - """ - - id = "pt-BR" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/pt-PT.py b/src/holidata/holidays/pt-PT.py deleted file mode 100644 index 387445e..0000000 --- a/src/holidata/holidays/pt-PT.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class pt_PT(Locale): - """ - 01-01: [NF] Ano Novo - 04-25: [NF] Dia da Liberdade - 05-01: [NF] Dia do Trabalhador - 06-10: [NF] Dia de Portugal - 08-15: [NF] Assunção de Nossa Senhora - 10-05: [NF] Implantação da República - 11-01: [NF] Dia de Todos os Santos - 12-01: [NF] Restauração da Independência - 12-08: [NF] Imaculada Conceição - 12-25: [NF] Natal - 47 days before Easter: [NRV] Carnaval - 2 days before Easter: [NRV] Sexta-feira Santa - Easter: [NRV] Páscoa - 60 days after Easter: [NRV] Corpo de Deus - """ - - id = "pt-PT" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/ru-RU.py b/src/holidata/holidays/ru-RU.py deleted file mode 100644 index 9cbbf02..0000000 --- a/src/holidata/holidays/ru-RU.py +++ /dev/null @@ -1,21 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_ORTHODOX - -from .holidays import Locale - - -class ru_RU(Locale): - """ - 01-01: [NF] Новый Год - 01-07: [NRF] Рождество Христово - 02-23: [NF] День защитника Отечества - 03-08: [NF] Международный женский день - 05-01: [NF] Праздник весны и труда - 05-09: [NF] День Победы - 06-12: [NF] День России - 11-04: [NF] День народного единства - Easter: [NRV] Пасха - """ - - id = "ru-RU" - easter_type = EASTER_ORTHODOX diff --git a/src/holidata/holidays/sk-SK.py b/src/holidata/holidays/sk-SK.py deleted file mode 100644 index 444ad9e..0000000 --- a/src/holidata/holidays/sk-SK.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from .holidays import Locale - - -class sk_SK(Locale): - """ - 01-01: [NF] Deň vzniku Slovenskej republiky - 01-06: [NRF] Zjavenie Pána / Traja králi - 05-01: [NF] Sviatok práce - 05-08: [NF] Deň víťazstva nad fašizmom - 07-05: [NRF] Sviatok svätého Cyrila a Metoda - 08-29: [NF] Výročie SNP - 09-01: [NF] Deň Ústavy Slovenskej republiky - 09-15: [NRF] Sedembolestná Panna Mária - 11-01: [NRF] Sviatok všetkých svätých - 11-17: [NF] Deň boja za slobodu a demokraciu - 12-24: [NRF] Štedrý deň - 12-25: [NRF] Prvý sviatok vianočný - 12-26: [NRF] Druhý sviatok vianočný - 2 days before Easter: [NRV] Veľký piatok - 1 day after Easter: [NRV] Veľkonočný pondelok - """ - - id = "sk-SK" - easter_type = EASTER_WESTERN diff --git a/src/holidata/holidays/sl-SI.py b/src/holidata/holidays/sl-SI.py deleted file mode 100644 index 59c2961..0000000 --- a/src/holidata/holidays/sl-SI.py +++ /dev/null @@ -1,46 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - -""" -sources: http://www.pisrs.si/Pis.web/pregledPredpisa?id=ZAKO865# -""" - - -class sl_SI(Locale): - """ - 01-01: [NF] Novo leto - 02-08: [NF] Prešernov dan - 04-27: [NF] Dan upora proti okupatorju - 05-01: [NF] Praznik dela - 05-02: [NF] Praznik dela - 06-25: [NF] Dan državnosti - 08-15: [NRF] Marijino vnebovzetje - 10-31: [NRF] Dan reformacije - 11-01: [NF] Dan spomina na mrtve - 12-25: [NF] Božič - 12-26: [NF] Dan samostojnosti in enotnosti - Easter: [NRV] Velikonočna nedelja - 1 day after Easter: [NRV] Velikonočni ponedeljek - 50 days after Easter: [NRV] Binkošti - """ - - id = "sl-SI" - easter_type = EASTER_WESTERN - - def holiday_novo_leto(self, year): - """ - From 1955 until May 2012, when the National Assembly of Slovenia passed the Public Finance Balance Act, - 2 January was a work-free day. It was reintroduced in 2017. - 2012<: https://www.uradni-list.si/1/objava.jsp?sop=2012-01-1700 - 2016<: https://www.uradni-list.si/1/objava.jsp?sop=2016-01-3568 - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 1, 2), - "Novo leto", - "NF" - )] if year not in [2013, 2014, 2015, 2016] else [] diff --git a/src/holidata/holidays/sv-FI.py b/src/holidata/holidays/sv-FI.py deleted file mode 100644 index 317ac7e..0000000 --- a/src/holidata/holidays/sv-FI.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - -""" -source: https://almanakka.helsinki.fi/en/flag-days-and-holidays-in-finland.html -""" - - -class sv_FI(Locale): - """ - 01-01: [NF] Nyårsdagen - 01-06: [NRF] Trettondedagen - 05-01: [NF] Första maj - 12-06: [NF] Självständighetsdagen - 12-25: [NRF] Juldagen - 12-26: [NRF] Annandag jul - 2 days before Easter: [NRV] Långfredagen - Easter: [NRV] Påskdagen - 1 day after Easter: [NRV] Annandag påsk - 39 days after Easter: [NRV] Kristi himmelfärdsdag - 49 days after Easter: [NRV] Pingst - """ - - id = "sv-FI" - easter_type = EASTER_WESTERN - - def holiday_midsommardagen(self, year): - """ - Saturday between 20 and 26 June: Midsommardagen - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 6, 19).shift_to_weekday("saturday", order=1, reverse=False), - "Midsommardagen", - "NRV" - )] - - def holiday_alla_helgons_dag(self, year): - """ - Saturday between 31 October and 6 November: Alla helgons dag (All Saints' Day) - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 10, 30).shift_to_weekday("saturday", order=1, reverse=False), - "Alla helgons dag", - "NRV" - )] diff --git a/src/holidata/holidays/sv-SE.py b/src/holidata/holidays/sv-SE.py deleted file mode 100644 index 6b6ec97..0000000 --- a/src/holidata/holidays/sv-SE.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding=utf-8 -from dateutil.easter import EASTER_WESTERN - -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - -""" -source: https://www.riksdagen.se/sv/dokument-lagar/dokument/svensk-forfattningssamling/lag-1989253-om-allmanna-helgdagar_sfs-1989-253 -source: https://www.riksdagen.se/sv/dokument-lagar/dokument/svensk-forfattningssamling/semesterlag-1977480_sfs-1977-480 -""" - - -class sv_SE(Locale): - """ - 01-01: [NF] Nyårsdagen - 01-06: [NRF] Trettondedag jul - 05-01: [NF] Första maj - 06-06: [NF] Nationaldagen - 12-24: [NRF] Julafton - 12-25: [NRF] Juldagen - 12-26: [NRF] Annandag jul - 12-31: [NF] Nyårsafton - 2 days before Easter: [NRV] Långfredagen - Easter: [NRV] Påskdagen - 1 day after Easter: [NRV] Annandag påsk - 39 days after Easter: [NRV] Kristi himmelsfärdsdag - 49 days after Easter: [NRV] Pingstdagen - """ - - id = "sv-SE" - easter_type = EASTER_WESTERN - - def __midsommar(self, year): - """ - Find the Saturday between 20 and 26 June - """ - return SmartDayArrow(year, 6, 19).shift_to_weekday("saturday", order=1, reverse=False) - - def holiday_midsommarafton(self, year): - """ - The day before midsommardagen: [NV] Midsommarafton - """ - return [Holiday( - self.id, - "", - self.__midsommar(year).shift(days=-1), - "Midsommarafton", - "NV" - )] - - def holiday_midsommardagen(self, year): - """ - Saturday between 20 and 26 June: [NV] Midsommardagen - """ - return [Holiday( - self.id, - "", - self.__midsommar(year), - "Midsommardagen", - "NV" - )] - - def holiday_alla_helgons_dag(self, year): - """ - Saturday between 31 October and 6 November: [NRV] Alla helgons dag - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 10, 30).shift_to_weekday("saturday", order=1, reverse=False), - "Alla helgons dag", - "NRV" - )] diff --git a/src/holidata/holidays/tr-TR.py b/src/holidata/holidays/tr-TR.py deleted file mode 100644 index 38c78d4..0000000 --- a/src/holidata/holidays/tr-TR.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -from holidata.utils import SmartDayArrow -from .holidays import Locale, Holiday - -""" -sources: -law on national holidays and general holidays: https://www.mevzuat.gov.tr/mevzuat?MevzuatNo=2429&MevzuatTur=1&MevzuatTertip=5 -dates for holidays 'Ramazan Bayramı' and 'Kurban Bayramı': https://vakithesaplama.diyanet.gov.tr/dini_gunler.php -""" - - -class tr_TR(Locale): - """ - 01-01: [NF] Yılbaşı - 04-23: [NF] Ulusal Egemenlik ve Çocuk Bayramı - 05-01: [NF] Emek ve Dayanışma Günü - 05-19: [NF] Atatürk'ü Anma, Gençlik ve Spor Bayramı - 08-30: [NF] Zafer Bayramı - 10-29: [NF] Cumhuriyet Bayramı - """ - - id = "tr-TR" - - @staticmethod - def __ramazan_bayrami_reference(year): - ramazan_bayrami_reference = { - 2011: SmartDayArrow(2011, 8, 29), - 2012: SmartDayArrow(2012, 8, 18), - 2013: SmartDayArrow(2013, 8, 7), - 2014: SmartDayArrow(2014, 7, 27), - 2015: SmartDayArrow(2015, 7, 16), - 2016: SmartDayArrow(2016, 7, 4), - 2017: SmartDayArrow(2017, 6, 24), - 2018: SmartDayArrow(2018, 6, 14), - 2019: SmartDayArrow(2019, 6, 4), - 2020: SmartDayArrow(2020, 5, 23), - 2021: SmartDayArrow(2021, 5, 12), - 2022: SmartDayArrow(2022, 5, 1), - 2023: SmartDayArrow(2023, 4, 20), - 2024: SmartDayArrow(2024, 4, 9), - 2025: SmartDayArrow(2025, 3, 29), - 2026: SmartDayArrow(2026, 3, 19), - 2027: SmartDayArrow(2027, 3, 8), - } - - return ramazan_bayrami_reference[year] - - @staticmethod - def __kurban_bayrami_reference(year): - kurban_bayrami_reference = { - 2011: SmartDayArrow(2011, 11, 5), - 2012: SmartDayArrow(2012, 10, 24), - 2013: SmartDayArrow(2013, 10, 14), - 2014: SmartDayArrow(2014, 10, 3), - 2015: SmartDayArrow(2015, 9, 23), - 2016: SmartDayArrow(2016, 9, 11), - 2017: SmartDayArrow(2017, 8, 31), - 2018: SmartDayArrow(2018, 8, 20), - 2019: SmartDayArrow(2019, 8, 10), - 2020: SmartDayArrow(2020, 7, 30), - 2021: SmartDayArrow(2021, 7, 19), - 2022: SmartDayArrow(2022, 7, 8), - 2023: SmartDayArrow(2023, 6, 27), - 2024: SmartDayArrow(2024, 6, 15), - 2025: SmartDayArrow(2025, 6, 5), - 2026: SmartDayArrow(2026, 5, 26), - 2027: SmartDayArrow(2027, 5, 15), - } - - return kurban_bayrami_reference[year] - - def holiday_demokrasi_ve_milli_birlik_gunu(self, year): - """ - Democracy and National Unity Day (since 2017) - 07-15 [NF] Demokrasi ve Milli Birlik Günü - """ - return [Holiday( - self.id, - "", - SmartDayArrow(year, 7, 15), - "Demokrasi ve Milli Birlik Günü", - "NF" - )] if year >= 2017 else [] - - def holiday_ramazan_bayrami(self, year): - """ - Ramazan Bayramı 1.-3. Gün - """ - reference = self.__ramazan_bayrami_reference(year) - - return [Holiday( - self.id, - "", - reference.shift(days=i), - f"Ramazan Bayramı ({i}. Gün)", - "NRV" - ) for i in [1, 2, 3]] - - def holiday_kurban_bayrami(self, year): - """ - Kurban Bayramı 1.-4. Gün - """ - reference = self.__kurban_bayrami_reference(year) - - return [Holiday( - self.id, - "", - reference.shift(days=i), - "Kurban Bayramı ({}. Gün)".format(i), - "NRV" - ) for i in [1, 2, 3, 4]] diff --git a/tests/test_holidata.py b/tests/test_holidata.py index b824033..2cbb427 100644 --- a/tests/test_holidata.py +++ b/tests/test_holidata.py @@ -2,7 +2,7 @@ from snapshottest.file import FileSnapshot from snapshottest.formatter import Formatter -from holidata import Locale, Country, LocaleWrapper +from holidata import Locale, Country from tests import HOLIDATA_YEAR_MAX SNAPSHOT_FILE_PATH_PATTERN = "snapshots/snap_test_holidata/{}[{}-{}] 1.py" @@ -12,13 +12,7 @@ def create_locales(): response = [] for country_class in Country.plugins: - country = country_class() - - if hasattr(country, "get_holidays_of"): - response.extend([LocaleWrapper(country_class(), lang_id) for lang_id in country.languages]) - - for locale_class in Locale.plugins: - response.append(locale_class()) + response.extend([Locale(country_class(), lang_id) for lang_id in country_class.languages]) return response diff --git a/tests/test_holidays.py b/tests/test_holidays.py index 4678652..7c352fd 100644 --- a/tests/test_holidays.py +++ b/tests/test_holidays.py @@ -2,7 +2,7 @@ import pytest -from holidata import Locale, Country, LocaleWrapper +from holidata import Locale, Country from tests import HOLIDATA_YEAR_MAX @@ -10,13 +10,7 @@ def create_locales(): response = [] for country_class in Country.plugins: - country = country_class() - - if hasattr(country, "get_holidays_of"): - response.extend([LocaleWrapper(country_class(), lang_id) for lang_id in country.languages]) - - for locale_class in Locale.plugins: - response.append(locale_class()) + response.extend([Locale(country_class(), lang_id) for lang_id in country_class.languages]) return response From bd38f08240cb27197c3802eef8baaaee1dd11568 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 21 Nov 2023 12:51:55 +0100 Subject: [PATCH 2/5] Overhaul wrappers Locale and Holidata Signed-off-by: Thomas Lauf --- bin/holidata | 4 ++-- src/holidata/__init__.py | 40 +++++++++++++++++++++---------- src/holidata/holidays/__init__.py | 3 +-- src/holidata/holidays/holidays.py | 13 ---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bin/holidata b/bin/holidata index e7f4b67..9436071 100755 --- a/bin/holidata +++ b/bin/holidata @@ -37,7 +37,7 @@ import sys from docopt import docopt -from holidata import Holidata +from holidata import for_locale def parse_locale(locale): @@ -65,7 +65,7 @@ if __name__ == "__main__": # When neither '--locale' nor '--country' are given, docopt prints usage sys.exit(1) - print(Holidata(country=country_id, language=lang_id, year=args["--year"]).formatted_as(args["--output"]), end="") + print(for_locale(country_id, lang_id).holidays_of(args["--year"]).formatted_as(args["--output"]), end="") except ValueError as e: sys.exit(str(e)) diff --git a/src/holidata/__init__.py b/src/holidata/__init__.py index cee49ea..2d5c23a 100644 --- a/src/holidata/__init__.py +++ b/src/holidata/__init__.py @@ -1,6 +1,5 @@ from .emitters import Emitter from .holidays import * -from .holidays.holidays import Locale def get_country_for(identifier): @@ -21,28 +20,20 @@ def get_emitter_for(identifier): return emitter_class() -def create_locale_for(country_id, lang_id=None): +def for_locale(country_id, lang_id=None): country = get_country_for(country_id) lang_id = country.validate_language_or_get_default(lang_id) return Locale(country, lang_id) -def parse_year(year): - try: - return int(year) - except ValueError: - raise ValueError(f"Invalid year '{year}'! Has to be an integer.") - - class Holidata: emitter = None holidays = None - def __init__(self, country=None, language=None, year=None): - year = parse_year(year) - locale = create_locale_for(country_id=country, lang_id=language) - self.holidays = locale.get_holidays_of(year) + def __init__(self, holidays, emitter=None): + self.holidays = holidays + self.emitter = emitter def __str__(self): return self.emitter.output(self.holidays) @@ -51,3 +42,26 @@ def formatted_as(self, format_id): self.emitter = get_emitter_for(format_id) return self + + +class Locale: + def __init__(self, country, lang): + self.country = country + self.lang = lang + + def get_holidays_of(self, year): + return self.country.get_holidays_of(year, self.lang) + + def holidays_of(self, year): + return Holidata(self.country.get_holidays_of(self._parse_year(year), self.lang)) + + @staticmethod + def _parse_year(year): + try: + return int(year) + except ValueError: + raise ValueError(f"Invalid year '{year}'! Has to be an integer.") + + @property + def id(self): + return f"{self.lang}-{self.country.id}" diff --git a/src/holidata/holidays/__init__.py b/src/holidata/holidays/__init__.py index f4cf0f4..cb5d01f 100644 --- a/src/holidata/holidays/__init__.py +++ b/src/holidata/holidays/__init__.py @@ -1,5 +1,5 @@ from .ES import * -from .holidays import Locale, Country +from .holidays import Country __all__ = [ "Country", @@ -35,5 +35,4 @@ "TR", "US", "ZA", - "Locale", ] diff --git a/src/holidata/holidays/holidays.py b/src/holidata/holidays/holidays.py index af2cd24..b5a4387 100644 --- a/src/holidata/holidays/holidays.py +++ b/src/holidata/holidays/holidays.py @@ -247,16 +247,3 @@ def get_holidays_of(self, year, lang): for generator in self.holiday_generators: for holiday in generator.build_for_year_and_lang(year, lang): yield holiday - - -class Locale: - def __init__(self, country, lang): - self.country = country - self.lang = lang - - def get_holidays_of(self, year): - return self.country.get_holidays_of(year, self.lang) - - @property - def id(self): - return f"{self.lang}-{self.country.id}" From a16664fe7c1a883a28ca4db3a454b79eff20e19c Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 21 Nov 2023 14:20:22 +0100 Subject: [PATCH 3/5] Fix language handling Language id can be given in upper or lower case in the main script. Internally, the language id is handled in lower case. Signed-off-by: Thomas Lauf --- src/holidata/holidays/holidays.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/holidata/holidays/holidays.py b/src/holidata/holidays/holidays.py index b5a4387..552b8fa 100644 --- a/src/holidata/holidays/holidays.py +++ b/src/holidata/holidays/holidays.py @@ -214,7 +214,7 @@ def validate_language_or_get_default(self, lang_id): raise ValueError( f"Country '{self.id}' has no default language specified! Choose one of [{', '.join(self.languages)}].") - return lang_id + return lang_id.lower() def define_holiday(self): generator = HolidayGenerator(self.id, self.default_lang, self.easter_type) From eb3c72e4d494b94ccab220917ccf8b1b7fa6d285 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 21 Nov 2023 15:25:02 +0100 Subject: [PATCH 4/5] Update ChangeLog Signed-off-by: Thomas Lauf --- ChangeLog | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e0934f..ea48ab8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,19 +1,20 @@ -- Fix permalinks for holidays in locale de-DE for region BE +- #97 Merge locale and country +- Fix permalinks for holidays in locale de-DE for region BE 2023.11.0 -- es-ES: Implement 2024 holidays of Spain -- Drop support for Python 3.7 -- Use double quotes instead of single quotes and f-strings +- es-ES: Implement 2024 holidays of Spain +- Drop support for Python 3.7 +- Use double quotes instead of single quotes and f-strings 2023.04.0 -- en-GB: Add bank holiday for the coronation of King Charles III -- Move creator functions to holidata module -- Print proper error messages for exceptions instead of stack traces -- Fix regex for locale +- en-GB: Add bank holiday for the coronation of King Charles III +- Move creator functions to holidata module +- Print proper error messages for exceptions instead of stack traces +- Fix regex for locale 2022.11.0 -- es-ES: Implement 2023 holidays of Spain +- es-ES: Implement 2023 holidays of Spain 2022.9.0 -- en-GB: Add Bank Holiday for State Funeral of Queen Elizabeth II +- en-GB: Add Bank Holiday for State Funeral of Queen Elizabeth II 2022.8.2 -- Add ability to specify a locale via country and language +- Add ability to specify a locale via country and language 2022.8.0 - #87 Update legal sources for Turkish holidays From c3be9cffafe3a274861cdb8417ed2ecfbcd7d738 Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Tue, 21 Nov 2023 15:29:43 +0100 Subject: [PATCH 5/5] Fix indentation and add newlines Signed-off-by: Thomas Lauf --- ChangeLog | 188 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea48ab8..3760df8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,105 +1,109 @@ -- #97 Merge locale and country -- Fix permalinks for holidays in locale de-DE for region BE +- #97 Merge locale and country +- Fix permalinks for holidays in locale de-DE for region BE + 2023.11.0 -- es-ES: Implement 2024 holidays of Spain -- Drop support for Python 3.7 -- Use double quotes instead of single quotes and f-strings +- es-ES: Implement 2024 holidays of Spain +- Drop support for Python 3.7 +- Use double quotes instead of single quotes and f-strings + 2023.04.0 -- en-GB: Add bank holiday for the coronation of King Charles III -- Move creator functions to holidata module -- Print proper error messages for exceptions instead of stack traces -- Fix regex for locale +- en-GB: Add bank holiday for the coronation of King Charles III +- Move creator functions to holidata module +- Print proper error messages for exceptions instead of stack traces +- Fix regex for locale + 2022.11.0 -- es-ES: Implement 2023 holidays of Spain +- es-ES: Implement 2023 holidays of Spain + 2022.9.0 -- en-GB: Add Bank Holiday for State Funeral of Queen Elizabeth II +- en-GB: Add Bank Holiday for State Funeral of Queen Elizabeth II + 2022.8.2 -- Add ability to specify a locale via country and language +- Add ability to specify a locale via country and language 2022.8.0 -- #87 Update legal sources for Turkish holidays +- #87 Update legal sources for Turkish holidays 2022.7.0 -- Restructured package -- #85 Error in locale en-GB, year 2022 - (Thanks to Richard Fieldsend) -- #80 Add locale en-ZA - (Thanks to girtu) -- #83 Update non-working days for 2022 in locale hu-HU -- #81 Add locale et-EE - (Thanks to h0adp0re) -- #78 Add locale for sl-SI - (Thanks to Dejan Dezman) -- #21 Update locale for pt-BR - (Thanks to Adriano Correa) -- #58 Update locale for es-ES - (Thanks to Vicente Jimenez Aguilar) -- #59 Add locale for hu-HU - (Thanks to David Hanak) -- #60 Add locale for tr-TR - (Thanks to farukara) -- #55 Fixed: Wrong assignment of flag `N` in locales en-US and es-US -- #54 Fixed: Wrong assignment of flag `N` in locale de-CH -- #53 Fixed: Regional holidays marked as national in locale de-DE -- #52 Fixed: Non-regional holidays not marked as national in locale nl-NL -- #51 Fixed: Regional holidays marked as national in locale de-AT -- #19 Add locale for sv-SE - (Thanks to Martijn van der Ven) -- #49 Add additional office holidays for en-US/es-US - (Thanks to Brian Burnett) -- #13 Add locale for es-CO - (Thanks to Jorge E. Gómez) -- #44 Add locale fr-CA - (Thanks to Ghyslain Leclerc) -- #29 Add locale en-CA - (Thanks to Ghyslain Leclerc) -- Add locale sv-FI -- #30 Add locale fi-FI - (Thanks to Antti Heinonen) -- #22 Add locale pl-PL - (Thanks to sebacyp) -- #10 Add locale cs-CZ - (Thanks to Jakub Pavlík) -- #40 Add missing holidays in locale de-DE for region BE -- #38 Update croatian holidays according to the law valid for the year 2020 and onwards - (Thanks to Saša Janiška) -- #32 Make project python only -- #25 Add locale for is-IS - (Thanks to Matt Riggott) -- #33 Add locale for pt-PT - (Thanks to lldh) -- Add locale it-IT -- Add locale fr-FR -- Add locale el-GR -- Add locale nl-NL -- Add locale en-NZ -- Add locale es-ES -- Add locale ru-RU -- Add XML emitter -- Add YAML emitter -- Add locale en-GB -- Add locale nb-NO -- Add locale da-DK -- Add locale nl-BE -- Add locale fr-BE -- Add locale de-BE -- Add locale es-US -- Add regions to locale de-AT -- Add locale de-AT -- Add locale de-CH -- Add emitters -- Add locale de-DE -- Replace module 'countries' by subpackage 'holidays' -- Add support for regions -- Add option for output format -- #2 Fix some Croatian holidays - (Thanks to Saša Janiška) -- #1 Add locale hr-HR - (Thanks to Saša Janiška) -- Add locale sk-SK and en-US -- Add Proof-Of-Concept python implementation +- Restructured package +- #85 Error in locale en-GB, year 2022 + (Thanks to Richard Fieldsend) +- #80 Add locale en-ZA + (Thanks to girtu) +- #83 Update non-working days for 2022 in locale hu-HU +- #81 Add locale et-EE + (Thanks to h0adp0re) +- #78 Add locale for sl-SI + (Thanks to Dejan Dezman) +- #21 Update locale for pt-BR + (Thanks to Adriano Correa) +- #58 Update locale for es-ES + (Thanks to Vicente Jimenez Aguilar) +- #59 Add locale for hu-HU + (Thanks to David Hanak) +- #60 Add locale for tr-TR + (Thanks to farukara) +- #55 Fixed: Wrong assignment of flag `N` in locales en-US and es-US +- #54 Fixed: Wrong assignment of flag `N` in locale de-CH +- #53 Fixed: Regional holidays marked as national in locale de-DE +- #52 Fixed: Non-regional holidays not marked as national in locale nl-NL +- #51 Fixed: Regional holidays marked as national in locale de-AT +- #19 Add locale for sv-SE + (Thanks to Martijn van der Ven) +- #49 Add additional office holidays for en-US/es-US + (Thanks to Brian Burnett) +- #13 Add locale for es-CO + (Thanks to Jorge E. Gómez) +- #44 Add locale fr-CA + (Thanks to Ghyslain Leclerc) +- #29 Add locale en-CA + (Thanks to Ghyslain Leclerc) +- Add locale sv-FI +- #30 Add locale fi-FI + (Thanks to Antti Heinonen) +- #22 Add locale pl-PL + (Thanks to sebacyp) +- #10 Add locale cs-CZ + (Thanks to Jakub Pavlík) +- #40 Add missing holidays in locale de-DE for region BE +- #38 Update croatian holidays according to the law valid for the year 2020 and onwards + (Thanks to Saša Janiška) +- #32 Make project python only +- #25 Add locale for is-IS + (Thanks to Matt Riggott) +- #33 Add locale for pt-PT + (Thanks to lldh) +- Add locale it-IT +- Add locale fr-FR +- Add locale el-GR +- Add locale nl-NL +- Add locale en-NZ +- Add locale es-ES +- Add locale ru-RU +- Add XML emitter +- Add YAML emitter +- Add locale en-GB +- Add locale nb-NO +- Add locale da-DK +- Add locale nl-BE +- Add locale fr-BE +- Add locale de-BE +- Add locale es-US +- Add regions to locale de-AT +- Add locale de-AT +- Add locale de-CH +- Add emitters +- Add locale de-DE +- Replace module 'countries' by subpackage 'holidays' +- Add support for regions +- Add option for output format +- #2 Fix some Croatian holidays + (Thanks to Saša Janiška) +- #1 Add locale hr-HR + (Thanks to Saša Janiška) +- Add locale sk-SK and en-US +- Add Proof-Of-Concept python implementation Project started November 8, 2016. ------ start ----------------------------------- -