Skip to content
3 Death Saves

Hooks

Calendaria fires the hooks below. Register them with Hooks.on() like any core Foundry hook.


Fires during Foundry’s init hook, after the CALENDARIA global namespace is created.

Parameters: None

Fires during Foundry’s ready hook, after every Calendaria manager is initialized and before any Calendaria application renders. Register widgets and configure integrations here.

ParameterTypeDescription
data.apiCalendariaAPIThe public API object
data.calendarCalendariaCalendar|nullThe active calendar
data.versionstringModule version
Hooks.on('calendaria.ready', ({ api, calendar, version }) => {
console.log(`Calendaria v${version} ready with calendar: ${calendar?.id}`);
});

Fires at the end of Calendaria’s ready handler, once the show call has been issued for every application configured to appear on load. Those renders are asynchronous and are not awaited, so the elements are not guaranteed to be in the DOM yet. To touch BigCal’s DOM, listen for calendaria.renderCalendar.

Parameters: None


Fires before BigCal renders.

ParameterTypeDescription
data.appBigCalThe BigCal application instance
data.displayModestring"month", "week", or "year"
data.calendarCalendariaCalendarActive calendar

Fires after BigCal renders and all DOM setup is complete.

ParameterTypeDescription
data.appBigCalThe BigCal application instance
data.elementHTMLElementThe rendered application element
data.displayModestring"month", "week", or "year"
data.calendarCalendariaCalendarActive calendar
Hooks.on('calendaria.renderCalendar', (data) => {
const dayCell = data.element.querySelector('.calendar-day.today');
if (dayCell) dayCell.classList.add('my-module-highlight');
});

Fires when the active calendar changes. It also fires once at startup, from inside CalendarManager.initialize(). That happens before calendaria.ready, so a listener registered in calendaria.ready will not see the startup fire. Read the active calendar from the calendaria.ready payload instead.

ParameterTypeDescription
idstringCalendar ID
calendarCalendariaCalendarCalendar instance

Fires when a calendarSwitch socket message arrives. Calendaria does not send that message. Switching the active calendar writes a world setting flagged requiresReload, so other clients reload rather than switching live. The hook fires only if another module calls CALENDARIA.socket.emitCalendarSwitch(calendarId).

ParameterTypeDescription
idstringCalendar ID
calendarCalendariaCalendarCalendar instance

Fires when a calendar is created or imported.

ParameterTypeDescription
idstringCalendar ID
calendarCalendariaCalendarCalendar instance

Fires when a calendar is modified.

ParameterTypeDescription
idstringCalendar ID
calendarCalendariaCalendarUpdated calendar instance

Fires when a calendar is deleted.

ParameterTypeDescription
idstringCalendar ID

In previous and current, year is the displayed year, with the calendar’s yearZero already applied. The other components match Foundry’s raw time components.

The Set Date dialog has a Skip Event Triggers option. A jump made with it enabled still fires calendaria.dateTimeChange and the day, month, year, and season hooks. It suppresses the solar threshold hooks, calendaria.moonPhaseChange, calendaria.restDayChange, calendaria.eventTriggered, and calendaria.eventDayChanged for that jump.

Fires on every world time change. This is the primary hook for time tracking.

ParameterTypeDescription
data.previousobjectPrevious time components: year, month, dayOfMonth, hour, minute, second
data.currentobjectCurrent time components
data.diffnumberTime delta in seconds
data.calendarCalendariaCalendarActive calendar
data.worldTimenumberCurrent world time in seconds

Fires when the day changes.

ParameterTypeDescription
data.previousobjectPrevious time components
data.currentobjectCurrent time components
data.calendarCalendariaCalendarActive calendar

Fires when the month changes. The payload matches calendaria.dayChange.

Fires when the year changes. The payload matches calendaria.dayChange.

Fires when the season changes.

ParameterTypeDescription
data.previousobjectPrevious time components
data.currentobjectCurrent time components
data.calendarCalendariaCalendarActive calendar
data.previousSeasonobject|nullPrevious season definition
data.currentSeasonobject|nullCurrent season definition

Fires when a dateChange socket message arrives from another client. Calendaria never sends that message, because world time already reaches every client through Foundry’s own updateWorldTime hook. This fires only if another module calls CALENDARIA.socket.emitDateChange(worldTime, delta). For ordinary time tracking, use calendaria.dateTimeChange.

ParameterTypeDescription
data.worldTimenumberNew world time in seconds
data.deltanumberTime delta in seconds

