CalendaryInstance
CalendaryInstance class - the main instance
Example
Section titled “Example”// Default usageconst cal = calendary();
// With typed metadatainterface LiturgicalMetadata { rank: string; vestmentColor: string; }const cal = calendary<LiturgicalMetadata>();const day = cal.getDay("2025-12-25");day.events[0].metadata?.rank; // TypeScript knows this existsType Parameters
Section titled “Type Parameters”TMetadata
Section titled “TMetadata”TMetadata extends Record<string, unknown> = Record<string, unknown>
Custom metadata type for events
TCategory
Section titled “TCategory”TCategory extends string = string
Category type for events
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CalendaryInstance<
TMetadata,TCategory>(cfg?):CalendaryInstance<TMetadata,TCategory>
Parameters
Section titled “Parameters”Record<string, unknown>
Returns
Section titled “Returns”CalendaryInstance<TMetadata, TCategory>
Properties
Section titled “Properties”$isCalendary
Section titled “$isCalendary”$isCalendary:
boolean=true
Methods
Section titled “Methods”addGroup()
Section titled “addGroup()”addGroup(
config):this
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”this
clone()
Section titled “clone()”clone():
CalendaryInstance<TMetadata,TCategory>
Clone this instance
Returns
Section titled “Returns”CalendaryInstance<TMetadata, TCategory>
getDay()
Section titled “getDay()”getDay(
date):CalendarDay<TMetadata,TCategory>
Get a single calendar day
Parameters
Section titled “Parameters”string | DateComponents
Returns
Section titled “Returns”CalendarDay<TMetadata, TCategory>
getDays()
Section titled “getDays()”getDays(
options):CalendarDay<TMetadata,TCategory>[]
Get calendar days for a date range
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”CalendarDay<TMetadata, TCategory>[]
getEvents()
Section titled “getEvents()”getEvents(
date):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
getEventsByGroup()
Section titled “getEventsByGroup()”getEventsByGroup(
groupId,from?,to?):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
string
string
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
getEventsInRange()
Section titled “getEventsInRange()”getEventsInRange(
from,to):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
getGroup()
Section titled “getGroup()”getGroup(
groupId):Group|undefined
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
Returns
Section titled “Returns”Group | undefined
getGroups()
Section titled “getGroups()”getGroups():
Group[]
Returns
Section titled “Returns”Group[]
getUpcomingEvents()
Section titled “getUpcomingEvents()”getUpcomingEvents(
days):CalendarEvent<TMetadata,TCategory>[]
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”CalendarEvent<TMetadata, TCategory>[]
hasDayEnricher()
Section titled “hasDayEnricher()”hasDayEnricher(
name):boolean
Check if a day enricher is registered
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
hasPlugin()
Section titled “hasPlugin()”hasPlugin(
name):boolean
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
invalidateCache()
Section titled “invalidateCache()”invalidateCache():
this
Returns
Section titled “Returns”this
load()
Section titled “load()”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.
Parameters
Section titled “Parameters”collection
Section titled “collection”string | Collection
Returns
Section titled “Returns”this
registerDayEnricher()
Section titled “registerDayEnricher()”registerDayEnricher(
enricher):this
Register a day enricher to add custom data to CalendarDay objects
Parameters
Section titled “Parameters”enricher
Section titled “enricher”Returns
Section titled “Returns”this
registerFormula()
Section titled “registerFormula()”registerFormula(
name,fn):this
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
removeGroup()
Section titled “removeGroup()”removeGroup(
groupId):this
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
Returns
Section titled “Returns”this
search()
Section titled “search()”search():
SearchBuilder<TMetadata,TCategory>
Create a search builder for advanced event queries. Supports text search, metadata search, categories, and more.
Returns
Section titled “Returns”SearchBuilder<TMetadata, TCategory>
Example
Section titled “Example”// Search by text (case-insensitive)cal.search().text('christmas').getEvents();
// Search by metadatacal.search().metadata({ season: 'advent' }).getEvents();
// Combined searchcal.search() .text('easter') .categories(['liturgical']) .range('2025-01-01', '2025-12-31') .sortBy('date', 'asc') .getEvents();setGroupEnabled()
Section titled “setGroupEnabled()”setGroupEnabled(
groupId,enabled):this
Parameters
Section titled “Parameters”groupId
Section titled “groupId”string
enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”this
toCollection()
Section titled “toCollection()”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.
Parameters
Section titled “Parameters”options?
Section titled “options?”group?
Section titled “group?”string
export a single group; omit to export every group’s events.
string
the collection name (also the default group id on re-load).
version?
Section titled “version?”string
an informational version stamp.
Returns
Section titled “Returns”use(
plugin):this
Register a plugin (use/extend)
Parameters
Section titled “Parameters”plugin
Section titled “plugin”Returns
Section titled “Returns”this