Skip to content

Commit

Permalink
Merge branch 'dev' into add_get_next_holiday
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosi2143 authored Jan 11, 2025
2 parents adf4653 + eb47c2d commit 1fe9a7e
Show file tree
Hide file tree
Showing 15 changed files with 517 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- --py39-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff
- id: ruff-format
Expand Down
108 changes: 90 additions & 18 deletions holidays/countries/afghanistan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

from gettext import gettext as tr

from holidays.groups import InternationalHolidays, IslamicHolidays
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import InternationalHolidays, IslamicHolidays, PersianCalendarHolidays
from holidays.holiday_base import HolidayBase


class Afghanistan(HolidayBase, InternationalHolidays, IslamicHolidays):
class Afghanistan(HolidayBase, InternationalHolidays, IslamicHolidays, PersianCalendarHolidays):
"""
https://en.wikipedia.org/wiki/Public_holidays_in_Afghanistan
https://www.timeanddate.com/holidays/afghanistan/
Expand All @@ -26,17 +28,14 @@ class Afghanistan(HolidayBase, InternationalHolidays, IslamicHolidays):
default_language = "fa_AF"
# %s (estimated).
estimated_label = tr("%s (برآورد شده)")
# %s (observed).
observed_label = tr("%s (مشاهده شده)")
# %s (observed, estimated).
observed_estimated_label = tr("%s (مشاهده شده، برآورد شده)")
supported_languages = ("en_US", "fa_AF", "ps_AF")
# Afghanistan's regaining of full independence from British influence.
start_year = 1919

def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self)
IslamicHolidays.__init__(self, AfghanistanIslamicHolidays)
PersianCalendarHolidays.__init__(self)
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
Expand All @@ -49,7 +48,7 @@ def _populate_public_holidays(self):

if self._year <= 1996 or 2001 <= self._year <= 2020:
# Nowruz.
self._add_holiday_mar_21(tr("نوروز"))
self._add_nowruz_day(tr("نوروز"))

if self._year >= 1992:
# Mojahedin's Victory Day.
Expand All @@ -64,13 +63,26 @@ def _populate_public_holidays(self):
self._add_holiday_may_9(tr("روز پیروزی شوروی"))

if self._year >= 2022:
# Islamic Emirate Victory Day.
self._add_islamic_emirat_victory_day(tr("روز پیروزی امارت اسلامی"))

# American Withdrawal Day.
self._add_holiday_aug_31(tr("روز خروج آمریکایی ها"))

if self._year >= 2012:
if 2012 <= self._year <= 2020:
# Martyrs' Day.
self._add_holiday_sep_9(tr("روز شهیدان"))

if self._year <= 2021:
# Ashura.
self._add_ashura_day(tr("عاشورا"))

# Prophet's Birthday.
self._add_mawlid_day(tr("میلاد پیامبر"))

# First Day of Ramadan.
self._add_ramadan_beginning_day(tr("اول رمضان"))

# Eid al-Fitr.
name = tr("عید فطر")
self._add_eid_al_fitr_day(name)
Expand All @@ -86,19 +98,79 @@ def _populate_public_holidays(self):
self._add_eid_al_adha_day_two(name)
self._add_eid_al_adha_day_three(name)

# Ashura.
self._add_ashura_day(tr("عاشورا"))

# First Day of Ramadan.
self._add_ramadan_beginning_day(tr("اول رمضان"))

# Prophet's Birthday.
self._add_mawlid_day(tr("میلاد پیامبر"))


class AF(Afghanistan):
pass


class AFG(Afghanistan):
pass


class AfghanistanIslamicHolidays(_CustomIslamicHolidays):
ASHURA_DATES = {
2014: (NOV, 3),
2015: (OCT, 24),
2016: (OCT, 12),
2017: (OCT, 1),
2018: (SEP, 21),
2019: (SEP, 10),
2020: (AUG, 30),
2021: (AUG, 19),
}

EID_AL_ADHA_DATES = {
2014: (OCT, 5),
2015: (SEP, 23),
2016: (SEP, 13),
2017: (SEP, 2),
2018: (AUG, 22),
2019: (AUG, 11),
2020: (JUL, 31),
2021: (JUL, 20),
2022: (JUL, 9),
2023: (JUN, 28),
2024: (JUN, 17),
}

EID_AL_FITR_DATES = {
2014: (JUL, 29),
2015: (JUL, 18),
2016: (JUL, 7),
2017: (JUN, 26),
2018: (JUN, 15),
2019: (JUN, 4),
2020: (MAY, 24),
2021: (MAY, 13),
2022: (MAY, 1),
2023: (APR, 22),
2024: (APR, 10),
}

MAWLID_DATES = {
2014: (JAN, 14),
2015: ((JAN, 3), (DEC, 24)),
2016: (DEC, 12),
2017: (DEC, 1),
2018: (NOV, 21),
2019: (NOV, 10),
2020: (OCT, 29),
2021: (OCT, 19),
2022: (OCT, 8),
2023: (SEP, 27),
2024: (SEP, 16),
}

RAMADAN_BEGINNING_DATES = {
2014: (JUN, 29),
2015: (JUN, 18),
2016: (JUN, 7),
2017: (MAY, 27),
2018: (MAY, 16),
2019: (MAY, 6),
2020: (APR, 24),
2021: (APR, 13),
2022: (APR, 2),
2023: (MAR, 23),
2024: (MAR, 11),
}
5 changes: 1 addition & 4 deletions holidays/countries/lithuania.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ def _populate_public_holidays(self) -> None:
if self._year >= 1991:
self._add_holiday_jul_6(
# Statehood Day.
tr(
"Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) "
"ir Tautiškos giesmės diena"
)
tr("Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) ir Tautiškos giesmės diena")
)

# Assumption Day.
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/thailand.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,7 @@ def _populate_public_holidays(self):
if self._year >= 2019:
# HM King Bhumibol Adulyadej the Great's Birthday Anniversary.
name = tr(
"วันคล้ายวันเฉลิมพระชนมพรรษาพระบาทสมเด็จพระบรมชนกาธิเบศร "
"มหาภูมิพลอดุลยเดชมหาราช บรมนาถบพิตร"
"วันคล้ายวันเฉลิมพระชนมพรรษาพระบาทสมเด็จพระบรมชนกาธิเบศร มหาภูมิพลอดุลยเดชมหาราช บรมนาถบพิตร"
)
elif self._year >= 2016:
# HM King Bhumibol Adulyadej Birthday Anniversary.
Expand Down
11 changes: 11 additions & 0 deletions holidays/groups/persian.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def _add_death_of_khomeini_day(self, name: str) -> Optional[date]:
name, self._persian_calendar.persian_to_gregorian(self._year, 3, 14)
)

def _add_islamic_emirat_victory_day(self, name: str) -> Optional[date]:
"""
Add Islamic Emirate Victory Day (24th day of the 5th month).
Anniversary of the Taliban forces arrival in Kabul.
https://en.wikipedia.org/wiki/Fall_of_Kabul_(2021)
"""
return self._add_persian_calendar_holiday(
name, self._persian_calendar.persian_to_gregorian(self._year, 5, 24)
)

def _add_islamic_republic_day(self, name: str) -> Optional[date]:
"""
Add Islamic Republic Day (12th day of the 1st month).
Expand Down
3 changes: 1 addition & 2 deletions holidays/holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ def __init__(
# Deprecated arguments.
if prov_state := prov or state:
warnings.warn(
"Arguments prov and state are deprecated, use "
f"subdiv='{prov_state}' instead.",
f"Arguments prov and state are deprecated, use subdiv='{prov_state}' instead.",
DeprecationWarning,
)

Expand Down
20 changes: 7 additions & 13 deletions holidays/locale/en_US/LC_MESSAGES/AF.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Holidays 0.64\n"
"Project-Id-Version: Holidays 0.65\n"
"POT-Creation-Date: 2024-12-24 13:40+0530\n"
"PO-Revision-Date: 2024-12-31 15:52+0700\n"
"Last-Translator: Prateekshit Jaiswal <prateekshitjaiswal73@gmail.com>\n"
"PO-Revision-Date: 2025-01-10 18:59+0200\n"
"Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
"Language-Team: Holidays Localization Team\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -63,16 +63,6 @@ msgstr "First Day of Ramadan"
msgid "%s (برآورد شده)"
msgstr "%s (estimated)"

#. %s (observed).
#, c-format
msgid "%s (مشاهده شده)"
msgstr "%s (observed)"

#. %s (observed, estimated).
#, c-format
msgid "%s (مشاهده شده، برآورد شده)"
msgstr "%s (observed, estimated)"

#. Soviet Victory Day.
msgid "روز پیروزی شوروی"
msgstr "Soviet Victory Day"
Expand All @@ -93,6 +83,10 @@ msgstr "Eid al-Fitr"
msgid "عید قربانی"
msgstr "Eid al-Adha"

#. Islamic Emirate Victory Day.
msgid "روز پیروزی امارت اسلامی"
msgstr "Islamic Emirate Victory Day"

#. American Withdrawal Day.
msgid "روز خروج آمریکایی ها"
msgstr "American Withdrawal Day"
20 changes: 7 additions & 13 deletions holidays/locale/fa_AF/LC_MESSAGES/AF.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Holidays 0.64\n"
"Project-Id-Version: Holidays 0.65\n"
"POT-Creation-Date: 2024-12-24 13:40+0530\n"
"PO-Revision-Date: 2024-12-31 15:53+0700\n"
"Last-Translator: Prateekshit Jaiswal <prateekshitjaiswal73@gmail.com>\n"
"PO-Revision-Date: 2025-01-10 18:59+0200\n"
"Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
"Language-Team: Holidays Localization Team\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -63,16 +63,6 @@ msgstr ""
msgid "%s (برآورد شده)"
msgstr ""

#. %s (observed).
#, c-format
msgid "%s (مشاهده شده)"
msgstr ""

#. %s (observed, estimated).
#, c-format
msgid "%s (مشاهده شده، برآورد شده)"
msgstr ""

#. Soviet Victory Day.
msgid "روز پیروزی شوروی"
msgstr ""
Expand All @@ -93,6 +83,10 @@ msgstr ""
msgid "عید قربانی"
msgstr ""

#. Islamic Emirate Victory Day.
msgid "روز پیروزی امارت اسلامی"
msgstr ""

#. American Withdrawal Day.
msgid "روز خروج آمریکایی ها"
msgstr ""
20 changes: 7 additions & 13 deletions holidays/locale/ps_AF/LC_MESSAGES/AF.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Holidays 0.64\n"
"Project-Id-Version: Holidays 0.65\n"
"POT-Creation-Date: 2024-12-25 20:00+0530\n"
"PO-Revision-Date: 2024-12-31 15:53+0700\n"
"Last-Translator: Prateekshit Jaiswal <prateekshitjaiswal73@gmail.com>\n"
"PO-Revision-Date: 2025-01-10 18:59+0200\n"
"Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
"Language-Team: Holidays Localization Team\n"
"Language: ps_AF\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -63,16 +63,6 @@ msgstr "د روژې لومړۍ نیټه"
msgid "%s (برآورد شده)"
msgstr "%s (اټکل)"

#. %s (observed).
#, c-format
msgid "%s (مشاهده شده)"
msgstr "%s (په دې وروستیو کې د افغانستان د کرکټ ملی)"

#. %s (observed, estimated).
#, c-format
msgid "%s (مشاهده شده، برآورد شده)"
msgstr "%s (مشاهده شده، تخمین زده شده است)"

#. Soviet Victory Day.
msgid "روز پیروزی شوروی"
msgstr "د شوروی د بریالیتوب ورځ"
Expand All @@ -93,6 +83,10 @@ msgstr "عید فطر"
msgid "عید قربانی"
msgstr "عید قربانی"

#. Islamic Emirate Victory Day.
msgid "روز پیروزی امارت اسلامی"
msgstr "د اسلامي امارت د بریا ورځ"

#. American Withdrawal Day.
msgid "روز خروج آمریکایی ها"
msgstr "د امریکا د وتلو ورځ"
Loading

0 comments on commit 1fe9a7e

Please sign in to comment.