Skip to content

Commit

Permalink
[JE] simplify observance rules
Browse files Browse the repository at this point in the history
Co-authored-by: ~Jhellico <[email protected]>
  • Loading branch information
PPsyrius and KJhellico authored Jan 30, 2024
1 parent 1c178cb commit 98af6e5
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions holidays/countries/jersey.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import (
ObservedHolidayBase,
SAT_SUN_TO_NEXT_MON,
SAT_SUN_TO_NEXT_MON_TUE,
SUN_TO_NEXT_MON,
SUN_TO_NEXT_TUE,
SAT_SUN_TO_NEXT_WORKDAY,
SUN_TO_NEXT_WORKDAY,
)


Expand Down Expand Up @@ -53,14 +51,14 @@ def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
StaticHolidays.__init__(self, JerseyStaticHolidays)
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_MON)
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_WORKDAY)
ObservedHolidayBase.__init__(self, *args, **kwargs)

def _add_observed(self, dt: date, **kwargs) -> Tuple[bool, date]:
# Prior to 2004, in-lieu are only given for Sundays.
# https://www.jerseylaw.je/laws/enacted/Pages/RO-123-2004.aspx
kwargs.setdefault(
"rule", SUN_TO_NEXT_MON if dt < date(2004, OCT, 12) else self._observed_rule
"rule", SUN_TO_NEXT_WORKDAY if dt < date(2004, OCT, 12) else self._observed_rule
)
return super()._add_observed(dt, **kwargs)

Expand Down Expand Up @@ -133,12 +131,8 @@ def _populate_public_holidays(self) -> None:
# Boxing Day
boxing_day = self._add_christmas_day_two("Boxing Day")

if self._year >= 2004:
self._add_observed(christmas_day, rule=SAT_SUN_TO_NEXT_MON_TUE)
self._add_observed(boxing_day, rule=SAT_SUN_TO_NEXT_MON_TUE)
else:
self._add_observed(christmas_day, rule=SUN_TO_NEXT_TUE)
self._add_observed(boxing_day)
self._add_observed(christmas_day)
self._add_observed(boxing_day)

# Jersey exclusive holidays

Expand Down

0 comments on commit 98af6e5

Please sign in to comment.