Holiday calendars
Module: Shoals.HolidayCal.
This module represents a named calendar as a list of holiday dates, ships
the 2025 New York and London tables, combines two calendars into a joint
calendar, and reports whether a date is a holiday or a business day. Dates
come from Std.Time.
The Calendar type
Section titled “The Calendar type”type Calendar = | Calendar { name: string, holidays: List[Date] }
def empty_calendar(name: string) -> Calendardef weekend_only_calendar() -> Calendardef nyc_calendar() -> Calendardef ldn_calendar() -> Calendardef joint_calendar(left: Calendar, right: Calendar) -> Calendarempty_calendar and weekend_only_calendar carry no holiday dates, so
under them only weekends are non-business. nyc_calendar and ldn_calendar
carry the 2025 New York and London bank holiday tables. joint_calendar
merges the holiday lists of two calendars, keeping the left calendar's name,
so a date that is a holiday in either is a holiday in the joint calendar.
Predicates
Section titled “Predicates”def is_holiday(cal: Calendar, d: Date) -> booldef is_business_day(cal: Calendar, d: Date) -> boolis_holiday reports whether a date is in the calendar's holiday list.
is_business_day reports whether a date is neither a weekend nor a holiday.
From tests/holidaycal.ch:
cal = nyc_calendar()ny = is_holiday(cal, date(cast(2025, int64), cast(1, int64), cast(1, int64))) // truewed = is_business_day(cal, date(cast(2025, int64), cast(8, int64), cast(13, int64))) // trueA joint New York and London calendar treats both US Independence Day and UK Boxing Day as holidays:
joint = joint_calendar(nyc_calendar(), ldn_calendar())july4 = is_holiday(joint, date(cast(2025, int64), cast(7, int64), cast(4, int64))) // trueboxing = is_holiday(joint, date(cast(2025, int64), cast(12, int64), cast(26, int64))) // true