/** * recurrence - a small, pure repeat-pattern engine for SvCalendar (and anywhere * you need "does this date match a recurring rule"). Supports daily / weekly / * monthly / yearly frequencies with an interval, weekday lists, a day-of-month * (incl. negative = counted from the end), a positional weekday-of-month * (`weekOfMonth`, e.g. the 2nd Tuesday / last Friday), an anchor (`from`) and two * end conditions - an inclusive `until` date or a `count` of occurrences. * Framework-free + pure so it is unit-tested directly - no RRULE dependency. * * ```ts * const standup = { freq: 'weekly', weekdays: [1, 2, 3, 4, 5] } // every weekday * const payday = { freq: 'monthly', day: -1 } // the last day * const sprint = { freq: 'weekly', weekdays: [1], interval: 2, from: '2026-01-05' } // every other Monday * const board = { freq: 'monthly', weekdays: [2], weekOfMonth: 1 } // 1st Tuesday * const review = { freq: 'weekly', weekdays: [5], count: 8 } // 8 Fridays then stop * matchesRecurrence(someDate, [standup, payday, sprint, board, review]) * ``` */ import { type DateLike } from './datetime/date-core'; export type RecurrenceFreq = 'daily' | 'weekly' | 'monthly' | 'yearly'; export type RecurrenceRule = { freq: RecurrenceFreq; /** Repeat every N units of `freq`. Default 1. Uses `from` as the phase anchor. */ interval?: number; /** weekly: the weekdays it lands on (0 = Sunday .. 6 = Saturday). Also the * weekday for a positional monthly / yearly rule (with `weekOfMonth`). */ weekdays?: ReadonlyArray; /** monthly / yearly: day of the month. 1..31, or negative to count from the * end (-1 = the last day, -2 = the second to last). */ day?: number; /** monthly / yearly: the ordinal week the `weekdays` land on within the month - * 1..4 (first..fourth) or -1 (last). E.g. `{ weekdays:[2], weekOfMonth:-1 }` * = the last Tuesday. Takes precedence over `day` when both are set. */ weekOfMonth?: number; /** yearly: the month (0 = January .. 11 = December). */ month?: number; /** First occurrence + the phase for `interval`. */ from?: DateLike; /** Last day the pattern applies (inclusive). */ until?: DateLike | null; /** End after this many occurrences (counted from `from`). Requires `from`. */ count?: number; }; /** Whether `date` matches any of the given recurrence rule(s). */ export declare function matchesRecurrence(date: Date, rules: RecurrenceRule | ReadonlyArray | null | undefined): boolean; /** Every matching date within [start, end] (inclusive), in order - for building * event lists / agendas. Bounded to avoid runaway loops. */ export declare function expandRecurrence(rules: RecurrenceRule | ReadonlyArray | null | undefined, start: Date, end: Date): Date[]; /** Optional English strings a caller can override for i18n. */ export type RecurrenceLabels = { weekdays?: ReadonlyArray; months?: ReadonlyArray; ordinals?: Record; never?: string; }; /** * A short, human-readable summary of a recurrence rule (or list) - e.g. * "Weekly on weekdays", "Every 2 weeks on Fri, 8 times", "Monthly on the last * Friday", "Yearly on the fourth Thursday of Nov". Returns the `never` label * (default "") for an empty / falsy rule, so it drops cleanly into a table cell. */ export declare function describeRecurrence(rules: RecurrenceRule | ReadonlyArray | null | undefined, labels?: RecurrenceLabels): string;