Skip to content

CalendaryInstance

CalendaryInstance class - the main instance

// Default usage
const cal = calendary();
// With typed metadata
interface LiturgicalMetadata { rank: string; vestmentColor: string; }
const cal = calendary<LiturgicalMetadata>();
const day = cal.getDay("2025-12-25");
day.events[0].metadata?.rank; // TypeScript knows this exists

TMetadata extends Record<string, unknown> = Record<string, unknown>

Custom metadata type for events

TCategory extends string = string

Category type for events

new CalendaryInstance<TMetadata, TCategory>(cfg?): CalendaryInstance<TMetadata, TCategory>

Record<string, unknown>

CalendaryInstance<TMetadata, TCategory>

$isCalendary: boolean = true

addGroup(config): this

GroupInput

this


clone(): CalendaryInstance<TMetadata, TCategory>

Clone this instance

CalendaryInstance<TMetadata, TCategory>


getDay(date): CalendarDay<TMetadata, TCategory>

Get a single calendar day

string | DateComponents

CalendarDay<TMetadata, TCategory>


getDays(options): CalendarDay<TMetadata, TCategory>[]

Get calendar days for a date range

GetDaysOptions

CalendarDay<TMetadata, TCategory>[]


getEvents(date): CalendarEvent<TMetadata, TCategory>[]

string

CalendarEvent<TMetadata, TCategory>[]


getEventsByGroup(groupId, from?, to?): CalendarEvent<TMetadata, TCategory>[]

string

string

string

CalendarEvent<TMetadata, TCategory>[]


getEventsInRange(from, to): CalendarEvent<TMetadata, TCategory>[]

string

string

CalendarEvent<TMetadata, TCategory>[]


getGroup(groupId): Group | undefined

string

Group | undefined


getGroups(): Group[]

Group[]


getUpcomingEvents(days): CalendarEvent<TMetadata, TCategory>[]

number

CalendarEvent<TMetadata, TCategory>[]


hasDayEnricher(name): boolean

Check if a day enricher is registered

string

boolean


hasPlugin(name): boolean

string

boolean


invalidateCache(): this

this


load(collection): this

Load a Collection — a portable bundle of events (a .cdy document is its JSON form). Pass an object or a JSON string. The declared plugins must already be registered (cal.use(...)); a clear error lists any that aren’t. Nothing is fetched or executed behind your back.

string | Collection

this


registerDayEnricher(enricher): this

Register a day enricher to add custom data to CalendarDay objects

DayEnricher

this


registerFormula(name, fn): this

string

FormulaFn

this


removeGroup(groupId): this

string

this


search(): SearchBuilder<TMetadata, TCategory>

Create a search builder for advanced event queries. Supports text search, metadata search, categories, and more.

SearchBuilder<TMetadata, TCategory>

// Search by text (case-insensitive)
cal.search().text('christmas').getEvents();
// Search by metadata
cal.search().metadata({ season: 'advent' }).getEvents();
// Combined search
cal.search()
.text('easter')
.categories(['liturgical'])
.range('2025-01-01', '2025-12-31')
.sortBy('date', 'asc')
.getEvents();

setGroupEnabled(groupId, enabled): this

string

boolean

this


toCollection(options?): Collection

Export events as a portable Collection — the inverse of load. Serializes the plain event configs plus a manifest of the plugins their event types need, so the result round-trips back through load(). Pass it to JSON.stringify for a .cdy document.

string

export a single group; omit to export every group’s events.

string

the collection name (also the default group id on re-load).

string

an informational version stamp.

Collection


use(plugin): this

Register a plugin (use/extend)

CalendaryPlugin

this