calendaria.sunrise, calendaria.sunset, calendaria.midnight, and calendaria.midday fire when the matching time-of-day threshold is crossed. They fire only when time moves forward. Rewinding the clock fires none of them. A forward jump replays each crossing it passed, capped at 30 intermediate days, so a longer jump fires fewer times than the number of days skipped.

All four take the same payload.

ParameterTypeDescription
data.worldTimenumberWorld time in seconds
data.componentsobjectTime components
data.calendarCalendariaCalendarActive calendar

Fires when any moon’s phase changes.

ParameterTypeDescription
data.moonsobject[]The moons whose phase changed
data.calendarCalendariaCalendarActive calendar
data.worldTimenumberWorld time in seconds

Each entry in data.moons has these fields.

FieldTypeDescription
moonIndexnumberIndex of the moon
moonNamestringLocalized moon name
visiblebooleanWhether the moon is visible to the current user. Always true for a GM
previousPhaseIndexnumberPrevious phase index
previousPhaseNamestring|nullPrevious phase name
currentPhaseIndexnumberCurrent phase index
currentPhaseNamestring|nullCurrent phase name

Fires when the date moves onto or off a rest day.

ParameterTypeDescription
data.isRestDaybooleanCurrent rest day status
data.wasRestDaybooleanPrevious rest day status
data.weekdayobject|nullWeekday info: index, name, abbreviation
data.worldTimenumberWorld time in seconds
data.calendarCalendariaCalendarActive calendar

Fires when the real-time clock starts or stops.

ParameterTypeDescription
data.runningbooleanWhether the clock is running
data.incrementnumberTime increment in game seconds
data.lockedbooleanPresent only when fired from the lock toggle
data.disabledbooleanPresent only when fired by a change to the disabled state

Fires when clock state arrives from another client, which is how the real-time clock stays in sync across connected clients.

ParameterTypeDescription
data.runningbooleanWhether the clock is running
data.rationumberThe clock’s selected time increment in game seconds, the same value calendaria.clockStartStop reports as increment

Fires once per real second while the real-time clock is running. It does not fire while the clock is stopped or blocked by combat. The HUD, BigCal, MiniCal, Time Keeper, and Stop Watch listen for it to update their time displays.

ParameterTypeDescription
data.predictedWorldTimenumberPredicted world time in seconds. Interpolation can put it ahead of game.time.worldTime

Fires from Calendaria’s updateWorldTime handler with the raw world time and delta. It fires after calendaria.dateTimeChange and before calendaria.eventTriggered.

ParameterTypeDescription
worldTimenumberCurrent world time in seconds
dtnumberTime delta in seconds

The stop watch is per-client state, so these hooks fire only on the client whose stop watch changed.

Fires when the stop watch starts.

ParameterTypeDescription
data.modestring"realtime" or "gametime"

Fires when the stop watch is paused.

ParameterTypeDescription
data.modestringStop watch mode
data.elapsednumberElapsed time, in milliseconds for realtime and seconds for gametime

Fires when the stop watch is reset.

ParameterTypeDescription
data.modestringStop watch mode

Fires when a lap is recorded.

ParameterTypeDescription
data.modestringStop watch mode
data.lapnumberLap number
data.elapsednumberElapsed time at lap

calendaria.noteCreated and calendaria.noteUpdated both pass a single note stub.

FieldTypeDescription
idstringJournal page ID
uuidstringPage UUID
namestringNote name
contentstringPage text content
flagDataobjectThe note’s calendar data
calendarIdstringCalendar the note belongs to
journalIdstring|nullParent journal entry ID
visiblebooleanWhether the current user may observe the note
isOwnerbooleanWhether the current user owns the note
ownershipobjectOwnership record from the parent journal

Fires when a calendar note is created.

Fires when a calendar note is modified.

Fires when a calendar note is deleted.

ParameterTypeDescription
pageIdstringJournal page ID

Fires when note presets are added, removed, or modified.

ParameterTypeDescription
presetsobject[]Updated array of all presets

Both event hooks are evaluated by the scheduler, which runs only on the primary GM’s client. Player clients never receive them. To reach players, broadcast from the GM listener or use calendaria.reminderReceived.

Fires when a scheduled event or reminder occurs.

ParameterTypeDescription
data.idstringNote or event ID
data.namestringEvent name
data.flagDataobjectEvent calendar data
data.currentDateobjectCurrent date components, events only
data.reminderTypestringReminder type, reminders only
data.isReminderbooleanTrue if this is a reminder

