+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions holidays/calendars/islamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3970,24 +3970,44 @@ class _IslamicLunar:
2076: (DEC, 5),
}

def __init__(self, calendar_delta_days: int = 0) -> None:
"""
Args:
calendar_delta_days:
Number of days to shift all calculated holiday dates.
Positive values move holidays forward, negative values move them backward.
Defaults to 0 (no shift).
"""
self.__calendar_delta_days = calendar_delta_days

def _get_holiday(self, holiday: str, year: int) -> Iterable[tuple[date, bool]]:
confirmed_dates = getattr(
self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {}
)
confirmed_years = getattr(
self, f"{holiday}_DATES_CONFIRMED_YEARS_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", ()
confirmed_years = _normalize_tuple(
getattr(
self, f"{holiday}_DATES_CONFIRMED_YEARS_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", ()
)
)
estimated_dates = getattr(self, f"{holiday}_DATES", {})
calendar_delta_days = self.__calendar_delta_days

for check_year in (year - 1, year):
is_confirmed_year = check_year in confirmed_dates
for dt in _normalize_tuple(
confirmed_dates.get(check_year, estimated_dates.get(check_year, ()))
):
is_confirmed = check_year in confirmed_dates or any(
year_from <= check_year <= year_to
for year_from, year_to in _normalize_tuple(confirmed_years)
is_confirmed = is_confirmed_year or any(
year_from <= check_year <= year_to for year_from, year_to in confirmed_years
)

holiday_date = date(check_year, *dt)
yield (
_timedelta(holiday_date, calendar_delta_days)
if calendar_delta_days and not is_confirmed_year
else holiday_date,
not is_confirmed,
)
yield date(check_year, *dt), not is_confirmed

def _is_long_ramadan(self, eid_al_fitr: date) -> bool:
"""Check whether the Ramadan preceding the given Eid al-Fitr date lasted 30 days.
Expand Down
56 changes: 24 additions & 32 deletions holidays/countries/guyana.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,18 @@ def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs):
islamic_show_estimated:
Whether to add "estimated" label to Islamic holidays name
if holiday date is estimated.

In Guyana, the dates of the Islamic calendar usually fall a day later than
the corresponding dates in the Umm al-Qura calendar.
"""
ChristianHolidays.__init__(self)
HinduCalendarHolidays.__init__(self, cls=GuyanaHinduHolidays)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(
self, cls=GuyanaIslamicHolidays, show_estimated=islamic_show_estimated
self,
cls=GuyanaIslamicHolidays,
show_estimated=islamic_show_estimated,
calendar_delta_days=+1,
)
StaticHolidays.__init__(self, cls=GuyanaStaticHolidays)
kwargs.setdefault("observed_rule", SUN_TO_NEXT_MON)
Expand Down Expand Up @@ -210,44 +216,30 @@ class GuyanaIslamicHolidays(_CustomIslamicHolidays):
# https://web.archive.org/web/20250424074512/https://www.timeanddate.com/holidays/guyana/eid-al-adha
EID_AL_ADHA_DATES_CONFIRMED_YEARS = (2001, 2025)
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
2003: (FEB, 12),
2004: (FEB, 2),
2008: (DEC, 9),
2009: (NOV, 28),
2010: (NOV, 17),
2011: (NOV, 7),
2014: (OCT, 5),
2015: (SEP, 24),
2005: (JAN, 21),
2006: ((JAN, 10), (DEC, 31)),
2007: (DEC, 20),
2012: (OCT, 26),
2013: (OCT, 15),
2016: (SEP, 13),
2017: (SEP, 2),
2018: (AUG, 22),
2021: (JUL, 21),
2023: (JUN, 29),
2024: (JUN, 17),
2025: (JUN, 7),
2019: (AUG, 11),
2020: (JUL, 31),
2022: (JUL, 9),
}

# https://web.archive.org/web/20241006104125/https://www.timeanddate.com/holidays/guyana/prophet-birthday
MAWLID_DATES_CONFIRMED_YEARS = (2001, 2025)
MAWLID_DATES = {
2003: (MAY, 14),
2004: (MAY, 2),
2006: (APR, 11),
2011: (FEB, 16),
2012: (FEB, 5),
2014: (JAN, 14),
2001: (JUN, 4),
2002: (MAY, 24),
2005: (APR, 21),
2007: (MAR, 31),
2008: (MAR, 20),
2009: (MAR, 9),
2010: (FEB, 26),
2013: (JAN, 24),
2015: ((JAN, 3), (DEC, 24)),
2016: (DEC, 12),
2017: (DEC, 1),
2018: (NOV, 21),
2019: (NOV, 10),
2021: (OCT, 19),
2022: (OCT, 9),
2023: (SEP, 28),
2024: (SEP, 16),
2025: (SEP, 5),
2020: (OCT, 29),
}


Expand Down
99 changes: 21 additions & 78 deletions holidays/countries/india.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from gettext import gettext as tr

from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, AUG, SEP, OCT, NOV, DEC
from holidays.constants import OPTIONAL, PUBLIC
from holidays.groups import (
ChristianHolidays,
Expand Down Expand Up @@ -156,11 +156,17 @@ def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs):
islamic_show_estimated:
Whether to add "estimated" label to Islamic holidays name
if holiday date is estimated.

In India, the dates of the Islamic calendar usually fall a day later than
the corresponding dates in the Umm al-Qura calendar.
"""
ChristianHolidays.__init__(self)
HinduCalendarHolidays.__init__(self)
IslamicHolidays.__init__(
self, cls=IndiaIslamicHolidays, show_estimated=islamic_show_estimated
self,
cls=IndiaIslamicHolidays,
show_estimated=islamic_show_estimated,
calendar_delta_days=+1,
)
InternationalHolidays.__init__(self)
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -518,103 +524,40 @@ class IND(India):
class IndiaIslamicHolidays(_CustomIslamicHolidays):
ASHURA_DATES_CONFIRMED_YEARS = (2001, 2025)
ASHURA_DATES = {
2003: (MAR, 14),
2004: (MAR, 2),
2007: (JAN, 30),
2001: (APR, 4),
2002: (MAR, 24),
2005: (FEB, 19),
2006: (FEB, 9),
2008: (JAN, 19),
2009: ((JAN, 7), (DEC, 28)),
2010: (DEC, 17),
2011: (DEC, 6),
2012: (NOV, 25),
2013: (NOV, 14),
2014: (NOV, 4),
2015: (OCT, 24),
2016: (OCT, 12),
2017: (OCT, 1),
2018: (SEP, 21),
2019: (SEP, 10),
2020: (AUG, 30),
2021: (AUG, 20),
2022: (AUG, 9),
2023: (JUL, 29),
2024: (JUL, 17),
2025: (JUL, 6),
}

EID_AL_ADHA_DATES_CONFIRMED_YEARS = (2001, 2025)
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
2003: (FEB, 12),
2004: (FEB, 2),
2005: (JAN, 21),
2006: ((JAN, 11), (DEC, 31)),
2008: (DEC, 9),
2009: (NOV, 28),
2010: (NOV, 17),
2011: (NOV, 7),
2012: (OCT, 27),
2013: (OCT, 16),
2007: (DEC, 20),
2014: (OCT, 6),
2015: (SEP, 25),
2016: (SEP, 13),
2017: (SEP, 2),
2018: (AUG, 22),
2019: (AUG, 12),
2020: (AUG, 1),
2021: (JUL, 21),
2022: (JUL, 10),
2023: (JUN, 29),
2024: (JUN, 17),
2025: (JUN, 7),
}

EID_AL_FITR_DATES_CONFIRMED_YEARS = (2001, 2025)
EID_AL_FITR_DATES = {
2001: (DEC, 17),
2002: (DEC, 6),
2003: (NOV, 26),
2006: (OCT, 24),
2008: (OCT, 2),
2009: (SEP, 21),
2011: (AUG, 31),
2012: (AUG, 20),
2014: (JUL, 29),
2015: (JUL, 18),
2016: (JUL, 7),
2017: (JUN, 26),
2018: (JUN, 16),
2019: (JUN, 5),
2020: (MAY, 25),
2021: (MAY, 14),
2022: (MAY, 3),
2023: (APR, 22),
2024: (APR, 11),
2025: (MAR, 31),
2004: (NOV, 14),
2005: (NOV, 3),
2007: (OCT, 13),
2010: (SEP, 10),
2013: (AUG, 8),
}

MAWLID_DATES_CONFIRMED_YEARS = (2001, 2025)
MAWLID_DATES = {
2001: (JUN, 5),
2002: (MAY, 25),
2003: (MAY, 15),
2004: (MAY, 3),
2005: (APR, 22),
2006: (APR, 11),
2007: (APR, 1),
2008: (MAR, 21),
2010: (FEB, 27),
2011: (FEB, 16),
2012: (FEB, 5),
2013: (JAN, 25),
2014: (JAN, 14),
2009: (MAR, 9),
2015: ((JAN, 4), (DEC, 25)),
2016: (DEC, 13),
2017: (DEC, 2),
2018: (NOV, 21),
2019: (NOV, 10),
2020: (OCT, 30),
2021: (OCT, 19),
2022: (OCT, 9),
2023: (SEP, 28),
2024: (SEP, 16),
2025: (SEP, 5),
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载