Skip to content
3 Death Saves

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.


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.

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.


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 });
ParameterTypeDescription
deltanumber|objectSeconds or time delta object (e.g., {day: 1, hour: 2})
options.cinematicbooleanTrigger the cinematic overlay (default: false)
options.smoothbooleanAnimate the advance in steps (default: false)
options.durationnumberSmooth advance length in milliseconds (default: 3000)
options.fpsnumberSmooth 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.


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 });
ParameterTypeDescription
componentsobjectTime components to set
options.cinematicbooleanTrigger the cinematic overlay (default: false)

Returns: Promise<number> - New world time in seconds.


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 });
ParameterTypeDescription
dateobjectTarget date { year, month, day }
options.cinematicbooleanTrigger the cinematic overlay (default: false)

Returns: Promise<void>


Advance time to the next occurrence of a preset time.

await CALENDARIA.api.advanceTimeToPreset('sunrise');
await CALENDARIA.api.advanceTimeToPreset('midnight', { cinematic: true });
ParameterTypeDescription
presetstring'sunrise', 'midday', 'noon', 'sunset', or 'midnight'
options.cinematicbooleanTrigger the cinematic overlay (default: false)

Returns: Promise<number> - New world time in seconds.


CALENDARIA.api.isClockRunning(); // true while the real-time clock runs
CALENDARIA.api.startClock();
CALENDARIA.api.stopClock();
CALENDARIA.api.toggleClock();
CALENDARIA.api.getClockSpeed(); // game seconds per real second

startClock() 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 collections are keyed objects, not arrays. Use the array getters on a calendar for ordered iteration.

GetterCollection
monthsArraymonths.values
weekdaysArraydays.values
seasonsArrayseasons.values
moonsArraymoons
cyclesArraycycles
erasArrayeras
festivalsArrayfestivals
canonicalHoursArraycanonicalHours
namedWeeksArrayweeks.names
namedDaysArraydays.names
weatherZonesArrayweather.zones

The daysInWeek getter returns weekdaysArray.length || 7.

const calendar = CALENDARIA.api.getActiveCalendar();
const months = calendar.monthsArray;
MethodReturns
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

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 });
ParameterTypeDescription
idstringCalendar ID to activate
options.useCalendarDefaultsbooleansetActiveCalendar() 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.


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.


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.


Open a Secondary Calendar viewer for a non-active calendar.

CALENDARIA.api.showSecondaryCalendar('greyhawk');

Returns: SecondaryCalendar - The viewer instance.


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.


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);
MethodReturns
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.


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 }
MethodReturns
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.


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.


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' });
ParameterTypeDescription
sceneSceneScene used to resolve the zone (defaults to the active scene)
zoneIdstringExplicit zone ID
timenumberWorld 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.


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


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:30
const daytime = CALENDARIA.api.isDaytime(myZone);
MethodReturns
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.


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();
MethodCounts down to
getTimeUntilTarget(targetHour)The next time the clock reaches an hour
getTimeUntilSunrise()The next sunrise
getTimeUntilSunset()The next sunset
getTimeUntilMidnight()Midnight
getTimeUntilMidday()Midday

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.


const festival = CALENDARIA.api.getCurrentFestival(); // festival on today's date, or null
const isFestival = CALENDARIA.api.isFestivalDay();
const festivals = CALENDARIA.api.getFestivals('harptos'); // defaults to the active calendar

getFestivals() returns the calendar’s festival note stubs.

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
});
ParameterTypeDescription
calendarIdstringCalendar ID (required)
festivalData.namestringFestival name (required)
festivalData.startDateobjectStart date { year, month, day } (required)
festivalData.contentstringDescription (HTML)
festivalData.colorstringFestival color (hex)
festivalData.iconstringFont Awesome icon name, such as 'fa-sun'
festivalData.durationnumberDuration in days (default: 1)
festivalData.conditionTreeobjectCondition tree for recurrence
festivalData.categoriesstring[]Preset IDs

Returns: Promise<object|null> - Created note page, or null on failure.


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'.

CategoryPresets
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


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 string

Convert a world time in seconds to date components.

const date = CALENDARIA.api.timestampToDate(86400);
// Returns: { year, month, ordinal, monthName, intercalary, day, hour, minute }
FieldDescription
month1-based position in the month list, counting intercalary months
ordinalTraditional month number, which an intercalary month may share with a regular month
monthNameMonth name as stored on the calendar. It may be a localization key, so pass it through game.i18n.localize()
intercalaryWhether the month is intercalary

Returns: object|null


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


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.


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.


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
MethodReturns
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

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.


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'
});
ParameterTypeDescription
options.namestringNote title
options.contentstringNote content (HTML). When omitted, the preset’s content template is used
options.startDateobjectStart date { year, month, day, hour?, minute? }
options.endDateobjectEnd date (optional)
options.allDaybooleanAll-day event (default: true)
options.conditionTreeobjectCondition tree for recurrence (see below)
options.categoriesstring[]Preset IDs
options.iconstringIcon path or class
options.colorstringEvent color (hex)
options.visibilitystring'visible', 'hidden', or 'secret' (default: 'visible')
options.displayStylestring'icon', 'pip', or 'banner' (default: the preset’s display style)
options.subjectsstring[]Document UUIDs the note is about
options.reminderTypestring'none', 'toast', 'chat', or 'dialog'
options.reminderTargetsstring'all', 'gm', 'author', 'specific', or 'viewers'
options.reminderUsersstring[]User IDs notified when reminderTargets is 'specific'
options.reminderOffsetnumberHow far ahead of the note the reminder fires
options.reminderUnitstringOffset unit: 'hour', 'day', 'week', 'month', or 'year'
options.openSheetfalse|'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.

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.


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.


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' });
MethodNotes
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'

