forceCalendar/Docs
API Reference

RecurrenceEngine

API reference for the RecurrenceEngine static class.

import { RecurrenceEngine } from '@forcecalendar/core';

All methods are static.

Methods

MethodSignatureReturns
expandEvent(event, rangeStart: Date, rangeEnd: Date, maxOccurrences?: number, tz?: string) => Event[]Occurrence array
parseRule(ruleString: string) => objectParsed rule
getNextOccurrence(currentDate: Date, rule: object, tz?: string) => DateNext date
matchesByDay(date: Date, byDay: string[]) => booleanDay match
setToWeekdayOfMonth(date: Date, weekday: string, position: number) => DateAdjusted date
isException(date: Date, rule: object, eventId?: string) => booleanIs exception
addExceptions(rule: object, exceptions: Date[], options?: object) => void—
getDescription(rule: object) => stringHuman-readable

expandEvent Parameters

ParamTypeDefaultDescription
eventEventrequiredThe recurring event
rangeStartDaterequiredStart of expansion range
rangeEndDaterequiredEnd of expansion range
maxOccurrencesnumber365Safety limit
timezonestringundefinedIANA timezone

Occurrence Object Shape

Each expanded occurrence has:

PropertyTypeDescription
...event—All properties from original event
startDateAdjusted start for this occurrence
endDateAdjusted end for this occurrence
isOccurrencebooleanAlways true
originalEventIdstringID of the recurring event
occurrenceDateDateDate of this occurrence

Lazy series queries

Static methodResult
iterateOccurrences(event, options?)Single-use generator
nextOccurrence(event, after?, options?)Next occurrence or null
takeOccurrences(event, count, options?)Bounded occurrence array

Options include after, before, inclusive and timezone. Bounds are exclusive unless inclusive: true. Use nextOccurrence for COUNT/UNTIL/exception-aware queries; the older getNextOccurrence only steps a rule. See lazy occurrence semantics.