Skip to content

Commit

Permalink
Merge branch 'upd-madagascar' of https://github.com/KJhellico/python-…
Browse files Browse the repository at this point in the history
…holidays into KJhellico-upd-madagascar
  • Loading branch information
arkid15r committed Jun 28, 2023
2 parents 267f34d + a533965 commit 866b68f
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ The list of supported countries, their subdivisions and supported languages
* - Madagascar
- MG
-
-
- en_US, **mg**, uk
* - Malawi
- MW
-
Expand Down
78 changes: 51 additions & 27 deletions holidays/countries/madagascar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,28 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from datetime import date
from datetime import timedelta as td
from gettext import gettext as tr

from dateutil.easter import easter

from holidays.constants import JAN, MAR, MAY, JUN, AUG, NOV, DEC, SUN
from holidays.constants import MAR, MAY, JUN, DEC, SUN
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays


class Madagascar(HolidayBase):
class Madagascar(HolidayBase, ChristianHolidays, InternationalHolidays):
"""
https://www.officeholidays.com/countries/madagascar
https://www.timeanddate.com/holidays/madagascar/
"""

country = "MG"
default_language = "mg"
supported_languages = ("en_US", "mg", "uk")

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
super().__init__(*args, **kwargs)

def _populate(self, year):
# Observed since 1947
Expand All @@ -33,40 +39,58 @@ def _populate(self, year):

super()._populate(year)

self[date(year, JAN, 1)] = "Taom-baovao / New Year's Day"
self[date(year, MAR, 8)] = "Fetin'ny vehivavy / Women's Day"
self[date(year, MAR, 29)] = "Fetin'ny mahery fo / Martyrs' Day"
self[date(year, MAY, 1)] = "Labour Day"
self[self._get_nth_weekday_of_month(3, SUN, JUN)] = "Fetin'ny ray / Father's Day"
# New Year's Day.
self._add_new_years_day(tr("Taom-baovao"))

if year >= 1960:
self[date(year, JUN, 26)] = "Independence Day"
# Women's Day.
self._add_womens_day(tr("Fetin'ny vehivavy"))

self[date(year, AUG, 15)] = "Fiakaran'ny Masina Maria tany an-danitra / Assumption Day"
# Martyrs' Day.
self._add_holiday(tr("Fetin'ny mahery fo"), MAR, 29)

self[date(year, NOV, 1)] = "Fetin'ny olo-masina / All Saints' Day"
# Easter Sunday.
self._add_easter_sunday(tr("Fetin'ny paska"))

if year >= 2011:
self[date(year, DEC, 11)] = "Republic Day"
# Easter Monday.
self._add_easter_monday(tr("Alatsinain'ny paska"))

self[date(year, DEC, 25)] = "Fetin'ny noely / Christmas Day"
# Labor Day.
self._add_labor_day(tr("Fetin'ny asa"))

easter_date = easter(year)
self[easter_date] = "Fetin'ny paska / Easter Sunday"
self[easter_date + td(days=+1)] = "Alatsinain'ny paska / Easter Monday"
self[
easter_date + td(days=+39)
] = "Fiakaran'ny Jesosy kristy tany an-danitra / Ascension Day"
# Ascension Day.
self._add_ascension_thursday(tr("Fiakaran'ny Jesosy kristy tany an-danitra"))

whit_sunday = easter_date + td(days=+49)
self[whit_sunday] = "Pentekosta / Whit Sunday"
# Whit Sunday.
whit_sunday = self._add_whit_sunday(tr("Pentekosta"))

self[easter_date + td(days=+50)] = "Alatsinain'ny pentekosta / Whit Monday"
# Whit Monday.
self._add_whit_monday(tr("Alatsinain'ny pentekosta"))

dt = self._get_nth_weekday_of_month(-1, SUN, MAY)
if dt == whit_sunday:
dt += td(days=+7)
self[dt] = "Fetin'ny Reny / Mother's Day"
# Mother's Day.
self._add_holiday(tr("Fetin'ny reny"), dt)

# Father's Day.
self._add_holiday(tr("Fetin'ny ray"), self._get_nth_weekday_of_month(3, SUN, JUN))

if year >= 1960:
# Independence Day.
self._add_holiday(tr("Fetin'ny fahaleovantena"), JUN, 26)

# Assumption Day.
self._add_assumption_of_mary_day(tr("Fiakaran'ny Masina Maria tany an-danitra"))

# All Saints' Day.
self._add_all_saints_day(tr("Fetin'ny olo-masina"))

if year >= 2011:
# Republic Day.
self._add_holiday(tr("Fetin'ny Repoblika"), DEC, 11)

# Christmas Day.
self._add_christmas_day(tr("Fetin'ny noely"))


class MG(Madagascar):
Expand Down
97 changes: 97 additions & 0 deletions holidays/locale/en_US/LC_MESSAGES/MG.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Madagascar holidays en_US localization.
# Authors: ~Jhellico <[email protected]>, (c) 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.28\n"
"POT-Creation-Date: 2023-06-25 17:39+0300\n"
"PO-Revision-Date: 2023-06-25 17:45+0300\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
"Language-Team: Python Holidays localization team\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.2.2\n"

