Skip to content

Commit

Permalink
XMOS: updated holidays from 2020 (#352)
Browse files Browse the repository at this point in the history
Also, adds exceptions for 2021 and observance functions for certain holidays.
  • Loading branch information
iMikeBug authored Feb 13, 2024
1 parent 8d06f54 commit da62a20
Show file tree
Hide file tree
Showing 3 changed files with 1,123 additions and 9 deletions.
42 changes: 35 additions & 7 deletions exchange_calendars/exchange_calendar_xmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ def new_years_eve_observance(dt: datetime.datetime) -> datetime.datetime | None:
return None if dt.year in [2008, 2009] else weekend_to_monday(dt)


def new_years_day_observance(dt: datetime.datetime) -> datetime.datetime | None:
# New Year's Day did not follow the next-non-holiday rule these years.
return None if dt.year in [2022] else weekend_to_monday(dt)


def new_years_holiday_observance(dt: datetime.datetime) -> datetime.datetime | None:
# New Year's Holiday did not follow the next-non-holiday rule in 2016.
return None if dt.year == 2016 else weekend_to_monday(dt)
# New Year's Holiday did not follow the next-non-holiday rule these years.
return None if dt.year in [2016, 2021, 2022] else weekend_to_monday(dt)


def orthodox_christmas_observance(dt: datetime.datetime) -> datetime.datetime | None:
# Orthodox Christmas did not follow the next-non-holiday rule these years.
return None if dt.year in [2012, 2017] else weekend_to_monday(dt)
return None if dt.year in [2012, 2017, 2023, 2024] else weekend_to_monday(dt)


def defender_of_fatherland_observance(
Expand All @@ -48,7 +53,22 @@ def defender_of_fatherland_observance(
return None if dt.year in [2013, 2014, 2019] else weekend_to_monday(dt)


NewYearsDay = new_years_day(observance=weekend_to_monday)
def victory_day_observance(dt: datetime.datetime) -> datetime.datetime | None:
# Victory Day did not follow the next-non-holiday rule these years.
return None if dt.year in [2021] else weekend_to_monday(dt)


def day_of_russia_observance(dt: datetime.datetime) -> datetime.datetime | None:
# Day of Russia did not follow the next-non-holiday rule these years.
return None if dt.year in [2021] else weekend_to_monday(dt)


def unity_day_observance(dt: datetime.datetime) -> datetime.datetime | None:
# Unity Day did not follow the next-non-holiday rule these years.
return None if dt.year in [2023] else weekend_to_monday(dt)


NewYearsDay = new_years_day(observance=new_years_day_observance)
NewYearsHoliday = Holiday(
"New Year's Holiday",
month=1,
Expand Down Expand Up @@ -111,21 +131,21 @@ def defender_of_fatherland_observance(
"Victory Day",
month=5,
day=9,
observance=weekend_to_monday,
observance=victory_day_observance,
)

DayOfRussia = Holiday(
"Day of Russia",
month=6,
day=12,
observance=weekend_to_monday,
observance=day_of_russia_observance,
)

UnityDay = Holiday(
"Unity Day",
month=11,
day=4,
observance=weekend_to_monday,
observance=unity_day_observance,
start_date="2005",
)

Expand Down Expand Up @@ -170,6 +190,7 @@ def defender_of_fatherland_observance(
"2005-03-07",
"2011-03-07",
"2012-03-09",
"2022-03-07",
]

labour_day_extensions = [
Expand All @@ -182,13 +203,17 @@ def defender_of_fatherland_observance(
"2012-04-30",
"2015-05-04",
"2016-05-03",
# LabourDay Holiday extended to Tuesday.
"2022-05-03",
]

victory_day_extensions = [
"2002-05-10",
"2005-05-10",
"2006-05-08",
"2017-05-08",
# Victory Day Holiday extended to Tuesday.
"2022-05-10",
]

day_of_russia_extensions = [
Expand Down Expand Up @@ -218,6 +243,9 @@ def defender_of_fatherland_observance(
# Trading Suspended.
"2008-10-10",
"2008-10-27",
# Non-Working Days.
"2020-06-24",
"2020-07-01",
]


Expand Down
Loading

0 comments on commit da62a20

Please sign in to comment.