CalendarPattern

CalendarPattern :: # (opaque)

Validated Gregorian date selectors within anchored calendar periods. This is the candidate layer: it does not apply DTSTART truncation, COUNT, UNTIL, BYSETPOS, clock selectors, exclusions or zone interpretation. Week ordinals use the date's week-numbering year, which can differ from its civil year. Negative positions count back from that numbering year's end.

definition : CalendarPattern -> Spec

Read validated selector declarations without evaluating a period.

new : GregorianDate, Spec -> Try(CalendarPattern, [InvalidInterval, TooManySelectors, InvalidSelector(Str), InvalidCombination(Str), ..])

RFC date-selector domains and combinations; at most 4096 supplied values per selector. Duplicates have set meaning and do not duplicate candidates.

period : CalendarPattern, U64 -> Try({ start : GregorianDate, end : GregorianDate }, [OutOfRange, ..])

A whole frequency period, including days before the anchor in period zero. Exclusive end must fit the Gregorian provider. No clamping or clipping. Fixed work independent of index; intermediate arithmetic uses I128.

matches : CalendarPattern, U64, GregorianDate -> Try(Bool, [OutOfRange, ..])

Test one date against one period. Cost is O(s) supplied selector values, with bounded calendar arithmetic; no series scan or candidate lists. BYSETPOS must operate on completed full candidates, after this layer. Weekly defaults retain the anchor weekday; monthly defaults retain its month-day when neither BYDAY nor BYMONTHDAY expands the period. Yearly defaults retain month/day only in the absence of expanding date selectors (an explicit BYMONTH can select multiple copies of the anchor month-day). Standards adapters supply any additional format-specific defaults first.

Frequency : [Daily, Weekly, Monthly, Yearly]
Weekday : [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]
Spec : {
    frequency : Frequency,
    interval : I64,
    week_start : Weekday,
    by_month : List(U8),
    by_month_day : List(I8),
    by_year_day : List(I16),
    by_week_no : List(I8),
    by_day : List({ ordinal : I8, weekday : Weekday }),
}

Filter

CalendarPattern.Filter :: # (opaque)

Date restrictions without a frequency's expansion defaults. Subdaily periods use these same selector predicates after choosing their date.

new : Spec -> Try(Filter, [InvalidInterval, TooManySelectors, InvalidSelector(Str), InvalidCombination(Str), ..])
definition : Filter -> Spec

Shared predicate storage only: frequency/interval/week_start are placeholders, not a recurrence frequency or expansion defaults.