#. New Year's Day.
#: ./holidays/countries/madagascar.py:43
msgid "Taom-baovao"
msgstr "New Year's Day"

#. Women's Day.
#: ./holidays/countries/madagascar.py:46
msgid "Fetin'ny vehivavy"
msgstr "Women's Day"

#. Martyrs' Day.
#: ./holidays/countries/madagascar.py:49
msgid "Fetin'ny mahery fo"
msgstr "Martyrs' Day"

#. Easter Sunday.
#: ./holidays/countries/madagascar.py:52
msgid "Fetin'ny paska"
msgstr "Easter Sunday"

#. Easter Monday.
#: ./holidays/countries/madagascar.py:55
msgid "Alatsinain'ny paska"
msgstr "Easter Monday"

#. Labor Day.
#: ./holidays/countries/madagascar.py:58
msgid "Fetin'ny asa"
msgstr "Labor Day"

#. Ascension Day.
#: ./holidays/countries/madagascar.py:61
msgid "Fiakaran'ny Jesosy kristy tany an-danitra"
msgstr "Ascension Day"

#. Whit Sunday.
#: ./holidays/countries/madagascar.py:64
msgid "Pentekosta"
msgstr "Whit Sunday"

#. Whit Monday.
#: ./holidays/countries/madagascar.py:67
msgid "Alatsinain'ny pentekosta"
msgstr "Whit Monday"

#. Mother's Day.
#: ./holidays/countries/madagascar.py:73
msgid "Fetin'ny reny"
msgstr "Mother's Day"

#. Father's Day.
#: ./holidays/countries/madagascar.py:76
msgid "Fetin'ny ray"
msgstr "Father's Day"

#. Independence Day.
#: ./holidays/countries/madagascar.py:80
msgid "Fetin'ny fahaleovantena"
msgstr "Independence Day"

#. Assumption Day.
#: ./holidays/countries/madagascar.py:83
msgid "Fiakaran'ny Masina Maria tany an-danitra"
msgstr "Assumption Day"

#. All Saints' Day.
#: ./holidays/countries/madagascar.py:86
msgid "Fetin'ny olo-masina"
msgstr "All Saints' Day"

#. Republic Day.
#: ./holidays/countries/madagascar.py:90
msgid "Fetin'ny Repoblika"
msgstr "Republic Day"

#. Christmas Day.
#: ./holidays/countries/madagascar.py:93
msgid "Fetin'ny noely"
msgstr "Christmas Day"
97 changes: 97 additions & 0 deletions holidays/locale/mg/LC_MESSAGES/MG.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Madagascar holidays.
# Authors: ~Jhellico <[email protected]>, (c) 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.28\n"
"POT-Creation-Date: 2023-06-25 17:39+0300\n"
"PO-Revision-Date: 2023-06-25 17:40+0300\n"
"Last-Translator: ~Jhellico <[email protected]>\n"
"Language-Team: Python Holidays localization team\n"
"Language: mg\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.2.2\n"

#. New Year's Day.
#: ./holidays/countries/madagascar.py:43
msgid "Taom-baovao"
msgstr ""

#. Women's Day.
#: ./holidays/countries/madagascar.py:46
msgid "Fetin'ny vehivavy"
msgstr ""

#. Martyrs' Day.
#: ./holidays/countries/madagascar.py:49
msgid "Fetin'ny mahery fo"
msgstr ""

#. Easter Sunday.
#: ./holidays/countries/madagascar.py:52
msgid "Fetin'ny paska"
msgstr ""

#. Easter Monday.
#: ./holidays/countries/madagascar.py:55
msgid "Alatsinain'ny paska"
msgstr ""

#. Labor Day.
#: ./holidays/countries/madagascar.py:58
msgid "Fetin'ny asa"
msgstr ""

#. Ascension Day.
#: ./holidays/countries/madagascar.py:61
msgid "Fiakaran'ny Jesosy kristy tany an-danitra"
msgstr ""

#. Whit Sunday.
#: ./holidays/countries/madagascar.py:64
msgid "Pentekosta"
msgstr ""

#. Whit Monday.
#: ./holidays/countries/madagascar.py:67
msgid "Alatsinain'ny pentekosta"
msgstr ""

#. Mother's Day.
#: ./holidays/countries/madagascar.py:73
msgid "Fetin'ny reny"
msgstr ""

#. Father's Day.
#: ./holidays/countries/madagascar.py:76
msgid "Fetin'ny ray"
msgstr ""

#. Independence Day.
#: ./holidays/countries/madagascar.py:80
msgid "Fetin'ny fahaleovantena"
msgstr ""

#. Assumption Day.
#: ./holidays/countries/madagascar.py:83
msgid "Fiakaran'ny Masina Maria tany an-danitra"
msgstr ""

#. All Saints' Day.
#: ./holidays/countries/madagascar.py:86
msgid "Fetin'ny olo-masina"
msgstr ""

#. Republic Day.
#: ./holidays/countries/madagascar.py:90
msgid "Fetin'ny Repoblika"
msgstr ""

#. Christmas Day.
#: ./holidays/countries/madagascar.py:93
msgid "Fetin'ny noely"
msgstr ""
Loading

0 comments on commit 866b68f

Please sign in to comment.