Fires when a multi-day event progresses to a new day.

ParameterTypeDescription
data.idstringNote ID
data.namestringEvent name
data.progressobjectcurrentDay, totalDays, percentage, isFirstDay, isLastDay

Fires when a reminder notification arrives from another client. ReminderScheduler listens for it to display the notification, and it is available for module integration.

ParameterTypeDescription
data.typestring"toast" or "dialog"
data.noteIdstringJournal page ID
data.noteNamestringNote name
data.journalIdstringParent journal entry ID
data.messagestringFormatted reminder message
data.iconstring|nullIcon identifier
data.iconTypestring|nullIcon type, such as "fontawesome"
data.colorstring|nullIcon color
data.targetsstring[]User IDs who should receive the reminder
Hooks.on('calendaria.reminderReceived', (data) => {
if (data.targets.includes(game.user.id)) {
console.log(`Reminder: ${data.noteName}`);
}
});

Fires after a note’s condition tree is evaluated through the API. Passing { silent: true } to evaluateNote() skips the hook, which avoids flooding listeners when evaluating a note across many dates in a loop.

ParameterTypeDescription
pageIdstringJournal entry page ID
dateobjectDate the note was evaluated against
resultbooleanEvaluation result

Fires when you reveal or reset fog of war date ranges.

ParameterTypeDescription
data.calendarIdstringCalendar the ranges belong to
data.rangesobject[]Updated array of revealed date ranges

calendaria.cinematicStart fires when a cinematic time skip begins and calendaria.cinematicEnd when it completes. calendaria.cinematicAbort fires when a user cancels the skip. calendaria.cinematicPause and calendaria.cinematicResume fire around a paused skip.

All five receive the same payload.

ParameterTypeDescription
data.startTimenumberWorld time in seconds at the start of the skip
data.endTimenumberWorld time in seconds at the end of the skip
data.deltaSecondsnumberLength of the skip in seconds
data.calendarIdstring|nullActive calendar ID
data.keyframesobject[]The keyframes the cinematic plays through
data.settingsobjectSnapshot of the cinematic settings in force for this skip

Fires when weather changes. The payload shape varies by source. A per-zone change carries previous, current, and zoneId. A bulk change carries only bulk. An editor preview carries only visualOnly.

The hook also fires when a scene is activated, reporting the zone’s existing weather so listeners can re-apply effects for the new scene. On that path and on remote changes, previous is null even when earlier weather existed. Compare against state you cached rather than relying on previous.

ParameterTypeDescription
data.previousobject|nullPrevious weather state
data.currentobject|nullCurrent weather state
data.zoneIdstring|undefinedClimate zone ID for the change
data.remotebooleanTrue if the change originated on another client
data.visualOnlybooleanTrue when fired from a Weather Editor preview. FX and sound handlers should skip it
data.bulkbooleanTrue when the change affects all zones at once. previous, current, and zoneId are absent, so re-read weather state from the API
Hooks.on('calendaria.weatherChange', (data) => {
if (data.bulk) return refreshAllZones();
if (data.current) applyWeather(data.zoneId, data.current);
});

Fires when the intraday weather period changes at a solar threshold. It fires only on the primary GM’s client, and only while intraday weather generation is enabled. A bulk calendaria.weatherChange for the same transition always precedes it.

ParameterTypeDescription
data.periodstringThe period that just started: "night", "morning", "afternoon", or "evening"

Fires when a calendar import begins.

ParameterTypeDescription
data.importerIdstringImporter ID
data.calendarIdstringTarget calendar ID

Fires when an import finishes successfully.

ParameterTypeDescription
data.importerIdstringImporter ID
data.calendarIdstringCreated calendar ID
data.calendarCalendariaCalendarImported calendar

Fires when an import fails.

ParameterTypeDescription
data.importerIdstringImporter ID
data.calendarIdstringTarget calendar ID
data.errorstringError message

Fires when display format settings are saved.

ParameterTypeDescription
newFormatsobjectUpdated display format configuration

Theming runs through 3DS:ATLAS. Calendaria listens for the 3ds-atlas.themeChanged hook and re-renders the HUD, Time Keeper, MiniCal, BigCal, and Stop Watch when its own theme changes. It fires no theme hook of its own.


Fires when a widget is registered through the Widget API.

ParameterTypeDescription
fullIdstringFull widget ID, moduleId.widgetId
configobjectWidget configuration

Fires when widgets are re-rendered.

Parameters: None