Skip to main content

Module data_calendar

Module data_calendar 

Expand description

DataCalendar — the single data-backed Calendar implementation.

A jurisdiction calendar is a precomputed set of holiday dates plus a weekend mask. All rule logic (Easter, nth-weekday, observed-holiday shifting) lives in the offline generator; at runtime a business-day test is one bit probe into a day-number-indexed grid built once at construction (BusinessDayGrid), and a business-day count is an O(1) prefix-sum subtraction.

Dates outside the generated horizon carry no holiday data, so the calendar degrades to weekend-only behaviour past the horizon — no error path. The grid is built over the fixed generated horizon (2000–2198) widened to cover any explicitly supplied holiday outside it, so every listed holiday is always inside the grid and the out-of-grid fallback is exactly the weekend mask.

Structs§

BusinessDayGrid 🔒
Day-number-indexed business-day classification over a fixed date horizon: a bitset (one bit per day, set ⇔ business day) plus a per-word prefix sum making “business days in [0, i)” a lookup-and-popcount. Immutable after construction; ~4.6 KB of bits plus ~2.3 KB of prefix per century calendar.
DataCalendar
A Calendar backed by a precomputed business-day grid and a weekend mask.

Functions§

horizon_end 🔒
Last day of the generated holiday horizon (inclusive). pub(crate) for the same reason as horizon_start.
horizon_start 🔒
First day of the generated holiday horizon.
weekmask_open_days 🔒
Open (non-weekend) days by weekmask alone in the half-open date range [from, to) (from <= to), in O(1): whole weeks contribute the mask’s open count, the remainder walks at most six weekdays.