Move a calendar to a note’s date and open the note sheet.

await CALENDARIA.api.navigateToNote('abc123', { context: 'bigcal' });
ParameterTypeDescription
options.contextstring'bigcal' or 'minical' opens that calendar if needed. When omitted, only an already-open calendar moves
options.modestring'view' (default) or 'edit' for the note sheet

Returns: Promise<void>


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>


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:

OptionDescription
includeContentInclude note HTML content (default: false)
includeOccurrencesAdd nextOccurrence to each stub, a date or null (default: false)
maxOccurrencesgetNotesInRange() 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.


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 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');
ParameterTypeDescription
termstringSearch term (minimum 2 characters)
options.searchContentbooleanSearch note content (default: true)
options.limitnumberMax 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'.


const presets = CALENDARIA.api.getPresets();
const meetings = CALENDARIA.api.getNotesByPreset('meeting');

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>'
}
});
ParameterTypeDescription
options.labelstringDisplay name (required)
options.colorstringHex color
options.iconstringFont Awesome icon class
options.playerUsablebooleanAllow non-GM users to apply the preset (default: true)
options.sortOrdernumberSort order (default: end of the list)
options.defaultsobjectDefault 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.


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? }


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


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.


const payload = CALENDARIA.api.buildCinematicPayload(game.time.worldTime, game.time.worldTime + 604800);
await CALENDARIA.api.playCinematic(payload);
MethodDescription
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.


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.


Show a date picker dialog.

const date = await CALENDARIA.api.showDatePicker({ showTime: true });
// Returns: { year, month, day, hour, minute } or null if cancelled
ParameterTypeDescription
options.dateobjectInitial date (defaults to today)
options.showTimebooleanShow time inputs (default: false)
options.titlestringDialog title
options.positionobjectDialog position { x, y } in pixels
options.onSelectFunctionCallback fired with the selected date

Returns: Promise<object|null> - Selected date, or null if cancelled.


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.

ParameterTypeDescription
options.startDateobjectRange start { year, month, dayOfMonth } with 0-indexed month and day
options.endDateobjectRange end, in the same format
options.lockedRangebooleanLock the view to startDate and endDate
options.calendarIdstringCalendar whose entries drive the view
options.categoryFilterstring[]|nullPreset IDs to show; null restores the saved filter
options.subjectFilterstring[]|nullSubject document UUIDs to show; null clears the filter

options pre-filters the Note Viewer by date, preset ID, search term, or visibility.

CALENDARIA.api.startStopwatch(); // show and start
CALENDARIA.api.pauseStopwatch();
CALENDARIA.api.resetStopwatch();

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 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.

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.


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.


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 }
});
ParameterTypeDescription
presetIdstringWeather preset ID
options.temperaturenumberTemperature in Celsius
options.windobjectWind { speed, direction, forced } in place of the preset’s
options.precipitationobjectPrecipitation { type, intensity } in place of the preset’s
options.periodstringIntraday period to set: 'night', 'morning', 'afternoon', or 'evening'
options.allPeriodsbooleanSet every intraday period
options.zoneIdstringZone 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.


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.


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.


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.


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 }, ...]
ParameterTypeDescription
options.zoneIdstringZone to forecast
options.daysnumberNumber of days, capped at the Forecast Days setting
options.accuracynumberAccuracy from 0 to 100. GM callers only; defaults to 100 for a GM unless playerView is set
options.startobjectInternal date { year, month, dayOfMonth } to start from (default: today)
options.playerViewbooleanFor 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[]


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.

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 });
ParameterTypeDescription
options.allbooleanClear all history
options.futurebooleanClear entries after today
options.yearnumberClear one year
options.monthnumberClear one month of year
options.clearForecastbooleanAlso 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.


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 zone
await WeatherManager.setSceneZoneOverride(game.scenes.active, null); // No Zone
await WeatherManager.setSceneZoneOverride(game.scenes.active, undefined); // follow the calendar
const 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.


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
});
ParameterTypeDescription
namestringZone name (required)
idstringUnique zone ID, generated from the name when omitted
descriptionstringZone description
temperaturesobjectCelsius ranges keyed by season name, such as { Winter: { min, max } }
presetsArray|objectWeather preset configurations
seasonOverridesobjectPer-season overrides
windSpeedRangeobjectWind speed range { min, max } on the 0 to 5 scale
windDirectionsobjectWind direction weights by compass direction
brightnessMultipliernumberScene darkness scaling
environmentBaseobjectDay lighting: hue, intensity, luminosity, saturation, shadows
environmentDarkobjectNight lighting, in the same format
shortestDaynumberShortest day length in hours
longestDaynumberLongest day length in hours
colorShiftobjectDawn, 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.


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.


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.


const temp = CALENDARIA.api.getTemperature('desert'); // 22
const 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.


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.

MethodNotes
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

Recompute scene lighting on every synced scene, including time-of-day hue, weather, climate zone, and moon light.

await CALENDARIA.api.refreshEnvironment();

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.

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');
MethodReturns
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


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!')
});
MemberDescription
widgetPointsInsertion points: BIGCAL_ACTIONS, HUD_BUTTONS_LEFT, HUD_BUTTONS_RIGHT, HUD_INDICATORS, HUD_TRAY, MINICAL_SIDEBAR
replaceableElementsBuilt-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

Read-only copies of the module’s constants.

GetterValues
conditionFieldsEvery condition field
conditionOperatorsEvery condition operator
conditionGroupModesand, or, nand, xor, count
displayStylesicon, pip, banner
noteVisibilityvisible, hidden, secret
hooksEvery Calendaria hook name, such as DAY_CHANGE. See Hooks
Hooks.on(CALENDARIA.api.hooks.DAY_CHANGE, (data) => console.log(data));