API Reference
Wiki updated as of 1.4.10 (Nov 2026)The public API is at CALENDARIA.api. Use it from macros or from another module.
Dates passed to and returned from the API use the display year and 1-indexed month and day, unless a method says otherwise.
Time management
Section titled “Time management”advanceTime(), setDateTime(), jumpToDate(), and advanceTimeToPreset() require the changeDateTime permission. A non-GM call is sent to the GM and resolves with the world time from before the change. API calls do not play the cinematic overlay unless you pass cinematic: true.
getCurrentDateTime()
Section titled “getCurrentDateTime()”Get the current world date and time.
const now = CALENDARIA.api.getCurrentDateTime();// Returns: { year, month, day, hour, minute, second, ... }Returns: object - Time components with the display year and 1-indexed month and day.
advanceTime(delta, options)
Section titled “advanceTime(delta, options)”Advance time by a number of seconds or by a { day, hour, minute, second } object, converted using the active calendar’s day length.
await CALENDARIA.api.advanceTime({ hour: 8 });await CALENDARIA.api.advanceTime(3600);await CALENDARIA.api.advanceTime({ day: 1, hour: 6 }, { cinematic: true });await CALENDARIA.api.advanceTime({ hour: 8 }, { smooth: true });| Parameter | Type | Description |
|---|---|---|
delta | number|object | Seconds or time delta object (e.g., {day: 1, hour: 2}) |
options.cinematic | boolean | Trigger the cinematic overlay (default: false) |
options.smooth | boolean | Animate the advance in steps (default: false) |
options.duration | number | Smooth advance length in milliseconds (default: 3000) |
options.fps | number | Smooth advance steps per second (default: 20) |
A smooth advance pauses a running clock until it finishes. A second call during a smooth advance is ignored.
Returns: Promise<number> - New world time in seconds.
setDateTime(components, options)
Section titled “setDateTime(components, options)”Set time to specific values.
await CALENDARIA.api.setDateTime({ year: 1492, month: 5, day: 15, hour: 10, minute: 30 });await CALENDARIA.api.setDateTime({ year: 1492, month: 5, day: 15 }, { cinematic: true });| Parameter | Type | Description |
|---|---|---|
components | object | Time components to set |
options.cinematic | boolean | Trigger the cinematic overlay (default: false) |
Returns: Promise<number> - New world time in seconds.
jumpToDate(date, options)
Section titled “jumpToDate(date, options)”Jump to a date and keep the current time of day.
await CALENDARIA.api.jumpToDate({ year: 1492, month: 5, day: 1 });await CALENDARIA.api.jumpToDate({ year: 1492, month: 5, day: 1 }, { cinematic: true });| Parameter | Type | Description |
|---|---|---|
date | object | Target date { year, month, day } |
options.cinematic | boolean | Trigger the cinematic overlay (default: false) |
Returns: Promise<void>
advanceTimeToPreset(preset, options)
Section titled “advanceTimeToPreset(preset, options)”Advance time to the next occurrence of a preset time.
await CALENDARIA.api.advanceTimeToPreset('sunrise');await CALENDARIA.api.advanceTimeToPreset('midnight', { cinematic: true });| Parameter | Type | Description |
|---|---|---|
preset | string | 'sunrise', 'midday', 'noon', 'sunset', or 'midnight' |
options.cinematic | boolean | Trigger the cinematic overlay (default: false) |
Returns: Promise<number> - New world time in seconds.
Clock control
Section titled “Clock control”CALENDARIA.api.isClockRunning(); // true while the real-time clock runsCALENDARIA.api.startClock();CALENDARIA.api.stopClock();CALENDARIA.api.toggleClock();CALENDARIA.api.getClockSpeed(); // game seconds per real secondstartClock() requires the changeDateTime permission. It does nothing when the clock is locked, when the real-time speed is 0, when combat blocks the clock, or when the game is paused with clock-pause sync enabled.
Calendar access
Section titled “Calendar access”Calendar collections are keyed objects, not arrays. Use the array getters on a calendar for ordered iteration.
| Getter | Collection |
|---|---|
monthsArray | months.values |
weekdaysArray | days.values |
seasonsArray | seasons.values |
moonsArray | moons |
cyclesArray | cycles |
erasArray | eras |
festivalsArray | festivals |
canonicalHoursArray | canonicalHours |
namedWeeksArray | weeks.names |
namedDaysArray | days.names |
weatherZonesArray | weather.zones |
The daysInWeek getter returns weekdaysArray.length || 7.
const calendar = CALENDARIA.api.getActiveCalendar();const months = calendar.monthsArray;Lookup methods
Section titled “Lookup methods”| Method | Returns |
|---|---|
getActiveCalendar() | The active calendar, or null |
getCalendar(id) | The calendar with that ID, or null |
getAllCalendars() | Map of calendar ID to calendar |
getAllCalendarMetadata() | Array of calendar metadata |
isBundledCalendar(id) | true when the calendar ships with Calendaria |
addCalendar(id, definition)
Section titled “addCalendar(id, definition)”Register a new calendar.
await CALENDARIA.api.addCalendar('myCalendar', calendarDefinition);Returns: Promise<object|null> - The registered calendar. An ID that is already registered returns the existing calendar. Returns null on failure.
switchCalendar(id) / setActiveCalendar(id, options)
Section titled “switchCalendar(id) / setActiveCalendar(id, options)”Switch the active calendar. Both require the changeActiveCalendar permission.
await CALENDARIA.api.switchCalendar('greyhawk');await CALENDARIA.api.setActiveCalendar('greyhawk', { useCalendarDefaults: true });| Parameter | Type | Description |
|---|---|---|
id | string | Calendar ID to activate |
options.useCalendarDefaults | boolean | setActiveCalendar() only. Resets the display format settings to the new calendar’s own formats (default: false) |
useCalendarDefaults is ignored for a non-GM caller.
Returns: Promise<boolean> - True if switched. A non-GM call resolves true once the request is sent to the GM.
convertDate(date, fromCalendarId, toCalendarId)
Section titled “convertDate(date, fromCalendarId, toCalendarId)”Convert a date from one calendar to another through shared world time.
const converted = CALENDARIA.api.convertDate({ year: 1492, month: 5, day: 15 }, 'harptos', 'greyhawk');// Returns: { year, month, day, hour, minute, second }date accepts optional hour and minute fields.
Returns: object|null - Converted date, or null when either calendar is missing.
getEquivalentDates(date, calendarId)
Section titled “getEquivalentDates(date, calendarId)”Get the same moment on every other registered calendar. calendarId is the source calendar and defaults to the active one. The input date accepts optional hour, minute, and second, which default to midnight.
const equivalents = CALENDARIA.api.getEquivalentDates({ year: 1492, month: 5, day: 15, hour: 14 });Returns: Array<{calendarId, calendarName, date, formatted}> - formatted uses each target calendar’s cross-calendar date format.
getCurrentDateOn(calendarId)
Section titled “getCurrentDateOn(calendarId)”Get the current world time as a date on another calendar.
const date = CALENDARIA.api.getCurrentDateOn('greyhawk');// Returns: { year, month, day, hour, minute }Returns: object|null - Date on the target calendar, or null.
showSecondaryCalendar(calendarId)
Section titled “showSecondaryCalendar(calendarId)”Open a Secondary Calendar viewer for a non-active calendar.
CALENDARIA.api.showSecondaryCalendar('greyhawk');Returns: SecondaryCalendar - The viewer instance.
Moon phases
Section titled “Moon phases”getMoonPhase(moonIndex) / getAllMoonPhases()
Section titled “getMoonPhase(moonIndex) / getAllMoonPhases()”Get the current phase of one moon, or of every moon on the active calendar.
const phase = CALENDARIA.api.getMoonPhase(0);// Returns: { name, icon, position, dayInCycle, ... }const moons = CALENDARIA.api.getAllMoonPhases();A moon hidden from players returns null for a non-GM caller.
Returns: getMoonPhase() returns object|null. getAllMoonPhases() returns one entry per moon in stored order, each with moonIndex and moonName added. An entry is null when the moon has no phases or is hidden from a non-GM caller.
Moon definition methods
Section titled “Moon definition methods”These take a moon definition object from calendar.moonsArray, not an index. Dates default to the current date.
const calendar = CALENDARIA.api.getActiveCalendar();const moon = calendar.moonsArray[0];const position = CALENDARIA.api.getMoonPhasePosition(moon);const next = CALENDARIA.api.getNextFullMoon(moon, null, { maxDays: 500 });const convergence = CALENDARIA.api.getNextConvergence(calendar.moonsArray);| Method | Returns |
|---|---|
getMoonPhasePosition(moon, date) | Phase position from 0 (new moon) to 1 |
isMoonFull(moon, date) | true when the moon is in its full phase |
getNextFullMoon(moon, startDate, options) | Date of the next full moon, or null |
getNextConvergence(moons, startDate, options) | Next date when every given moon is full, or null |
getConvergencesInRange(moons, startDate, endDate) | Array of dates when every given moon is full |
options.maxDays caps the search for the getNext methods.
Eclipses
Section titled “Eclipses”The eclipse methods take a moon definition or an index into moonsArray. Dates default to the current date.
const eclipse = CALENDARIA.api.getEclipse(0);// Returns: { type: 'totalSolar', proximity: 0.95 } or { type: null }const next = CALENDARIA.api.getNextEclipse(0);// Returns: { date: { year, month, day }, type: 'totalLunar', proximity: 1.0 }| Method | Returns |
|---|---|
getEclipse(moonOrIndex, date) | { type, proximity }, or { type: null } |
isEclipse(date) | true when any moon has an eclipse on that date |
getNextEclipse(moonOrIndex, startDate, options) | { date, type, proximity }, or null |
getEclipsesInRange(moonOrIndex, startDate, endDate) | Array of { date, type, proximity } |
type is 'totalSolar', 'partialSolar', 'annularSolar', 'totalLunar', 'partialLunar', or 'penumbralLunar'. options.maxDays caps the getNextEclipse() search.
Seasons and sun
Section titled “Seasons and sun”getCurrentSeason(timestamp)
Section titled “getCurrentSeason(timestamp)”Get the season containing a world time in seconds, defaulting to now.
const season = CALENDARIA.api.getCurrentSeason();Returns: object|null - The calendar’s season without zone aliases applied.
getAliasedSeason({ scene, zoneId, time })
Section titled “getAliasedSeason({ scene, zoneId, time })”Get the current season with the climate zone’s season alias applied. This is a WeatherManager method, not part of CALENDARIA.api.
const season = CALENDARIA.managers.WeatherManager.getAliasedSeason({ zoneId: 'desert' });| Parameter | Type | Description |
|---|---|---|
scene | Scene | Scene used to resolve the zone (defaults to the active scene) |
zoneId | string | Explicit zone ID |
time | number | World time in seconds (defaults to the current world time) |
Returns: object|null - The season with the alias’s name, abbreviation, icon, and color applied, or null when no calendar is active.
getCycleValues()
Section titled “getCycleValues()”Get the current entry of every cycle on the active calendar.
const cycles = CALENDARIA.api.getCycleValues();// Returns: { text, values: [{ cycleName, entryName, index }] }Returns: object|null
Sun and daylight
Section titled “Sun and daylight”Each method takes an optional climate zone object and defaults to the active scene’s zone.
const sunrise = CALENDARIA.api.getSunrise(); // 6.5 means 6:30const daytime = CALENDARIA.api.isDaytime(myZone);| Method | Returns |
|---|---|
getSunrise(zone) | Today’s sunrise in hours, or null |
getSunset(zone) | Today’s sunset in hours, or null |
getDaylightHours(zone) | Hours of daylight today, or null |
getProgressDay(zone) | Progress from sunrise (0) to sunset (1), or null |
getProgressNight(zone) | Progress from sunset (0) to sunrise (1), or null |
isDaytime(zone) | true between sunrise and sunset |
isNighttime(zone) | true before sunrise or after sunset |
A zone with both sunriseOverride and sunsetOverride set uses those hours all year, provided sunrise comes before sunset and both fall within the day.
Time until
Section titled “Time until”Each method returns { hours, minutes, seconds }. All but getTimeUntilTarget() return null when no calendar is active.
const untilNoon = CALENDARIA.api.getTimeUntilTarget(12);const untilDawn = CALENDARIA.api.getTimeUntilSunrise();| Method | Counts down to |
|---|---|
getTimeUntilTarget(targetHour) | The next time the clock reaches an hour |
getTimeUntilSunrise() | The next sunrise |
getTimeUntilSunset() | The next sunset |
getTimeUntilMidnight() | Midnight |
getTimeUntilMidday() | Midday |
Weekdays and rest days
Section titled “Weekdays and rest days”const weekday = CALENDARIA.api.getCurrentWeekday();// Returns: { index, name, abbreviation, isRestDay }const isRest = CALENDARIA.api.isRestDay();Named weeks and named days are read from the active calendar instance, not from CALENDARIA.api:
const calendar = CALENDARIA.managers.CalendarManager.getActiveCalendar();const week = calendar?.getCurrentWeek();// Returns: { weekName, weekAbbr, weekNumber, index }const day = calendar?.getCurrentDayName();// Returns: { dayName, dayAbbr, dayNumber, index }Both return null when the calendar defines no named weeks or days, or when no entry matches the date. Pass a world time to resolve a different date.
Festivals
Section titled “Festivals”const festival = CALENDARIA.api.getCurrentFestival(); // festival on today's date, or nullconst isFestival = CALENDARIA.api.isFestivalDay();const festivals = CALENDARIA.api.getFestivals('harptos'); // defaults to the active calendargetFestivals() returns the calendar’s festival note stubs.
createFestival(calendarId, festivalData)
Section titled “createFestival(calendarId, festivalData)”Create a festival note for a calendar. Requires the editCalendars permission.
await CALENDARIA.api.createFestival('harptos', { name: 'Midsummer', content: '<p>The feast of Midsummer.</p>', startDate: { year: 1492, month: 7, day: 1 }, color: '#f0a500', icon: 'fa-sun', duration: 1});| Parameter | Type | Description |
|---|---|---|
calendarId | string | Calendar ID (required) |
festivalData.name | string | Festival name (required) |
festivalData.startDate | object | Start date { year, month, day } (required) |
festivalData.content | string | Description (HTML) |
festivalData.color | string | Festival color (hex) |
festivalData.icon | string | Font Awesome icon name, such as 'fa-sun' |
festivalData.duration | number | Duration in days (default: 1) |
festivalData.conditionTree | object | Condition tree for recurrence |
festivalData.categories | string[] | Preset IDs |
Returns: Promise<object|null> - Created note page, or null on failure.
Formatting
Section titled “Formatting”formatDate(components, formatOrPreset)
Section titled “formatDate(components, formatOrPreset)”Format a date as a string. components defaults to the current time and takes a display year with 1-indexed month and day.
const formatted = CALENDARIA.api.formatDate(null, 'datetime12');const custom = CALENDARIA.api.formatDate({ year: 1492, month: 5, day: 15 }, 'DD MMMM YYYY');formatOrPreset is a preset name or a format string built from format tokens. It defaults to 'dateLong'.
| Category | Presets |
|---|---|
| Utility | 'off' |
| Approximate | 'approxDate', 'approxTime', 'approxDateTime' |
| Standard | 'dateShort', 'dateMedium', 'dateLong', 'dateFull' |
| Regional | 'dateUS', 'dateUSFull', 'dateISO', 'dateNumericUS', 'dateNumericEU' |
| Ordinal/Fantasy | 'ordinal', 'ordinalLong', 'ordinalEra', 'ordinalFull', 'seasonDate' |
| Year/Week | 'yearOnly', 'yearEra', 'weekHeader' |
| Time | 'time12', 'time12Sec', 'time24', 'time24Sec' |
| DateTime | 'datetimeShort12', 'datetimeShort24', 'datetime12', 'datetime24' |
| Stopwatch | 'stopwatchRealtimeFull', 'stopwatchRealtimeNoMs', 'stopwatchRealtimeMinSec', 'stopwatchRealtimeSecOnly', 'stopwatchGametimeFull', 'stopwatchGametimeMinSec', 'stopwatchGametimeSecOnly' |
Returns: string
Other formatting helpers
Section titled “Other formatting helpers”const relative = CALENDARIA.api.timeSince({ year: 1492, month: 5, day: 15 }); // "3 days ago"const tokens = CALENDARIA.api.getFormatTokens(); // [{ token, descriptionKey, type }, ...]const presets = CALENDARIA.api.getFormatPresets(); // preset name to format stringDate/time conversion
Section titled “Date/time conversion”timestampToDate(timestamp)
Section titled “timestampToDate(timestamp)”Convert a world time in seconds to date components.
const date = CALENDARIA.api.timestampToDate(86400);// Returns: { year, month, ordinal, monthName, intercalary, day, hour, minute }| Field | Description |
|---|---|
month | 1-based position in the month list, counting intercalary months |
ordinal | Traditional month number, which an intercalary month may share with a regular month |
monthName | Month name as stored on the calendar. It may be a localization key, so pass it through game.i18n.localize() |
intercalary | Whether the month is intercalary |
Returns: object|null
dateToTimestamp(date)
Section titled “dateToTimestamp(date)”Convert date components to a world time in seconds.
const timestamp = CALENDARIA.api.dateToTimestamp({ year: 1492, month: 5, day: 15, hour: 10 });const byOrdinal = CALENDARIA.api.dateToTimestamp({ year: 729, ordinal: 7, day: 1 });month takes priority over ordinal. When an ordinal is shared, the regular month wins over the intercalary one. hour, minute, and second default to 0.
Returns: number
chooseRandomDate(startDate, endDate)
Section titled “chooseRandomDate(startDate, endDate)”Pick a random date in a range. startDate defaults to today and endDate to one year after the start.
const randomDate = CALENDARIA.api.chooseRandomDate({ year: 1492, month: 1, day: 1 }, { year: 1492, month: 12, day: 31 });Returns: object - Date in the timestampToDate() format.
Core integration: game.time.calendar
Section titled “Core integration: game.time.calendar”game.time.calendar is a separate CalendariaCalendar instance built from the active calendar. Modules and systems that read dates through core’s API call it.
game.time.calendar.format();game.time.calendar.timeToComponents(game.time.worldTime);format(time, formatter, options) uses Calendaria’s format tokens for the default "timestamp" formatter. Other formatters use core’s logic.
timeToComponents() returns year, month, dayOfMonth, day, dayOfWeek, season, leapYear, hour, minute, and second. year is not adjusted for yearZero.
Date arithmetic
Section titled “Date arithmetic”Dates are { year, month, day, hour?, minute? } objects. The add methods accept negative amounts.
const later = CALENDARIA.api.addDays({ year: 1492, month: 5, day: 15 }, 10);const days = CALENDARIA.api.daysBetween({ year: 1492, month: 5, day: 1 }, { year: 1492, month: 5, day: 15 }); // 14| Method | Returns |
|---|---|
addDays(date, days) | New date |
addMonths(date, months) | New date |
addYears(date, years) | New date |
addHours(date, hours) | New date |
addMinutes(date, minutes) | New date |
addSeconds(date, seconds) | New date |
daysBetween(start, end) | Whole days, positive when end is later |
monthsBetween(start, end) | Months |
hoursBetween(start, end) | Hours, which can be fractional |
minutesBetween(start, end) | Minutes |
secondsBetween(start, end) | Seconds |
compareDates(date1, date2) | -1, 0, or 1, including hour and minute |
compareDays(date1, date2) | -1, 0, or 1, ignoring time |
isSameDay(date1, date2) | true when both fall on the same day |
dayOfWeek(date) | 0-based weekday index |
isValidDate(date) | true when the date exists on the active calendar |
Reading notes
Section titled “Reading notes”const notes = CALENDARIA.api.getAllNotes();const note = CALENDARIA.api.getNote('abc123');const page = CALENDARIA.api.getNoteDocument('abc123');getAllNotes() and getNote() return note stubs with id, name, and flagData. getNoteDocument() returns the full JournalEntryPage, or null.
createNote(options)
Section titled “createNote(options)”Create a calendar note. Requires the addNotes permission.
const note = await CALENDARIA.api.createNote({ name: 'Council Meeting', content: "<p>Meeting with the Lords' Alliance</p>", startDate: { year: 1492, month: 5, day: 15, hour: 14, minute: 0 }, endDate: { year: 1492, month: 5, day: 15, hour: 16, minute: 0 }, allDay: false, categories: ['meeting'], icon: 'fas fa-handshake', color: '#4a90e2', visibility: 'visible', openSheet: 'edit'});| Parameter | Type | Description |
|---|---|---|
options.name | string | Note title |
options.content | string | Note content (HTML). When omitted, the preset’s content template is used |
options.startDate | object | Start date { year, month, day, hour?, minute? } |
options.endDate | object | End date (optional) |
options.allDay | boolean | All-day event (default: true) |
options.conditionTree | object | Condition tree for recurrence (see below) |
options.categories | string[] | Preset IDs |
options.icon | string | Icon path or class |
options.color | string | Event color (hex) |
options.visibility | string | 'visible', 'hidden', or 'secret' (default: 'visible') |
options.displayStyle | string | 'icon', 'pip', or 'banner' (default: the preset’s display style) |
options.subjects | string[] | Document UUIDs the note is about |
options.reminderType | string | 'none', 'toast', 'chat', or 'dialog' |
options.reminderTargets | string | 'all', 'gm', 'author', 'specific', or 'viewers' |
options.reminderUsers | string[] | User IDs notified when reminderTargets is 'specific' |
options.reminderOffset | number | How far ahead of the note the reminder fires |
options.reminderUnit | string | Offset unit: 'hour', 'day', 'week', 'month', or 'year' |
options.openSheet | false|'edit'|'view' | Open the note sheet after creation in that mode (default: 'edit'). Pass false to skip |
Returns: Promise<object|null> - The created note page. A player without Foundry’s journal-creation permission gets null; the request goes to the GM, who creates the note.
Recurrence with conditionTree
Section titled “Recurrence with conditionTree”A conditionTree is a group of conditions tested against each date. This annual note matches 23 August every year:
await CALENDARIA.api.createNote({ name: "Aldric's Birthday", startDate: { year: 1492, month: 8, day: 23 }, conditionTree: { type: 'group', mode: 'and', children: [ { type: 'condition', field: 'month', op: '==', value: 8 }, { type: 'condition', field: 'day', op: '==', value: 23 } ] }});The root needs a type of 'group' or 'condition'. Without one, the tree is ignored and the note only appears on its startDate. Inside conditions, month and day are 1-indexed. Use createCondition() and createConditionGroup() to build trees.
updateNote(pageId, updates)
Section titled “updateNote(pageId, updates)”Update a note. Requires a GM or ownership of the note.
await CALENDARIA.api.updateNote('abc123', { name: 'Rescheduled Meeting', startDate: { year: 1492, month: 5, day: 16, hour: 14 }});updates accepts name, content, startDate, endDate, allDay, conditionTree, categories, icon, color, visibility, displayStyle, and subjects, in the same formats as createNote().
Returns: Promise<object|null> - Updated note page.
Other note methods
Section titled “Other note methods”await CALENDARIA.api.deleteNote('abc123');await CALENDARIA.api.deleteAllNotes();await CALENDARIA.api.setNoteVisibility('abc123', 'hidden');await CALENDARIA.api.setNoteDisplayStyle('abc123', 'banner');await CALENDARIA.api.openNote('abc123', { mode: 'edit' });| Method | Notes |
|---|---|
deleteNote(pageId) | Resolves true. Throws when the page does not exist |
deleteAllNotes() | Requires the deleteNotes permission. Resolves with the number deleted |
setNoteVisibility(pageId, value) | 'visible', 'hidden', or 'secret'. Resolves with the updated page, or null on failure |
setNoteDisplayStyle(pageId, style) | 'icon', 'pip', or 'banner'. Resolves with the updated page, or null on failure |
openNote(pageId, options) | Opens the note sheet. options.mode is 'view' (default) or 'edit' |
navigateToNote(pageId, options)
Section titled “navigateToNote(pageId, options)”Move a calendar to a note’s date and open the note sheet.
await CALENDARIA.api.navigateToNote('abc123', { context: 'bigcal' });| Parameter | Type | Description |
|---|---|---|
options.context | string | 'bigcal' or 'minical' opens that calendar if needed. When omitted, only an already-open calendar moves |
options.mode | string | 'view' (default) or 'edit' for the note sheet |
Returns: Promise<void>
navigateToDate(year, month, day)
Section titled “navigateToDate(year, month, day)”Move a calendar to a date. The target follows the Enricher Click Target setting, and the chosen calendar opens if it is closed. On auto, the MiniCal is used when it is open and the BigCal is not; otherwise the BigCal is used.
await CALENDARIA.api.navigateToDate(1492, 5, 15);Returns: Promise<void>
Note queries
Section titled “Note queries”const today = CALENDARIA.api.getNotesForDate(1492, 5, 15);const month = CALENDARIA.api.getNotesForMonth(1492, 5, { includeContent: true });const range = CALENDARIA.api.getNotesInRange({ year: 1492, month: 5, day: 1 }, { year: 1492, month: 5, day: 31 }, { includeOccurrences: true });All three return note stubs and accept these options:
| Option | Description |
|---|---|
includeContent | Include note HTML content (default: false) |
includeOccurrences | Add nextOccurrence to each stub, a date or null (default: false) |
maxOccurrences | getNotesInRange() only. Cap on occurrences counted per note (default: 100) |
With includeOccurrences, getNotesInRange() also adds occurrenceCount, the number of times the note falls inside the range.
searchNotes(searchTerm, options)
Section titled “searchNotes(searchTerm, options)”Search note names and content.
const results = CALENDARIA.api.searchNotes('dragon', { categories: ['quest'] });options.caseSensitive defaults to false. options.categories filters by preset ID.
Returns: object[] - Note stubs.
search(term, options)
Section titled “search(term, options)”Search notes by title, preset label, and content. Only notes the current user can see are returned.
const results = CALENDARIA.api.search('council', { limit: 10 });const meetings = CALENDARIA.api.search('preset:meeting');| Parameter | Type | Description |
|---|---|---|
term | string | Search term (minimum 2 characters) |
options.searchContent | boolean | Search note content (default: true) |
options.limit | number | Max results (default: 50) |
A term starting with preset: matches the rest against preset labels and returns every note carrying a matching preset.
Returns: object[] - Results, each with type: 'note'.
Note presets
Section titled “Note presets”const presets = CALENDARIA.api.getPresets();const meetings = CALENDARIA.api.getNotesByPreset('meeting');addPreset(options)
Section titled “addPreset(options)”Add a custom note preset. GM only.
const preset = await CALENDARIA.api.addPreset({ label: 'Session Log', color: '#51cf66', icon: 'fas fa-book-open', defaults: { allDay: true, displayStyle: 'icon', content: '<p><strong>Recap</strong></p><p></p>' }});| Parameter | Type | Description |
|---|---|---|
options.label | string | Display name (required) |
options.color | string | Hex color |
options.icon | string | Font Awesome icon class |
options.playerUsable | boolean | Allow non-GM users to apply the preset (default: true) |
options.sortOrder | number | Sort order (default: end of the list) |
options.defaults | object | Default values for notes created with this preset |
defaults accepts name, allDay, displayStyle, visibility, color, icon, reminderType, reminderTargets, reminderOffset, reminderUnit, hasDuration, duration, maxOccurrences, silent, showBookends, defaultOwnership, macro, owners, and content. content is the HTML template pre-filled into new notes.
Returns: Promise<object> - The created preset.
updatePreset(presetId, updates) / deletePreset(presetId)
Section titled “updatePreset(presetId, updates) / deletePreset(presetId)”Change or remove a note preset.
await CALENDARIA.api.updatePreset('session-log', { defaults: { content: '<p>Notes</p>' } });await CALENDARIA.api.deletePreset('session-log');updates accepts label, color, icon, playerUsable, sortOrder, and defaults. New defaults merge into the existing ones.
Returns: updatePreset() resolves with the updated preset, or null when the preset is not found. deletePreset() resolves true when deleted.
Condition engine
Section titled “Condition engine”createCondition(field, op, …values)
Section titled “createCondition(field, op, …values)”Build a condition for a condition tree.
const condition = CALENDARIA.api.createCondition('weekday', '==', 0);// Returns: { type: 'condition', field: 'weekday', op: '==', value: 0 }The first value is value. A second value becomes value2.
Fields: computed, cycle, date, dayOfYear, day, dayInCalendar, daysBeforeMonthEnd, eclipse, epoch, eraYear, era, event, intercalary, inverseWeekNumber, isAutumnEquinox, isEclipse, isLeapYear, isLongestDay, isLunarEclipse, isShortestDay, isSolarEclipse, isSpringEquinox, month, monthInCalendar, moonPhaseCountMonth, moonPhaseCountEpoch, moonPhaseCountYear, moonPhaseIndex, moonPhase, moonSubPhase, random, seasonDay, seasonPercent, season, totalWeek, weather, weekInMonth, weekInYear, weekNumberInMonth, weekday, weeksBeforeMonthEnd, weeksBeforeYearEnd, year
Operators: ==, !=, >, >=, <, <=, %, daysAgo, daysFromNow, withinLast, withinNext
Returns: object - { type: 'condition', field, op, value, value2? }
createConditionGroup(mode, children, options)
Section titled “createConditionGroup(mode, children, options)”Combine conditions and nested groups.
const group = CALENDARIA.api.createConditionGroup('and', [CALENDARIA.api.createCondition('weekday', '==', 0), CALENDARIA.api.createCondition('month', '==', 5)]);mode is 'and', 'or', 'nand', 'xor', or 'count'. options.threshold sets the required match count for 'count'.
Returns: object - { type: 'group', mode, children, threshold? }
evaluateNote(pageId, date, options)
Section titled “evaluateNote(pageId, date, options)”Check whether a note occurs on a date.
const matches = CALENDARIA.api.evaluateNote('abc123', { year: 1492, month: 5, day: 15 }, { silent: true });The call fires the calendaria.conditionEvaluated hook unless options.silent is true.
Returns: boolean
Recurrence
Section titled “Recurrence”const next = CALENDARIA.api.getNextOccurrences('abc123', 10);const inRange = CALENDARIA.api.getNoteOccurrencesInRange('abc123', { year: 1492, month: 1, day: 1 }, { year: 1493, month: 1, day: 1 });getNextOccurrences(pageId, count) returns the next count dates from today (default: 5). getNoteOccurrencesInRange(pageId, startDate, endDate, maxOccurrences) returns every date in the range, up to maxOccurrences (default: 100). Both return { year, month, day } objects.
Cinematic Time Skip
Section titled “Cinematic Time Skip”const payload = CALENDARIA.api.buildCinematicPayload(game.time.worldTime, game.time.worldTime + 604800);await CALENDARIA.api.playCinematic(payload);| Method | Description |
|---|---|
buildCinematicPayload(startTime, endTime) | Build a payload for a span of world time in seconds, without playing it |
playCinematic(payload) | Play the overlay on the calling client only. World time does not change. Resolves when it ends |
pauseCinematic() | Freeze the overlay in place |
resumeCinematic() | Continue from where it paused |
abortCinematic() | Stop the overlay |
isCinematicActive() | true while a cinematic is playing |
isCinematicPaused() | true while a playing cinematic is paused |
Pause, resume, and abort called by the primary GM also apply on every other client.
Fog of War
Section titled “Fog of War”const enabled = CALENDARIA.api.isFogEnabled();const revealed = CALENDARIA.api.isDateRevealed(1492, 6, 15);const ranges = CALENDARIA.api.getRevealedRanges();// [{ start: { year, month, day }, end: { year, month, day } }]await CALENDARIA.api.revealDateRange({ year: 1492, month: 1, day: 1 }, { year: 1492, month: 6, day: 15 });await CALENDARIA.api.clearRevealedRanges();The date methods take an optional calendar ID as their last argument and default to the active calendar. isDateRevealed() always returns true for a GM or when fog is disabled. revealDateRange() and clearRevealedRanges() are GM only. Overlapping and adjacent revealed ranges merge.
Date picker
Section titled “Date picker”showDatePicker(options)
Section titled “showDatePicker(options)”Show a date picker dialog.
const date = await CALENDARIA.api.showDatePicker({ showTime: true });// Returns: { year, month, day, hour, minute } or null if cancelled| Parameter | Type | Description |
|---|---|---|
options.date | object | Initial date (defaults to today) |
options.showTime | boolean | Show time inputs (default: false) |
options.title | string | Dialog title |
options.position | object | Dialog position { x, y } in pixels |
options.onSelect | Function | Callback fired with the selected date |
Returns: Promise<object|null> - Selected date, or null if cancelled.
Application controls
Section titled “Application controls”Each application has show, hide, and toggle methods.
CALENDARIA.api.showBigCal();CALENDARIA.api.hideMiniCal();CALENDARIA.api.toggleHUD();CALENDARIA.api.showTimeKeeper();CALENDARIA.api.showSunDial({ closeOnClickOutside: true });CALENDARIA.api.toggleStopwatch();CALENDARIA.api.showChronicle();CALENDARIA.api.showNoteViewer({ preset: 'meeting', search: 'dragon' });The show methods for the BigCal, MiniCal, HUD, TimeKeeper, Stopwatch, and Chronicle return the application, or null when the user lacks its view permission or its combat setting hides it. showHUD() also returns null for a non-GM when the scene hides the HUD from players. showSunDial() returns nothing.
showChronicle(options)
Section titled “showChronicle(options)”| Parameter | Type | Description |
|---|---|---|
options.startDate | object | Range start { year, month, dayOfMonth } with 0-indexed month and day |
options.endDate | object | Range end, in the same format |
options.lockedRange | boolean | Lock the view to startDate and endDate |
options.calendarId | string | Calendar whose entries drive the view |
options.categoryFilter | string[]|null | Preset IDs to show; null restores the saved filter |
options.subjectFilter | string[]|null | Subject document UUIDs to show; null clears the filter |
showNoteViewer(options)
Section titled “showNoteViewer(options)”options pre-filters the Note Viewer by date, preset ID, search term, or visibility.
Stopwatch controls
Section titled “Stopwatch controls”CALENDARIA.api.startStopwatch(); // show and startCALENDARIA.api.pauseStopwatch();CALENDARIA.api.resetStopwatch();openCalendarEditor(calendarId)
Section titled “openCalendarEditor(calendarId)”Open the Calendar Editor. Requires the editCalendars permission. Omit calendarId to start a new calendar.
await CALENDARIA.api.openCalendarEditor('custom');Returns: Promise<object|null> - The editor application.
Weather
Section titled “Weather”Weather writes require the changeWeather permission: setWeather(), setCustomWeather(), clearWeather(), generateWeather(), setActiveZone(), addWeatherPreset(), removeWeatherPreset(), and updateWeatherPreset(). Without it, nothing changes.
A non-GM with the permission has setWeather(), clearWeather(), and generateWeather() sent to the GM. setWeather() and generateWeather() then resolve with the weather from before the request. setCustomWeather() is GM only.
Zone IDs default to the active scene’s zone throughout this section.
getCurrentWeather(zoneId)
Section titled “getCurrentWeather(zoneId)”const weather = CALENDARIA.api.getCurrentWeather('desert');// Returns: { id, label, icon, color, temperature, wind, precipitation, severity, ... }Returns: object|null - Current weather with wind { speed, direction, forced }, precipitation { type, intensity }, and a severity from 0 to 10. With intraday weather enabled, periods holds each period’s weather and its own severity.
Severity helpers
Section titled “Severity helpers”const label = CALENDARIA.api.getWeatherSeverityLabel(weather.severity);const band = CALENDARIA.api.getWeatherSeverityLevel(7);// Returns: { id: 'severe', min: 6, label: 'CALENDARIA.Weather.Severity.Severe' }const bands = CALENDARIA.api.getWeatherSeverityLevels();getWeatherSeverityLabel() returns the localized band name, or an empty string for a missing value. getWeatherSeverityLevel() returns the band { id, min, label }, or null. getWeatherSeverityLevels() lists every band in ascending order.
setWeather(presetId, options)
Section titled “setWeather(presetId, options)”Set weather by preset ID.
await CALENDARIA.api.setWeather('thunderstorm', { temperature: 18 });await CALENDARIA.api.setWeather('rain', { period: 'morning' });await CALENDARIA.api.setWeather('cloudy', { wind: { speed: 2, direction: 'SW', forced: false }, precipitation: { type: null, intensity: 0 }});| Parameter | Type | Description |
|---|---|---|
presetId | string | Weather preset ID |
options.temperature | number | Temperature in Celsius |
options.wind | object | Wind { speed, direction, forced } in place of the preset’s |
options.precipitation | object | Precipitation { type, intensity } in place of the preset’s |
options.period | string | Intraday period to set: 'night', 'morning', 'afternoon', or 'evening' |
options.allPeriods | boolean | Set every intraday period |
options.zoneId | string | Zone to write to |
Wind: speed is an integer from 0 (calm) to 5 (extreme). direction is degrees (0 = N, 90 = E), a 16-point compass string such as 'NNE', or null. forced locks the wind against generator inertia.
Precipitation: type is null, 'drizzle', 'rain', 'snow', 'sleet', or 'hail'. intensity runs from 0 to 1.
Returns: Promise<object> - The weather that was set.
setCustomWeather(weatherData)
Section titled “setCustomWeather(weatherData)”Set weather that is not tied to a preset. GM only.
await CALENDARIA.api.setCustomWeather({ label: 'Magical Storm', icon: 'fas fa-bolt', color: '#9b59b6', description: 'Arcane lightning crackles overhead', temperature: 7});weatherData takes label, icon, color, description, temperature, wind, precipitation, zoneId, period, and allPeriods.
Returns: Promise<object> - The weather that was set.
clearWeather() / generateWeather(options)
Section titled “clearWeather() / generateWeather(options)”await CALENDARIA.api.clearWeather();await CALENDARIA.api.generateWeather({ zoneId: 'desert', season: 'Summer' });await CALENDARIA.api.generateWeather({ randomize: true });generateWeather() rolls new weather from the zone’s climate and the current season. options.season names the season whose zone overrides apply. options.randomize uses true randomness instead of date-seeded generation.
Returns: clearWeather() resolves with nothing. generateWeather() resolves with the generated weather.
Intraday periods
Section titled “Intraday periods”const period = CALENDARIA.api.getCurrentWeatherPeriod(); // 'night', 'morning', 'afternoon', or 'evening'const morning = CALENDARIA.api.getWeatherForPeriod('morning', 'desert');getWeatherForPeriod(periodName, zoneId) returns that period’s weather for today, or null when intraday weather is off.
getWeatherForecast(options)
Section titled “getWeatherForecast(options)”Get the forecast for upcoming days. Non-GM users need the viewWeatherForecast permission.
const forecast = CALENDARIA.api.getWeatherForecast({ zoneId: 'desert', days: 3 });// Returns: [{ year, month, dayOfMonth, preset, temperature, wind, precipitation, isVaried }, ...]| Parameter | Type | Description |
|---|---|---|
options.zoneId | string | Zone to forecast |
options.days | number | Number of days, capped at the Forecast Days setting |
options.accuracy | number | Accuracy from 0 to 100. GM callers only; defaults to 100 for a GM unless playerView is set |
options.start | object | Internal date { year, month, dayOfMonth } to start from (default: today) |
options.playerView | boolean | For a GM, return the forecast as players see it, with world forecast accuracy and no period breakdown |
Forecast entries use internal dates: year is not adjusted for yearZero, and month and dayOfMonth are 0-indexed. preset is the full preset object, not an ID. isVaried shows whether forecast accuracy changed the entry. Only a GM gets the periods breakdown.
Returns: object[]
Weather history
Section titled “Weather history”const entry = CALENDARIA.api.getWeatherForDate(1492, 7, 15, 'desert');const year = CALENDARIA.api.getWeatherHistory({ year: 1492, zoneId: 'desert' });getWeatherForDate(year, month, day, zoneId) returns the recorded weather for a date, or null.
getWeatherHistory(options) returns the raw nested history object when year is omitted. With year, and optionally month, it returns a date-sorted array of { year, month, dayOfMonth, ...entry } using internal dates.
clearWeatherHistory(options)
Section titled “clearWeatherHistory(options)”Delete recorded weather for the active calendar. GM only.
await CALENDARIA.api.clearWeatherHistory({ future: true });await CALENDARIA.api.clearWeatherHistory({ year: 1492, month: 7 });await CALENDARIA.api.clearWeatherHistory({ all: true, clearForecast: false });| Parameter | Type | Description |
|---|---|---|
options.all | boolean | Clear all history |
options.future | boolean | Clear entries after today |
options.year | number | Clear one year |
options.month | number | Clear one month of year |
options.clearForecast | boolean | Also clear the forecast plan (default: true) |
Keep clearForecast on to stop the forecast plan from refilling the cleared days.
Returns: Promise<number> - Number of entries removed.
Climate zones
Section titled “Climate zones”const zone = CALENDARIA.api.getActiveZone();const zones = CALENDARIA.api.getCalendarZones();await CALENDARIA.api.setActiveZone('desert');const templates = CALENDARIA.api.getClimateZoneTemplates();setActiveZone(zoneId) changes the calendar’s active zone, fires calendaria.weatherChange, and updates every client.
These WeatherManager methods handle per-scene zones:
const WeatherManager = CALENDARIA.managers.WeatherManager;await WeatherManager.setSceneZoneOverride(game.scenes.active, 'tropical'); // use a zoneawait WeatherManager.setSceneZoneOverride(game.scenes.active, null); // No Zoneawait WeatherManager.setSceneZoneOverride(game.scenes.active, undefined); // follow the calendarconst noZone = WeatherManager.isZoneDisabled(game.scenes.active);WeatherManager.resolveDisplayLabel(presetId, fallbackLabel, calendarId, zoneId) returns a preset’s display name. A zone alias from the Climate Editor wins, then a name override from the Weather Editor, then the localized fallback.
createClimateZone(zoneConfig)
Section titled “createClimateZone(zoneConfig)”Create a climate zone on the active calendar. GM only.
const zone = await CALENDARIA.api.createClimateZone({ name: 'Frozen Wastes', temperatures: { Winter: { min: -40, max: -10 }, Summer: { min: -20, max: 5 } }, windSpeedRange: { min: 2, max: 5 }, brightnessMultiplier: 0.8});| Parameter | Type | Description |
|---|---|---|
name | string | Zone name (required) |
id | string | Unique zone ID, generated from the name when omitted |
description | string | Zone description |
temperatures | object | Celsius ranges keyed by season name, such as { Winter: { min, max } } |
presets | Array|object | Weather preset configurations |
seasonOverrides | object | Per-season overrides |
windSpeedRange | object | Wind speed range { min, max } on the 0 to 5 scale |
windDirections | object | Wind direction weights by compass direction |
brightnessMultiplier | number | Scene darkness scaling |
environmentBase | object | Day lighting: hue, intensity, luminosity, saturation, shadows |
environmentDark | object | Night lighting, in the same format |
shortestDay | number | Shortest day length in hours |
longestDay | number | Longest day length in hours |
colorShift | object | Dawn, dusk, and night hues and transition duration |
When the calendar has no active zone, the new zone becomes active.
Returns: Promise<object|null> - The new zone, or null when the name is missing or the ID is taken.
Weather probabilities
Section titled “Weather probabilities”const data = CALENDARIA.api.getWeatherProbabilities({ zoneId: 'arctic', season: 'Summer' });CALENDARIA.api.openWeatherProbabilities({ season: 'Winter' });getWeatherProbabilities() returns { zone, season, entries, tempRange }. entries holds { id, label, icon, color, weight, percent } sorted by percent, highest first. tempRange is { min, max } in Celsius. openWeatherProbabilities() opens the same breakdown as a dialog.
Weather presets
Section titled “Weather presets”const presets = await CALENDARIA.api.getWeatherPresets();const storm = CALENDARIA.api.getPreset('thunderstorm');await CALENDARIA.api.addWeatherPreset({ id: 'acid-rain', label: 'Acid Rain', icon: 'fas fa-skull', color: '#2ecc71', tempMin: 10, tempMax: 25, precipitation: { type: 'rain', intensity: 0.6 }, fxPreset: 'acid-rain'});await CALENDARIA.api.updateWeatherPreset('acid-rain', { label: 'Caustic Rain' });await CALENDARIA.api.removeWeatherPreset('acid-rain');addWeatherPreset() takes id, label, icon, color, description, tempMin, tempMax (Celsius), wind, precipitation, inertiaWeight, hudEffect, fxPreset, and soundFx. It resolves null when the ID already belongs to a built-in or custom preset.
updateWeatherPreset() and removeWeatherPreset() work on custom presets only. They resolve null or false when no custom preset has that ID.
Temperature
Section titled “Temperature”const temp = CALENDARIA.api.getTemperature('desert'); // 22const display = CALENDARIA.api.formatTemperature(temp); // "72°F" or "22°C"getTemperature() returns Celsius, or null when no weather is set. formatTemperature() uses the world’s temperature unit.
Weather sound and FX
Section titled “Weather sound and FX”await CALENDARIA.api.playWeatherSound('sounds/rain-heavy.ogg', { volume: 0.4 });await CALENDARIA.api.stopWeatherSound({ fade: 500 });await CALENDARIA.api.playWeatherFX('snow', { density: 'heavy' });await CALENDARIA.api.stopWeatherFX();playWeatherSound() plays on the calling client only. The next weather change replaces sound and FX started here.
| Method | Notes |
|---|---|
playWeatherSound(src, options) | Plays any Foundry audio path. options takes volume (defaults to the Weather Sound Volume setting), fade in ms, loop (default: true), and context. Resolves false when weather sounds are off globally or for the scene |
stopWeatherSound(options) | Fades out the current sound. options.fade is in ms |
playWeatherFX(presetName, options) | Plays an FXMaster preset and stops any other. options takes density, speed, color, direction, topDown, and belowTokens. Requires FXMaster |
stopWeatherFX() | Stops all FXMaster weather effects. Requires FXMaster |
refreshEnvironment()
Section titled “refreshEnvironment()”Recompute scene lighting on every synced scene, including time-of-day hue, weather, climate zone, and moon light.
await CALENDARIA.api.refreshEnvironment();Multiplayer and permissions
Section titled “Multiplayer and permissions”CALENDARIA.api.isPrimaryGM();CALENDARIA.api.canModifyTime(); // same as canChangeDateTime()CALENDARIA.api.canManageNotes(); // same as canAddNotes()isPrimaryGM() is true on the GM client that handles time saves and sync. It follows the 3DS:ATLAS Primary GM setting and falls back to Foundry’s active GM.
CALENDARIA.permissions
Section titled “CALENDARIA.permissions”Permission checks live on CALENDARIA.permissions. See Permissions for each permission and its defaults. Every check returns true for a GM.
const canChange = CALENDARIA.permissions.hasPermission('changeDateTime');const blocked = CALENDARIA.permissions.getBlockedActiveUsers('viewBigCal');| Method | Returns |
|---|---|
hasPermission(key) | Whether the current user holds the permission |
canViewBigCal(), canViewChronicle(), canViewHUD(), canViewMiniCal(), canViewNotes(), canViewStopwatch(), canViewSunDial(), canViewTimeKeeper() | Whether the current user can see that application |
canAddNotes(), canDeleteNotes(), canChangeDateTime(), canChangeWeather(), canViewWeatherForecast(), canChangeActiveCalendar(), canEditCalendars() | Whether the current user holds that permission |
canViewMoons() | Whether moons show for the current user, from the Hide Moons From Players setting |
getUsersWithPermission(key) | Every user holding the permission |
getBlockedActiveUsers(key) | Connected non-GM users without the permission |
Permission keys: viewBigCal, viewChronicle, viewHUD, viewMiniCal, viewNotes, viewStopwatch, viewSunDial, viewTimeKeeper, addNotes, deleteNotes, changeDateTime, changeWeather, viewWeatherForecast, changeActiveCalendar, editCalendars
Widgets
Section titled “Widgets”See Widgets for widget configuration.
CALENDARIA.api.registerWidget('my-module', { id: 'my-button', type: 'button', insertAt: 'hud.buttons.right', icon: 'fas fa-star', label: 'My Button', onClick: () => console.log('Clicked!')});| Member | Description |
|---|---|
widgetPoints | Insertion points: BIGCAL_ACTIONS, HUD_BUTTONS_LEFT, HUD_BUTTONS_RIGHT, HUD_INDICATORS, HUD_TRAY, MINICAL_SIDEBAR |
replaceableElements | Built-in indicators a widget can replace: WEATHER_INDICATOR, SEASON_INDICATOR, ERA_INDICATOR, CYCLE_INDICATOR |
registerWidget(moduleId, config) | Register a widget |
getRegisteredWidgets(insertPoint) | Widgets registered at an insertion point |
getWidgetByReplacement(elementId) | The widget replacing a built-in element, or null |
refreshWidgets() | Re-render every widget |
Enum getters
Section titled “Enum getters”Read-only copies of the module’s constants.
| Getter | Values |
|---|---|
conditionFields | Every condition field |
conditionOperators | Every condition operator |
conditionGroupModes | and, or, nand, xor, count |
displayStyles | icon, pip, banner |
noteVisibility | visible, hidden, secret |
hooks | Every Calendaria hook name, such as DAY_CHANGE. See Hooks |
Hooks.on(CALENDARIA.api.hooks.DAY_CHANGE, (data) => console.log(data));