Skip to content

API Reference

Calendaria exposes a public API at CALENDARIA.api for macros and module integration.

[!IMPORTANT] Methods marked “GM only” will fail silently or show a warning when called by non-GM users.


Get the current world date and time.

const now = CALENDARIA.api.getCurrentDateTime();
// Returns: { year, month, dayOfMonth, hour, minute, second, ... }

Returns: object - Time components including year adjusted for yearZero.


Advance time by a delta. GM only. When delta is an object with day, hour, minute, second keys, it is converted to seconds using the active calendar’s time configuration.

await CALENDARIA.api.advanceTime({ hour: 8 });
await CALENDARIA.api.advanceTime({ day: 1, hour: 6 });
await CALENDARIA.api.advanceTime(3600); // advance by raw seconds
await CALENDARIA.api.advanceTime({ hour: 8 }, { cinematic: true });
ParameterTypeDescription
deltanumber|objectSeconds or time delta object (e.g., {day: 1, hour: 2})
options.cinematicbooleanTrigger the cinematic overlay (default: false)

Note: API calls do not trigger the cinematic overlay by default. Pass cinematic: true to opt in.

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


Set time to specific values. GM only.

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.

Note: API calls do not trigger the cinematic overlay by default. Pass cinematic: true to opt in.


Jump to a specific date while preserving current time of day. GM only.

await CALENDARIA.api.jumpToDate({
year: 1492,
month: 5, // 1-indexed
day: 1
});
await CALENDARIA.api.jumpToDate({ year: 1492, month: 5, day: 1 }, { cinematic: true });
ParameterTypeDescription
options.yearnumberTarget year
options.monthnumberTarget month (1-indexed)
options.daynumberTarget day of month (1-indexed)
advanceOptions.cinematicbooleanTrigger the cinematic overlay (default: false)

Returns: Promise<void>

Note: API calls do not trigger the cinematic overlay by default. Pass cinematic: true to opt in.


Advance time to the next occurrence of a preset time. GM only.

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

Note: API calls do not trigger the cinematic overlay by default. Pass cinematic: true to opt in.

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


Check if the real-time clock is currently running.

const running = CALENDARIA.api.isClockRunning();

Returns: boolean - True if the clock is running.


Start the real-time clock. Requires time-change permission. Blocked during active combat or when the game is paused with sync enabled.

CALENDARIA.api.startClock();

Returns: void


Stop the real-time clock.

CALENDARIA.api.stopClock();

Returns: void


Toggle the real-time clock on or off.

CALENDARIA.api.toggleClock();

Returns: void


Check if the clock is currently locked. When locked, all time advancement is blocked.

const locked = CALENDARIA.api.isClockLocked();

Returns: boolean - True if the clock is locked.


Toggle the clock lock state. GM only.

await CALENDARIA.api.toggleClockLock();

Returns: Promise<void>


Get the current real-time clock speed (game seconds per real second).

const speed = CALENDARIA.api.getClockSpeed();
// Returns: 1 (1 game second per real second at default speed)

Returns: number - Clock speed multiplier.


Calendar collections (months, weekdays, seasons, moons, etc.) are stored as keyed objects with string IDs, not arrays. Use the convenience getter arrays for ordered iteration:

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

The daysInWeek getter returns weekdaysArray.length || 7.

const calendar = CALENDARIA.api.getActiveCalendar();
const months = calendar.monthsArray; // ordered array
const weekCount = calendar.daysInWeek; // number of weekdays or 7

Get the currently active calendar.

const calendar = CALENDARIA.api.getActiveCalendar();

Returns: object|null - The active calendar or null.


Get a specific calendar by ID.

const calendar = CALENDARIA.api.getCalendar('harptos');
ParameterTypeDescription
idstringCalendar ID

Returns: object|null - The calendar or null if not found.


Get all registered calendars.

const calendars = CALENDARIA.api.getAllCalendars();

Returns: Map<string, object> - Map of calendar ID to calendar.


Get metadata for all calendars.

const metadata = CALENDARIA.api.getAllCalendarMetadata();

Returns: object[] - Array of calendar metadata.


Add a new calendar. GM only.

await CALENDARIA.api.addCalendar('myCalendar', calendarDefinition);
ParameterTypeDescription
idstringUnique calendar ID
definitionobjectCalendar definition object

Returns: Promise<object|null> - The created calendar or null if the ID already exists.


Switch to a different calendar. GM only.

await CALENDARIA.api.switchCalendar('greyhawk');
ParameterTypeDescription
idstringCalendar ID to switch to

Returns: Promise<boolean> - True if switched successfully.


Set the active calendar. GM only. Accepts an options object that controls whether the world’s DISPLAY_FORMATS setting is rewritten from the new calendar’s authored dateFormats.

await CALENDARIA.api.setActiveCalendar('greyhawk', { useCalendarDefaults: true });
ParameterTypeDescription
idstringCalendar ID to activate
options.useCalendarDefaultsbooleanWhen true, rewrites the world DISPLAY_FORMATS setting from the new calendar’s dateFormats so every location maps to calendarDefault. Defaults to false

Returns: Promise<boolean> - True if activated successfully.


convertDate(date, fromCalendarId, toCalendarId)

Section titled “convertDate(date, fromCalendarId, toCalendarId)”

Convert a date from one calendar to another via shared world time.

const converted = CALENDARIA.api.convertDate({ year: 1492, month: 5, day: 15 }, 'harptos', 'greyhawk');
// Returns: { year, month, day, hour, minute }
ParameterTypeDescription
dateobjectDate to convert {year, month (1-indexed), day (1-indexed), hour?, minute?}
fromCalendarIdstringSource calendar ID
toCalendarIdstringTarget calendar ID

Returns: object|null - Converted date or null.


Get equivalent dates for a date on all other registered calendars.

const equivalents = CALENDARIA.api.getEquivalentDates({ year: 1492, month: 5, day: 15 });
ParameterTypeDescription
dateobjectDate {year, month (1-indexed), day (1-indexed)}
calendarIdstringSource calendar ID (defaults to active calendar)

Returns: Array<{calendarId, calendarName, date, formatted}> - Equivalent dates on all other calendars.


Get the current date expressed on a specific (non-active) calendar.

const date = CALENDARIA.api.getCurrentDateOn('greyhawk');
// Returns: { year, month, day, hour, minute }
ParameterTypeDescription
calendarIdstringTarget calendar ID

Returns: object|null - Date on the target calendar, or null.


Open a secondary calendar viewer for a non-active calendar. The viewer stays synced with worldTime.

CALENDARIA.api.showSecondaryCalendar('greyhawk');
ParameterTypeDescription
calendarIdstringCalendar ID to view

Returns: SecondaryCalendar - The viewer instance.


Get the current phase of a specific moon.

const phase = CALENDARIA.api.getMoonPhase(0);
// Returns: { name, icon, position, dayInCycle }
ParameterTypeDescription
moonIndexnumberIndex of the moon (default: 0)

Returns: object|null - Moon phase data.


Get phases for all moons in the active calendar.

const moons = CALENDARIA.api.getAllMoonPhases();

Returns: Array<object> - Array of moon phase data.


Get the phase position (0–1) for a moon on a given date. Returns 0 when the moon index is out of range or the calendar has no active moons.

const position = CALENDARIA.api.getMoonPhasePosition(0);
// Returns: 0.5 (full moon)
ParameterTypeDescription
moonIndexnumberMoon index (default: 0)
dateobjectOptional date (defaults to today)

Returns: number - Phase position from 0 (new moon) to 1.


Check if a moon is currently in its full phase.

const isFull = CALENDARIA.api.isMoonFull(0);
ParameterTypeDescription
moonIndexnumberMoon index (default: 0)
dateobjectOptional date

Returns: boolean - True if the moon is in its full phase.


Get the date of the next full moon.

const date = CALENDARIA.api.getNextFullMoon(0);
// Returns: { year, month, day }
ParameterTypeDescription
moonIndexnumberMoon index (default: 0)
fromDateobjectStart date (defaults to today)

Returns: object - Date of next full moon.


Get the date when all moons are simultaneously full.

const date = CALENDARIA.api.getNextConvergence();
ParameterTypeDescription
fromDateobjectStart date (defaults to today)

Returns: object|null - Date of next convergence, or null if not found within search range.


getConvergencesInRange(startDate, endDate)

Section titled “getConvergencesInRange(startDate, endDate)”

Get all dates within a range where all moons are simultaneously full.

const dates = CALENDARIA.api.getConvergencesInRange({ year: 1492, month: 0, day: 1 }, { year: 1493, month: 0, day: 1 });
ParameterTypeDescription
startDateobjectRange start
endDateobjectRange end

Returns: object[] - Array of convergence dates.


Get eclipse data for a moon on a specific date.

const eclipse = CALENDARIA.api.getEclipse(0);
// Returns: { type: 'solar-total', proximity: 0.95 } or { type: null }
ParameterTypeDescription
moonOrIndexobject|numberMoon definition or index into moonsArray
dateobjectDate to check {year, month, day} (defaults to current date)

Returns: object - Eclipse result { type, proximity } or { type: null } if no eclipse.


Check if any eclipse occurs on a specific date across all moons.

const eclipseToday = CALENDARIA.api.isEclipse();
const eclipseOnDate = CALENDARIA.api.isEclipse({ year: 1492, month: 6, day: 21 });
ParameterTypeDescription
dateobjectDate to check (defaults to current date)

Returns: boolean - True if any eclipse occurs.


getNextEclipse(moonOrIndex, startDate, options)

Section titled “getNextEclipse(moonOrIndex, startDate, options)”

Find the next eclipse for a moon.

const next = CALENDARIA.api.getNextEclipse(0);
// Returns: { date: { year, month, day }, type: 'lunar-total', proximity: 1.0 }
ParameterTypeDescription
moonOrIndexobject|numberMoon definition or index into moonsArray
startDateobjectStart searching from (defaults to current date)
options.maxDaysnumberMaximum days to search

Returns: object|null - { date, type, proximity } or null if not found.


getEclipsesInRange(moonOrIndex, startDate, endDate, options)

Section titled “getEclipsesInRange(moonOrIndex, startDate, endDate, options)”

Get all eclipses for a moon within a date range.

const eclipses = CALENDARIA.api.getEclipsesInRange(0, { year: 1492, month: 1, day: 1 }, { year: 1493, month: 1, day: 1 });
// Returns: [{ date, type, proximity }, ...]
ParameterTypeDescription
moonOrIndexobject|numberMoon definition or index into moonsArray
startDateobjectRange start {year, month, day}
endDateobjectRange end {year, month, day}
optionsobjectSearch options

Returns: object[] - Array of { date, type, proximity }.


Get the current season.

const season = CALENDARIA.api.getCurrentSeason();

Returns: object|null - Season data with name and properties. This call returns the raw calendar season without alias resolution. Callers wanting display values should use WeatherManager.getAliasedSeason (or WeatherManager.applySeasonAlias(season, zone) for an explicit zone).


Static WeatherManager helper that resolves the current season and applies the active zone’s alias.

const season = CALENDARIA.managers.WeatherManager.getAliasedSeason({ scene, zoneId, time });
ParameterTypeDescription
sceneSceneScene used to resolve the active zone when zoneId is omitted (optional)
zoneIdstringExplicit zone ID; bypasses scene resolution (optional)
timenumberWorld time in seconds used to resolve the season; defaults to the current world time

Returns: object - { name, abbreviation, icon, color } with alias overrides merged onto the resolved season.

For an explicit season + zone pair, call WeatherManager.applySeasonAlias(season, zone) directly.


Get current values for all cycles (zodiac signs, elemental weeks, etc).

const cycles = CALENDARIA.api.getCycleValues();
// Returns: { text, values: [{ cycleName, entryName, index }] }

Returns: object|null - Current cycle values.


Get today’s sunrise time in hours. Zones with both sunriseOverride and sunsetOverride set (and sunrise < sunset, within 0 to hoursPerDay) return the fixed override unchanged across the year, bypassing latitude and shortest/longest interpolation.

const sunrise = CALENDARIA.api.getSunrise();
// With explicit zone:
const sunrise = CALENDARIA.api.getSunrise(myZone);
// Returns: 6.5 (meaning 6:30 AM)
ParameterTypeDescription
zoneobject|nullClimate zone object (default: active scene’s zone)

Returns: number|null - Sunrise time in hours.


Get today’s sunset time in hours. Zones with both sunriseOverride and sunsetOverride set (and sunrise < sunset, within 0 to hoursPerDay) return the fixed override unchanged across the year.

const sunset = CALENDARIA.api.getSunset();
// With explicit zone:
const sunset = CALENDARIA.api.getSunset(myZone);
// Returns: 18.5 (meaning 6:30 PM)
ParameterTypeDescription
zoneobject|nullClimate zone object (default: active scene’s zone)

Returns: number|null - Sunset time in hours.


Get hours of daylight today. Zones with both sunriseOverride and sunsetOverride set return sunsetOverride - sunriseOverride as a constant across the year.

const hours = CALENDARIA.api.getDaylightHours();
// With explicit zone:
const hours = CALENDARIA.api.getDaylightHours(myZone);
ParameterTypeDescription
zoneobject|nullClimate zone object (default: active scene’s zone)

Returns: number|null - Hours of daylight.


Get progress through the day period (0 = sunrise, 1 = sunset).

const progress = CALENDARIA.api.getProgressDay();
// With explicit zone:
const progress = CALENDARIA.api.getProgressDay(myZone);
ParameterTypeDescription
zoneobject|nullClimate zone object (default: active scene’s zone)

Returns: number|null - Progress value between 0-1.


Get progress through the night period (0 = sunset, 1 = sunrise).

const progress = CALENDARIA.api.getProgressNight();
// With explicit zone:
const progress = CALENDARIA.api.getProgressNight(myZone);
ParameterTypeDescription
zoneobject|nullClimate zone object (default: active scene’s zone)

Returns: number|null - Progress value between 0-1.


Get time until a specific hour of day.

const time = CALENDARIA.api.getTimeUntilTarget(12);
// Returns: { hours, minutes, seconds }
ParameterTypeDescription
targetHournumberTarget hour (0 to hoursPerDay)

Returns: object|null - Time remaining as { hours, minutes, seconds }.

[!NOTE] For calendars with non-standard time (e.g., 20 hours/day), the targetHour range is 0 to hoursPerDay.


Get time until next sunrise.

const time = CALENDARIA.api.getTimeUntilSunrise();
// Returns: { hours, minutes, seconds }

Returns: object|null - Time remaining.


Get time until next sunset.

const time = CALENDARIA.api.getTimeUntilSunset();

Returns: object|null - Time remaining.


Get time until midnight.

const time = CALENDARIA.api.getTimeUntilMidnight();

Returns: object|null - Time remaining.


Get time until midday (noon).

const time = CALENDARIA.api.getTimeUntilMidday();

Returns: object|null - Time remaining.


Check if it’s currently daytime.

const daytime = CALENDARIA.api.isDaytime();

Returns: boolean - True if between sunrise and sunset.


Check if it’s currently nighttime.

const nighttime = CALENDARIA.api.isNighttime();

Returns: boolean - True if before sunrise or after sunset.


Get the current weekday information.

const weekday = CALENDARIA.api.getCurrentWeekday();
// Returns: { index, name, abbreviation, isRestDay }

Returns: object|null - Weekday data.


Get the current named week for the active world time. Exposed on the active calendar instance, not on CALENDARIA.api.

const calendar = CALENDARIA.managers.CalendarManager.getActiveCalendar();
const week = calendar?.getCurrentWeek();
// Returns: { weekName, weekAbbr, weekNumber, index }

Returns: object|null - Named week data, or null if no named weeks are defined or no entry matches the current date.


Check if today is a rest day.

const isRest = CALENDARIA.api.isRestDay();

Returns: boolean - True if current day is a rest day.


Get the festival on the current date, if any.

const festival = CALENDARIA.api.getCurrentFestival();

Returns: object|null - Festival data with name, month, day.


Check if today is a festival day.

const isFestival = CALENDARIA.api.isFestivalDay();

Returns: boolean - True if current date is a festival.


Create a festival note for a calendar. GM only.

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,
categories: ['festival']
});
ParameterTypeDescription
calendarIdstringCalendar ID
festivalData.namestringFestival name
festivalData.contentstringDescription (HTML)
festivalData.startDateobjectStart date {year, month (1-indexed), day (1-indexed)}
festivalData.colorstringFestival color (hex)
festivalData.iconstringIcon class (e.g., '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.


Get all festival notes for a calendar.

const festivals = CALENDARIA.api.getFestivals();
// Or for a specific calendar:
const festivals = CALENDARIA.api.getFestivals('harptos');
ParameterTypeDescription
calendarIdstringCalendar ID (defaults to active calendar)

Returns: object[] - Array of festival note stubs.


Format date and time components as a string.

// Using presets
const formatted = CALENDARIA.api.formatDate(null, 'dateLong');
const formatted = CALENDARIA.api.formatDate(null, 'datetime12');
// Using custom format
const formatted = CALENDARIA.api.formatDate({ year: 1492, month: 5, day: 15 }, 'DD MMMM YYYY');
ParameterTypeDescription
componentsobjectTime components (defaults to current time)
formatOrPresetstringPreset name or format string (default: 'dateLong')

Presets:

CategoryPresets
Utility'off', 'calendarDefault', 'custom'
Approximate'approxDate', 'approxTime'
Standard'dateShort', 'dateMedium', 'dateLong', 'dateFull'
Regional'dateUS', 'dateUSFull', 'dateISO', 'dateNumericUS', 'dateNumericEU'
Ordinal/Fantasy'ordinal', 'ordinalLong', 'ordinalEra', 'ordinalFull', 'seasonDate'
Time'time12', 'time12Sec', 'time24', 'time24Sec'
DateTime'datetimeShort12', 'datetimeShort24', 'datetime12', 'datetime24'

Returns: string - Formatted date/time string.

[!NOTE] When passing custom components, the day property should be 1-indexed (1-31). Internal time components use 0-indexed dayOfMonth (0-30). The formatDate() function automatically converts to 1-indexed for display when using D or DD tokens.


Get relative time description between two dates.

const relative = CALENDARIA.api.timeSince({ year: 1492, month: 5, dayOfMonth: 15 });
// Returns: "3 days ago" or "in 2 weeks"
ParameterTypeDescription
targetDateobjectTarget date { year, month, dayOfMonth }
currentDateobject or nullCurrent date (defaults to current time)

Returns: string - Relative time string.


Get available format tokens and their descriptions.

const tokens = CALENDARIA.api.getFormatTokens();
// Returns: [{ token, descriptionKey, type }, ...]

Returns: Array<{token: string, descriptionKey: string, type: string}> - Available format tokens.


Get default format presets.

const presets = CALENDARIA.api.getFormatPresets();

Returns: object - Format preset definitions.


Convert a world time timestamp to date components.

const date = CALENDARIA.api.timestampToDate(86400);
// Returns: { year, month, ordinal, monthName, intercalary, day, hour, minute }
ParameterTypeDescription
timestampnumberWorld time in seconds

Returns: object|null - Date components:

FieldTypeDescription
yearnumberYear (adjusted for yearZero)
monthnumber1-based sequential month index (includes intercalary months)
ordinalnumberTraditional month ordinal (may be shared by intercalary and regular months)
monthNamestringLocalized month name
intercalarybooleanWhether this month is an intercalary (festival) month
daynumber1-based day of month
hournumberHour
minutenumberMinute

Convert date components to a world time timestamp.

// Using sequential month index
const timestamp = CALENDARIA.api.dateToTimestamp({
year: 1492,
month: 5,
day: 15,
hour: 10,
minute: 30
});
// Using ordinal (prefers non-intercalary months when ordinals are shared)
const timestamp2 = CALENDARIA.api.dateToTimestamp({
year: 729,
ordinal: 7,
day: 1
});
ParameterTypeDescription
dateobjectDate components
date.yearnumberYear
date.monthnumber1-based sequential month index (takes priority over ordinal)
date.ordinalnumberTraditional month ordinal (used if month is not provided)
date.daynumber1-based day of month
date.hournumberHour (optional, default 0)
date.minutenumberMinute (optional, default 0)
date.secondnumberSecond (optional, default 0)

Returns: number - World time in seconds.


Generate a random date within a range.

const randomDate = CALENDARIA.api.chooseRandomDate({ year: 1492, month: 0, day: 1 }, { year: 1492, month: 11, day: 31 });
ParameterTypeDescription
startDateobjectStart date (defaults to current date)
endDateobjectEnd date (defaults to 1 year from start)

Returns: object - Random date components.


Add days to a date.

const newDate = CALENDARIA.api.addDays({ year: 1492, month: 5, day: 15 }, 10);
// Returns date 10 days later
ParameterTypeDescription
dateobjectDate { year, month, day }
daysnumberDays to add (negative to subtract)

Returns: object - New date components.


Add months to a date.

const newDate = CALENDARIA.api.addMonths({ year: 1492, month: 5, day: 15 }, 3);
ParameterTypeDescription
dateobjectDate { year, month, day }
monthsnumberMonths to add (negative to subtract)

Returns: object - New date components.


Add years to a date.

const newDate = CALENDARIA.api.addYears({ year: 1492, month: 5, day: 15 }, 10);
ParameterTypeDescription
dateobjectDate { year, month, day }
yearsnumberYears to add (negative to subtract)

Returns: object - New date components.


Add hours to a date.

const newDate = CALENDARIA.api.addHours({ year: 1492, month: 5, day: 15, hour: 10 }, 8);
ParameterTypeDescription
dateobjectDate { year, month, day, hour?, minute? }
hoursnumberHours to add (negative to subtract)

Returns: object - New date components.


Add minutes to a date.

const newDate = CALENDARIA.api.addMinutes({ year: 1492, month: 5, day: 15, hour: 10, minute: 30 }, 45);
ParameterTypeDescription
dateobjectDate { year, month, day, hour?, minute? }
minutesnumberMinutes to add (negative to subtract)

Returns: object - New date components.


Add seconds to a date.

const newDate = CALENDARIA.api.addSeconds({ year: 1492, month: 5, day: 15, hour: 10 }, 3600);
ParameterTypeDescription
dateobjectDate { year, month, day, hour?, minute? }
secondsnumberSeconds to add (negative to subtract)

Returns: object - New date components.


Calculate the number of days between two dates.

const days = CALENDARIA.api.daysBetween({ year: 1492, month: 5, day: 1 }, { year: 1492, month: 5, day: 15 });
// Returns: 14
ParameterTypeDescription
startDateobjectStart date { year, month, day }
endDateobjectEnd date { year, month, day }

Returns: number - Days between dates (positive if endDate is later).


Calculate the number of months between two dates.

const months = CALENDARIA.api.monthsBetween({ year: 1492, month: 0, day: 1 }, { year: 1492, month: 6, day: 1 });
// Returns: 6
ParameterTypeDescription
startDateobjectStart date { year, month, day }
endDateobjectEnd date { year, month, day }

Returns: number - Months between dates.


Calculate hours between two dates.

const hours = CALENDARIA.api.hoursBetween({ year: 1492, month: 5, day: 1, hour: 8 }, { year: 1492, month: 5, day: 1, hour: 17 });
// Returns: 9
ParameterTypeDescription
startDateobjectStart date { year, month, day, hour?, minute? }
endDateobjectEnd date { year, month, day, hour?, minute? }

Returns: number - Hours between dates (can be negative/fractional).


Calculate minutes between two dates.

const minutes = CALENDARIA.api.minutesBetween({ year: 1492, month: 5, day: 1, hour: 8, minute: 0 }, { year: 1492, month: 5, day: 1, hour: 8, minute: 45 });
// Returns: 45
ParameterTypeDescription
startDateobjectStart date { year, month, day, hour?, minute? }
endDateobjectEnd date { year, month, day, hour?, minute? }

Returns: number - Minutes between dates (can be negative).


Calculate seconds between two dates.

const seconds = CALENDARIA.api.secondsBetween({ year: 1492, month: 5, day: 1, hour: 8 }, { year: 1492, month: 5, day: 1, hour: 9 });
// Returns: 3600
ParameterTypeDescription
startDateobjectStart date { year, month, day, hour?, minute? }
endDateobjectEnd date { year, month, day, hour?, minute? }

Returns: number - Seconds between dates (can be negative).


Compare two dates including time components.

const result = CALENDARIA.api.compareDates({ year: 1492, month: 5, day: 15, hour: 10 }, { year: 1492, month: 5, day: 15, hour: 14 });
// Returns: -1 (date1 is earlier)
ParameterTypeDescription
date1objectFirst date
date2objectSecond date

Returns: number - -1 if date1 < date2, 0 if equal, 1 if date1 > date2.


Compare two dates ignoring time components.

const result = CALENDARIA.api.compareDays({ year: 1492, month: 5, day: 15 }, { year: 1492, month: 5, day: 20 });
// Returns: -1 (date1 is earlier)
ParameterTypeDescription
date1objectFirst date
date2objectSecond date

Returns: number - -1 if date1 < date2, 0 if same day, 1 if date1 > date2.


Check if two dates are the same day.

const same = CALENDARIA.api.isSameDay({ year: 1492, month: 5, day: 15, hour: 10 }, { year: 1492, month: 5, day: 15, hour: 20 });
// Returns: true
ParameterTypeDescription
date1objectFirst date
date2objectSecond date

Returns: boolean - True if same calendar day.


Get the weekday index for a date.

const weekday = CALENDARIA.api.dayOfWeek({ year: 1492, month: 5, day: 15 });
// Returns: 0-6 depending on calendar weekdays
ParameterTypeDescription
dateobjectDate { year, month, day }

Returns: number - Weekday index (0-based).


Check if a date is valid for the active calendar.

const valid = CALENDARIA.api.isValidDate({ year: 1492, month: 5, day: 31 });
ParameterTypeDescription
dateobjectDate { year, month, day }

Returns: boolean - True if date exists in the calendar.


Get all calendar notes.

const notes = CALENDARIA.api.getAllNotes();

Returns: object[] - Array of note stubs with id, name, flagData, etc.


Get a specific note by ID.

const note = CALENDARIA.api.getNote('abc123');
ParameterTypeDescription
pageIdstringJournal entry page ID

Returns: object|null - Note stub or null.


Get the full Foundry JournalEntryPage document for a note.

const page = CALENDARIA.api.getNoteDocument('abc123');
// Access full document properties
console.log(page.text.content);
ParameterTypeDescription
pageIdstringJournal entry page ID

Returns: JournalEntryPage|null - Full Foundry document or null.

[!NOTE] Use getNote() for calendar-specific data (stub). Use getNoteDocument() when you need the full Foundry document for content access or document methods.


Create a new calendar note. Players can create their own notes; GM can create notes for anyone.

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). If omitted and categories are set, the preset’s content template is used
options.startDateobjectStart date {year, month, day, hour?, minute?} (1-indexed month/day)
options.endDateobjectEnd date (optional)
options.allDaybooleanAll-day event (default: true)
options.conditionTreeobjectCondition tree for recurrence scheduling (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: 'icon')
options.openSheetfalse|'edit'|'view'Open the note sheet after creation in the given mode (default: 'edit'). Pass boolean false to skip

A conditionTree is a group of conditions evaluated against each candidate date. For a recurring annual event, use a fixed month/day group:

// Birthday on Aug 23 every year
await CALENDARIA.api.createNote({
name: "Aldric's Birthday",
startDate: { year: 1492, month: 8, day: 23 },
categories: ['birthday'],
conditionTree: {
type: 'group',
mode: 'and',
children: [
{ type: 'condition', field: 'month', op: '==', value: 8 },
{ type: 'condition', field: 'day', op: '==', value: 23 }
]
}
});

The type: 'group' field is required on the root — without it the tree is silently ignored and the note only fires on its exact startDate. Inside conditions, month and day values are 1-indexed (matching what you see in the UI), even though startDate.month / startDate.dayOfMonth are 0-indexed internally — the public API converts those for you.

[!WARNING] The legacy repeat field on noteData ('daily', 'weekly', 'monthly', 'yearly', etc.) is deprecated as of 1.0.0 and will be removed in 1.2.0. Express recurrence with conditionTree instead. Passing a deprecated repeat value will emit a Foundry compatibility warning.

Returns: Promise<object|null> - Created note page.


Update an existing note. GM only.

await CALENDARIA.api.updateNote('abc123', {
name: 'Rescheduled Meeting',
startDate: { year: 1492, month: 5, day: 16, hour: 14 }
});
ParameterTypeDescription
pageIdstringJournal entry page ID
updates.namestringNew note title
updates.startDateobjectNew start date
updates.endDateobjectNew end date
updates.allDaybooleanNew all-day setting
updates.conditionTreeobjectNew condition tree for recurrence
updates.categoriesstring[]New preset IDs
updates.iconstringNew icon
updates.colorstringNew color
updates.visibilitystringNew visibility: 'visible', 'hidden', 'secret'
updates.displayStylestringNew display style: 'icon', 'pip', 'banner'

Returns: Promise<object|null> - Updated note page.


Delete a calendar note.

await CALENDARIA.api.deleteNote('abc123');
ParameterTypeDescription
pageIdstringJournal entry page ID

Returns: Promise<boolean> - True if deleted successfully.


Delete all calendar notes. GM only.

await CALENDARIA.api.deleteAllNotes();

Returns: Promise<number> - Number of notes deleted.


Set a note’s visibility level.

await CALENDARIA.api.setNoteVisibility('abc123', 'hidden');
ParameterTypeDescription
pageIdstringJournal entry page ID
visibilitystring'visible', 'hidden', or 'secret'

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


Set a note’s display style.

await CALENDARIA.api.setNoteDisplayStyle('abc123', 'banner');
ParameterTypeDescription
pageIdstringJournal entry page ID
stylestring'icon', 'pip', or 'banner'

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


Open BigCal (or MiniCal) at a note’s date and open its sheet.

await CALENDARIA.api.navigateToNote('abc123');
ParameterTypeDescription
pageIdstringJournal entry page ID
options.contextstringForce target: 'bigcal' or 'minical' (auto-detects if omitted)

Returns: Promise<void>


Open a note in the UI.

await CALENDARIA.api.openNote('abc123', { mode: 'edit' });
ParameterTypeDescription
pageIdstringJournal entry page ID
options.modestring'view' or 'edit' (default: 'view')

Returns: Promise<void>


getNotesForDate(year, month, day, options)

Section titled “getNotesForDate(year, month, day, options)”

Get notes on a specific date.

const notes = CALENDARIA.api.getNotesForDate(1492, 5, 15);
// With full content:
const notes = CALENDARIA.api.getNotesForDate(1492, 5, 15, { includeContent: true });
ParameterTypeDescription
yearnumberDisplay year
monthnumberMonth (1-indexed)
daynumberDay of month (1-indexed)
options.includeContentbooleanInclude note HTML content in results (default: false)

Returns: object[] - Array of note stubs.


Get all notes in a month.

const notes = CALENDARIA.api.getNotesForMonth(1492, 5);
// With full content:
const notes = CALENDARIA.api.getNotesForMonth(1492, 5, { includeContent: true });
ParameterTypeDescription
yearnumberDisplay year
monthnumberMonth (1-indexed)
options.includeContentbooleanInclude note HTML content in results (default: false)

Returns: object[] - Array of note stubs.


getNotesInRange(startDate, endDate, options)

Section titled “getNotesInRange(startDate, endDate, options)”

Get notes within a date range.

const notes = CALENDARIA.api.getNotesInRange({ year: 1492, month: 5, day: 1 }, { year: 1492, month: 5, day: 31 });
// With full content:
const notes = CALENDARIA.api.getNotesInRange({ year: 1492, month: 5, day: 1 }, { year: 1492, month: 5, day: 31 }, { includeContent: true });
ParameterTypeDescription
startDateobjectStart date {year, month, day}
endDateobjectEnd date {year, month, day}
options.includeContentbooleanInclude note HTML content in results (default: false)

Returns: object[] - Array of note stubs.


Search notes by name or content.

const results = CALENDARIA.api.searchNotes('dragon', {
caseSensitive: false,
categories: ['quest']
});
ParameterTypeDescription
searchTermstringText to search for
options.caseSensitivebooleanCase-sensitive search (default: false)
options.categoriesstring[]Filter by category IDs

Returns: object[] - Array of note stubs.


Get notes with a specific preset (category).

const notes = CALENDARIA.api.getNotesByPreset('meeting');
ParameterTypeDescription
presetIdstringPreset ID

Returns: object[] - Array of note stubs.


Get all preset (category) definitions.

const presets = CALENDARIA.api.getPresets();

Returns: object[] - Array of preset definitions.


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><p><strong>Key Events</strong></p><p></p>'
}
});
ParameterTypeDescription
options.labelstringDisplay name (required)
options.colorstringHex color
options.iconstringFontAwesome icon class
options.defaultsobjectDefault values for notes created with this preset
options.defaults.allDaybooleanDefault all-day setting
options.defaults.displayStylestring'icon', 'pip', or 'banner'
options.defaults.visibilitystring'visible', 'hidden', or 'secret'
options.defaults.reminderTypestring'toast', 'chat', or 'dialog'
options.defaults.reminderOffsetnumberReminder offset in hours
options.defaults.hasDurationbooleanDefault multi-day setting
options.defaults.durationnumberDefault duration in days
options.defaults.macrostringMacro ID to execute
options.defaults.contentstringHTML content template pre-filled into new notes

Returns: Promise<object> - The created preset.


Update a note preset’s properties.

await CALENDARIA.api.updatePreset('session', {
defaults: { content: '<p><strong>Session Notes</strong></p><p></p>' }
});
ParameterTypeDescription
presetIdstringPreset ID
updates.labelstringNew display name
updates.colorstringNew hex color
updates.iconstringNew FontAwesome icon class
updates.playerUsablebooleanAllow non-GM users
updates.defaultsobjectDefault values (merged with existing)
updates.overridesobjectOverride values (merged with existing)

Returns: Promise<object|null> - Updated preset or null if not found.


Delete a custom note preset.

await CALENDARIA.api.deletePreset('my-custom-preset');
ParameterTypeDescription
presetIdstringPreset ID to delete

Returns: Promise<boolean> - True if deleted.


Search all content including notes and dates.

const results = CALENDARIA.api.search('council', {
searchContent: true,
limit: 10
});
ParameterTypeDescription
termstringSearch term (minimum 2 characters)
options.searchContentbooleanSearch note content
options.limitnumberMax results

Returns: object[] - Array of results with type field.


Create a condition object for use in a condition tree.

const condition = CALENDARIA.api.createCondition('weekday', '==', 0);
// Returns: { type: 'condition', field: 'weekday', op: '==', value: 0 }
ParameterTypeDescription
fieldstringCondition field (see conditionFields enum)
opstringComparison operator (see conditionOperators enum)
...values*Condition value(s). First is primary, second (if any) is secondary value

Returns: object - Condition {type: 'condition', field, op, value, value2?}.


createConditionGroup(mode, children, options)

Section titled “createConditionGroup(mode, children, options)”

Create a condition group for combining conditions with boolean logic.

const group = CALENDARIA.api.createConditionGroup('and', [CALENDARIA.api.createCondition('weekday', '==', 0), CALENDARIA.api.createCondition('month', '==', 5)]);
// Returns: { type: 'group', mode: 'and', children: [...] }
ParameterTypeDescription
modestring'and', 'or', 'nand', 'xor', or 'count'
childrenobject[]Array of condition objects and/or nested groups
options.thresholdnumberRequired match count for 'count' mode

Returns: object - Group {type: 'group', mode, children, threshold?}.


Check if a note occurs on a specific date by evaluating its condition tree.

const matches = CALENDARIA.api.evaluateNote('abc123', { year: 1492, month: 5, day: 15 });
// Silent evaluation (no hook):
const matches = CALENDARIA.api.evaluateNote('abc123', { year: 1492, month: 5, day: 15 }, { silent: true });
ParameterTypeDescription
pageIdstringJournal entry page ID
dateobjectDate to check {year, month (1-indexed), day (1-indexed)}
options.silentbooleanSkip firing the CONDITION_EVALUATED hook (default: false)

Returns: boolean - True if the note occurs on this date.

[!NOTE] The CONDITION_EVALUATED hook fires after evaluation unless silent is true. See Hooks.


Get the next N occurrences of a recurring note from the current date.

const dates = CALENDARIA.api.getNextOccurrences('abc123', 10);
// Returns: [{ year, month, day }, ...]
ParameterTypeDescription
pageIdstringJournal entry page ID
countnumberNumber of occurrences to find (default: 5)

Returns: object[] - Array of date objects {year, month (1-indexed), day (1-indexed)}.


getNoteOccurrencesInRange(pageId, startDate, endDate, maxOccurrences)

Section titled “getNoteOccurrencesInRange(pageId, startDate, endDate, maxOccurrences)”

Get all occurrences of a note within a date range.

const dates = CALENDARIA.api.getNoteOccurrencesInRange('abc123', { year: 1492, month: 1, day: 1 }, { year: 1493, month: 1, day: 1 });
ParameterTypeDescription
pageIdstringJournal entry page ID
startDateobjectRange start {year, month (1-indexed), day (1-indexed)}
endDateobjectRange end {year, month (1-indexed), day (1-indexed)}
maxOccurrencesnumberMaximum occurrences to return (default: 100)

Returns: object[] - Array of date objects {year, month (1-indexed), day (1-indexed)}.


Check whether a cinematic overlay is currently playing.

const active = CALENDARIA.api.isCinematicActive();

Returns: boolean - True if a cinematic is playing.


Play a cinematic overlay with a pre-built payload.

const payload = CALENDARIA.api.buildCinematicPayload(startTime, endTime);
await CALENDARIA.api.playCinematic(payload);
ParameterTypeDescription
payloadobjectCinematic payload (from buildCinematicPayload)

Returns: Promise<void> - Resolves when the cinematic completes or is aborted.


Abort the currently playing cinematic.

CALENDARIA.api.abortCinematic();

Returns: void


Build a cinematic payload without playing it. Used to prepare data for playCinematic().

const payload = CALENDARIA.api.buildCinematicPayload(game.time.worldTime, game.time.worldTime + 604800);
ParameterTypeDescription
startTimenumberStart world time (seconds)
endTimenumberEnd world time (seconds)

Returns: object - Cinematic payload with keyframes and settings.


Check whether Fog of War is enabled.

const enabled = CALENDARIA.api.isFogEnabled();

Returns: boolean


isDateRevealed(year, month, day, calendarId?)

Section titled “isDateRevealed(year, month, day, calendarId?)”

Check whether a specific date is revealed for the current user. GMs always get true. Returns true if fog is disabled.

CALENDARIA.api.isDateRevealed(1492, 6, 15);
CALENDARIA.api.isDateRevealed(1492, 6, 15, 'harptos');
ParameterTypeDescription
yearnumberYear
monthnumberMonth (1-indexed)
daynumberDay (1-indexed)
calendarIdstringCalendar ID (optional, defaults to active)

Returns: boolean


Get all revealed date ranges for a calendar.

const ranges = CALENDARIA.api.getRevealedRanges();
// [{ start: { year: 1492, month: 1, day: 1 }, end: { year: 1492, month: 6, day: 15 } }]
ParameterTypeDescription
calendarIdstringCalendar ID (optional, defaults to active)

Returns: Array<{start, end}> - Each with {year, month, day} (1-indexed).


Reveal a date range. GM only. Overlapping and adjacent ranges merge automatically.

await CALENDARIA.api.revealDateRange({ year: 1492, month: 1, day: 1 }, { year: 1492, month: 6, day: 15 });
ParameterTypeDescription
startobjectStart date {year, month (1-indexed), day (1-indexed)}
endobjectEnd date {year, month (1-indexed), day (1-indexed)}
calendarIdstringCalendar ID (optional, defaults to active)

Returns: Promise<void>


Clear all revealed ranges for a calendar. GM only.

await CALENDARIA.api.clearRevealedRanges();
ParameterTypeDescription
calendarIdstringCalendar ID (optional, defaults to active)

Returns: Promise<void>


Show a date picker dialog. Returns the selected date as a Promise, and optionally fires a callback.

const date = await CALENDARIA.api.showDatePicker({ showTime: true });
// Returns: { year, month, day, hour, minute } or null if cancelled
// With callback and positioning:
CALENDARIA.api.showDatePicker({
title: 'Select Date',
position: { x: 200, y: 300 },
onSelect: (date) => console.log('Selected:', date)
});
ParameterTypeDescription
options.dateobjectInitial date {year, month (1-indexed), day (1-indexed)} (defaults to current)
options.showTimebooleanShow time inputs (default: false)
options.titlestringCustom dialog 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.


All applications have show, hide, and toggle methods on the public API.

// BigCal
CALENDARIA.api.showBigCal();
CALENDARIA.api.hideBigCal();
CALENDARIA.api.toggleBigCal();
// MiniCal
CALENDARIA.api.showMiniCal();
CALENDARIA.api.hideMiniCal();
CALENDARIA.api.toggleMiniCal();
// HUD
CALENDARIA.api.showHUD();
CALENDARIA.api.hideHUD();
CALENDARIA.api.toggleHUD();
// TimeKeeper
CALENDARIA.api.showTimeKeeper();
CALENDARIA.api.hideTimeKeeper();
CALENDARIA.api.toggleTimeKeeper();
// Sun Dial
CALENDARIA.api.showSunDial();
CALENDARIA.api.showSunDial({ closeOnClickOutside: true });
CALENDARIA.api.hideSunDial();
CALENDARIA.api.toggleSunDial();
// Stopwatch
CALENDARIA.api.showStopwatch();
CALENDARIA.api.hideStopwatch();
CALENDARIA.api.toggleStopwatch();
// Chronicle
CALENDARIA.api.showChronicle();
CALENDARIA.api.showChronicle({ startDate, endDate, lockedRange: true, calendarId });
CALENDARIA.api.hideChronicle();
CALENDARIA.api.toggleChronicle();
// Note Viewer (supports pre-filter options)
CALENDARIA.api.showNoteViewer();
CALENDARIA.api.showNoteViewer({ date: { year: 1492, month: 5, day: 15 } });
CALENDARIA.api.showNoteViewer({ preset: 'meeting', search: 'dragon' });
CALENDARIA.api.showNoteViewer({ visibility: 'hidden' });
CALENDARIA.api.hideNoteViewer();
CALENDARIA.api.toggleNoteViewer();
// Secondary Calendar
CALENDARIA.api.showSecondaryCalendar('greyhawk');

Show the Chronicle with an optional locked date range.

ParameterTypeDescription
options.startDateobjectRange start {year, month (1-indexed), day (1-indexed)}
options.endDateobjectRange end {year, month (1-indexed), day (1-indexed)}
options.lockedRangebooleanLocks the view to startDate/endDate
options.calendarIdstringCalendar ID whose entries drive the view

Returns: Chronicle - The chronicle instance.

Show the Note Viewer with optional pre-filters.

ParameterTypeDescription
options.dateobjectPre-filter to date {year, month (1-indexed), day (1-indexed)}
options.presetstringPre-filter to preset ID
options.searchstringPre-filter with search term
options.visibilitystringPre-filter to visibility level

Returns: NoteViewer - The viewer instance.

CALENDARIA.api.startStopwatch(); // Show and start
CALENDARIA.api.pauseStopwatch(); // Pause if running
CALENDARIA.api.resetStopwatch(); // Reset to zero

Open the calendar editor. GM only.

await CALENDARIA.api.openCalendarEditor(); // New calendar
await CALENDARIA.api.openCalendarEditor('custom'); // Edit existing
ParameterTypeDescription
calendarIdstringCalendar ID to edit (omit for new)

Returns: Promise<object|null> - The editor application.


Get current weather state, optionally for a specific zone.

const weather = CALENDARIA.api.getCurrentWeather();
// With specific zone:
const weather = CALENDARIA.api.getCurrentWeather('desert');
// Returns: { id, label, icon, color, temperature, wind, precipitation, ... }
ParameterTypeDescription
zoneIdstringOptional zone ID (defaults to active scene’s zone)

Returns: object|null - Current weather state including wind { speed, direction, forced } and precipitation { type, intensity }.


Set weather by preset ID.

await CALENDARIA.api.setWeather('thunderstorm', { temperature: 65 });
// Set weather for a specific intraday period:
await CALENDARIA.api.setWeather('rain', { period: 'morning' });
// Set all periods at once:
await CALENDARIA.api.setWeather('snow', { allPeriods: true });
// Override wind and precipitation on top of the preset:
await CALENDARIA.api.setWeather('cloudy', {
temperature: 11,
wind: { speed: 2, direction: 'SW', forced: false },
precipitation: { type: null, intensity: 0 }
});
ParameterTypeDescription
presetIdstringWeather preset ID (e.g., 'clear', 'rain', 'thunderstorm')
options.temperaturenumberOptional temperature value
options.windobjectWind override { speed, direction, forced } (falls back to preset wind when omitted)
options.precipitationobjectPrecipitation override { type, intensity } (falls back to preset precipitation when omitted)
options.periodstringSpecific period to set when intraday is enabled ('night', 'morning', 'afternoon', 'evening')
options.allPeriodsbooleanSet all periods to this weather when intraday is enabled

Wind values: speed is an integer 0-5 (calm, light, moderate, strong, severe, extreme — see WIND_SPEEDS in scripts/constants.mjs). direction can be a number in degrees (0 = N, 90 = E, 180 = S, 270 = W), a 16-point compass string ('N', 'NNE', 'NE', …, 'NW', 'NNW'), or null. Strings are converted to degrees internally via COMPASS_DIRECTIONS — pass a number if you need precise rotation. forced is a boolean that locks the wind against generator inertia.

Precipitation values: type is null, 'drizzle', 'rain', 'snow', 'sleet', or 'hail'. intensity is a number in the range 0-1.

Returns: Promise<object> - The set weather.


Set custom weather with arbitrary values.

await CALENDARIA.api.setCustomWeather({
label: 'Magical Storm',
icon: 'fas fa-bolt',
color: '#9b59b6',
description: 'Arcane lightning crackles overhead',
temperature: 45
});
ParameterTypeDescription
weatherData.labelstringDisplay label
weatherData.iconstringFont Awesome icon class
weatherData.colorstringDisplay color
weatherData.descriptionstringDescription text
weatherData.temperaturenumberTemperature value

Returns: Promise<object> - The set weather.


Clear the current weather.

await CALENDARIA.api.clearWeather();

Returns: Promise<void>


Get the current intraday weather period based on the world clock.

const period = CALENDARIA.api.getCurrentWeatherPeriod();
// Returns: 'night', 'morning', 'afternoon', or 'evening'

Returns: string - Current period ID.


Get weather for a specific intraday period from the current day.

const weather = CALENDARIA.api.getWeatherForPeriod('morning');
// With specific zone:
const weather = CALENDARIA.api.getWeatherForPeriod('evening', 'desert');
ParameterTypeDescription
periodNamestringPeriod ID: 'night', 'morning', 'afternoon', 'evening'
zoneIdstringZone ID (defaults to active scene’s zone)

Returns: object|null - Weather data for the period, or null if intraday is disabled.


Generate and set weather based on climate and season.

await CALENDARIA.api.generateWeather();
await CALENDARIA.api.generateWeather({ climate: 'tropical', season: 'summer' });
ParameterTypeDescription
options.climatestringClimate override
options.seasonstringSeason override

Returns: Promise<object> - Generated weather.


Get a weather forecast for upcoming days.

const forecast = CALENDARIA.api.getWeatherForecast();
// With options:
const forecast = CALENDARIA.api.getWeatherForecast({ zoneId: 'desert', accuracy: 100 });
// Returns: [{ year, month, day, preset, temperature, wind, precipitation, isVaried }, ...]
ParameterTypeDescription
options.zoneIdstringZone to get forecast for (defaults to active scene’s zone)
options.accuracynumberOverride forecast accuracy (0–100). GMs default to 100
options.daysnumberNumber of days (defaults to Forecast Days setting)

Returns: object[] - Array of forecast entries. Each entry includes an isVaried flag indicating whether variance was applied. Forecast entries include a periods property only for GM users; non-GM users receive entries without period breakdown data.

Permission: Requires viewWeatherForecast permission for non-GM users.


getWeatherForDate(year, month, day, zoneId)

Section titled “getWeatherForDate(year, month, day, zoneId)”

Get recorded weather for a specific historical date.

const weather = CALENDARIA.api.getWeatherForDate(1492, 7, 15);
// With zone:
const weather = CALENDARIA.api.getWeatherForDate(1492, 7, 15, 'desert');
ParameterTypeDescription
yearnumberYear
monthnumberMonth (0-indexed)
daynumberDay of month (1-indexed)
zoneIdstringOptional zone ID (defaults to active zone)

Returns: object|null - Historical weather entry or null.


Get the full weather history, optionally filtered by zone.

const history = CALENDARIA.api.getWeatherHistory();
// Zone-filtered:
const history = CALENDARIA.api.getWeatherHistory({ zoneId: 'desert' });
ParameterTypeDescription
options.zoneIdstringOptional zone filter

Returns: object - Nested history structure.


Clear weather history entries. GM only. Also clears the forecast plan by default to prevent deleted entries from regenerating.

// Clear all history
await CALENDARIA.api.clearWeatherHistory({ all: true });
// Clear future entries only
await CALENDARIA.api.clearWeatherHistory({ future: true });
// Clear a specific year
await CALENDARIA.api.clearWeatherHistory({ year: 1492 });
// Clear a specific month (1-indexed)
await CALENDARIA.api.clearWeatherHistory({ year: 1492, month: 7 });
// Clear without resetting forecast plan
await CALENDARIA.api.clearWeatherHistory({ all: true, clearForecast: false });
ParameterTypeDescription
options.allbooleanClear all history
options.futurebooleanClear entries after the current date
options.yearnumberClear entries for a specific year
options.monthnumberClear entries for a specific month (1-indexed, requires year)
options.clearForecastbooleanClear the forecast plan (default: true)

Returns: Promise<number> - Number of entries removed.


Set a per-scene climate zone override.

await CALENDARIA.managers.WeatherManager.setSceneZoneOverride(game.scenes.active, 'tropical');
// Explicitly disable zone (No Zone):
await CALENDARIA.managers.WeatherManager.setSceneZoneOverride(game.scenes.active, null);
// Clear override (revert to calendar default):
await CALENDARIA.managers.WeatherManager.setSceneZoneOverride(game.scenes.active, undefined);

Note: This method is on WeatherManager, not on the public API object.

ParameterTypeDescription
sceneSceneScene document
zoneIdstring|null|undefinedZone ID, null for “No Zone”, or undefined to clear

Returns: Promise<void>


Check if a scene has explicitly disabled zone-based weather (“No Zone” selected).

const disabled = CALENDARIA.managers.WeatherManager.isZoneDisabled(game.scenes.active);

Note: This method is on WeatherManager, not on the public API object.

ParameterTypeDescription
sceneSceneScene document

Returns: boolean - True if the scene has “No Zone” set.


Invalidate cached environment overrides for a preset. Called internally by the Weather Editor after saving changes.

CALENDARIA.managers.WeatherManager.refreshEnvironmentOverrides('thunderstorm');

Note: This method is on WeatherManager, not on the public API object.

ParameterTypeDescription
presetIdstringWeather preset ID

Returns: void


resolveDisplayLabel(presetId, fallbackLabel, calendarId, zoneId)

Section titled “resolveDisplayLabel(presetId, fallbackLabel, calendarId, zoneId)”

Resolve the display label for a weather preset. Resolution priority: (1) per-zone alias from the Climate Editor, (2) name override from the Weather Editor, (3) localized fallback label. Useful for module developers who need to display weather names consistent with all override layers.

const label = CALENDARIA.managers.WeatherManager.resolveDisplayLabel('rain', 'Rain', 'harptos', 'desert');
// Returns: "Monsoon" (if aliased) or "Rain" (fallback)

Note: This method is on WeatherManager, not on the public API object.

ParameterTypeDescription
presetIdstringWeather preset ID
fallbackLabelstringDefault label if no alias is configured
calendarIdstringCalendar ID for alias lookup
zoneIdstringZone ID for alias lookup

Returns: string - Resolved display label.


Get the active climate zone.

const zone = CALENDARIA.api.getActiveZone();

Returns: object|null - Active zone config.


Set the active climate zone. Fires the calendaria.weatherChange hook and broadcasts the change to all connected clients, so weather displays update immediately.

await CALENDARIA.api.setActiveZone('desert');
ParameterTypeDescription
zoneIdstringClimate zone ID

Returns: Promise<void>


Get all available weather presets.

const presets = await CALENDARIA.api.getWeatherPresets();

Returns: Promise<object[]> - Array of weather presets.


Get all climate zones for the active calendar.

const zones = CALENDARIA.api.getCalendarZones();

Returns: object[] - Array of zone configs.


Add a custom weather preset.

await CALENDARIA.api.addWeatherPreset({
id: 'acid-rain',
label: 'Acid Rain',
icon: 'fas fa-skull',
color: '#2ecc71',
description: 'Corrosive precipitation',
tempMin: 10,
tempMax: 25,
wind: { speed: 1, direction: null },
precipitation: { type: 'rain', intensity: 0.6 },
inertiaWeight: 0,
hudEffect: 'rain-acid',
fxPreset: 'acid-rain',
soundFx: 'rain-acid-rain-blood-rain'
});
ParameterTypeDescription
preset.idstringUnique ID
preset.labelstringDisplay label
preset.iconstringIcon class
preset.colorstringDisplay color
preset.descriptionstringDescription
preset.tempMinnumberMin temperature (°C)
preset.tempMaxnumberMax temperature (°C)
preset.windobject{ speed, direction, forced }
preset.precipitationobject{ type, intensity }
preset.inertiaWeightnumberInertia multiplier (0–2)
preset.hudEffectstringHUD particle effect
preset.fxPresetstringFXMaster effect name
preset.soundFxstringSound loop filename

Returns: Promise<object> - The added preset.


Remove a custom weather preset.

await CALENDARIA.api.removeWeatherPreset('acid-rain');
ParameterTypeDescription
presetIdstringPreset ID to remove

Returns: Promise<boolean> - True if removed.


Get the current temperature for a zone.

const temp = CALENDARIA.api.getTemperature();
// With specific zone:
const temp = CALENDARIA.api.getTemperature('desert');
// Returns: { celsius, display, unit }
ParameterTypeDescription
zoneIdstringOptional zone ID (defaults to active scene’s zone)

Returns: object|null - Temperature data with celsius, display value, and unit.


Get a specific weather preset by ID.

const preset = CALENDARIA.api.getPreset('thunderstorm');
// Returns: { id, label, icon, color, description, tempMin, tempMax, wind, precipitation, ... }
ParameterTypeDescription
presetIdstringPreset ID (e.g., 'clear', 'rain', 'thunderstorm')

Returns: object|null - Preset definition or null if not found.


Update an existing custom weather preset. Only custom presets can be updated.

await CALENDARIA.api.updateWeatherPreset('acid-rain', {
label: 'Caustic Rain',
color: '#e74c3c',
tempMax: 30
});
ParameterTypeDescription
presetIdstringPreset ID to update
updatesobjectProperties to update (label, icon, color, etc.)

Returns: Promise<object|null> - Updated preset or null if not found.


Format a temperature value for display using the world’s temperature unit setting.

const display = CALENDARIA.api.formatTemperature(22);
// Returns: "72°F" (if unit is Fahrenheit) or "22°C" (if unit is Celsius)
ParameterTypeDescription
celsiusnumberTemperature in Celsius

Returns: string - Formatted temperature string.


Play a standalone weather sound effect with any Foundry audio path.

await CALENDARIA.api.playWeatherSound('sounds/rain-heavy.ogg');
ParameterTypeDescription
srcstringFoundry audio file path
optionsobjectAudio context override

Returns: Promise<boolean> - True if playback started.


Stop the currently playing weather sound with fade-out.

await CALENDARIA.api.stopWeatherSound();
await CALENDARIA.api.stopWeatherSound({ fade: 500 });
ParameterTypeDescription
options.fadenumberFade-out duration in ms (default: 2000)

Returns: Promise<boolean> - True if a sound was stopped.


Play an FXMaster weather preset. Uses exclusive mode (stops other presets). Requires FXMaster module.

await CALENDARIA.api.playWeatherFX('rain');
await CALENDARIA.api.playWeatherFX('snow', { density: 'heavy' });
ParameterTypeDescription
presetNamestringFXMaster preset name (e.g., 'rain', 'snow', 'fog')
options.densitystringParticle density
options.belowTokensbooleanRender below token layer

Returns: Promise<boolean> - True if FX started.


Stop all active FXMaster weather effects. Requires FXMaster module.

await CALENDARIA.api.stopWeatherFX();

Returns: Promise<boolean> - True if effects were stopped.


Get all available climate zone templates for creating new zones.

const templates = CALENDARIA.api.getClimateZoneTemplates();
// Returns array of template objects

Returns: Array<object> - Climate zone templates with id, name, temperatures, and weather weights.


Create a new climate zone on the active calendar. GM-only.

// Minimal: just a name
const zone = await CALENDARIA.api.createClimateZone({ name: 'Frozen Wastes' });
// Full config
const zone = await CALENDARIA.api.createClimateZone({
name: 'Frozen Wastes',
id: 'frozen-wastes',
description: 'A harsh frozen climate zone',
temperatures: { Winter: { min: -40, max: -10 }, Summer: { min: -20, max: 5 } },
presets: [],
seasonOverrides: {},
windSpeedRange: { min: 2, max: 5 },
windDirections: { N: 30, NE: 20, E: 10 },
brightnessMultiplier: 0.8,
environmentBase: { hue: 200, intensity: 0.3, luminosity: 0, saturation: -0.2, shadows: 0.5 },
environmentDark: { hue: 240, intensity: 0.5, luminosity: -0.5, saturation: -0.3, shadows: 0.8 },
shortestDay: 6,
longestDay: 18,
colorShift: { dawn: 30, dusk: 280, night: 240, transitionDuration: 1 }
});
ParameterTypeRequiredDescription
namestringYesZone display name
idstringNoZone ID (auto-generated from name if omitted). Must be unique
descriptionstringNoZone description text
temperaturesobjectNoTemperature ranges keyed by season name ({ 'Winter': { min, max } }). Defaults to { _default: { min: 10, max: 22 } }
presetsArray|objectNoWeather preset configurations
seasonOverridesobjectNoPer-season overrides
windSpeedRangeobjectNoWind speed range ({ min, max }, tiers 0-5)
windDirectionsobjectNoWind direction weights by cardinal direction
brightnessMultipliernumberNoScene darkness scaling (default: 1.0)
environmentBaseobjectNoBase (day) lighting overrides (hue, intensity, luminosity, saturation, shadows)
environmentDarkobjectNoDark (night) lighting overrides
shortestDaynumberNoManual shortest day hours override
longestDaynumberNoManual longest day hours override
colorShiftobjectNoTime-of-day color shift settings (dawn/dusk/night hue, transition duration)

Returns: Promise<object|null> - The created zone object, or null on failure.


Get the weather probability breakdown for a zone and season.

const data = CALENDARIA.api.getWeatherProbabilities();
const data = CALENDARIA.api.getWeatherProbabilities({ season: 'Winter' });
const data = CALENDARIA.api.getWeatherProbabilities({ zoneId: 'arctic', season: 'Summer' });
ParameterTypeDescription
zoneIdstringZone ID (defaults to active zone)
seasonstringSeason name (defaults to current season)

Returns: object with:

  • zone - { id, name } of the resolved zone
  • season - Localized season name
  • entries - Array of { id, label, icon, color, weight, percent } sorted by percent descending
  • tempRange - { min, max } in Celsius

Open the Weather Probability dialog.

CALENDARIA.api.openWeatherProbabilities();
CALENDARIA.api.openWeatherProbabilities({ season: 'Winter' });
ParameterTypeDescription
zoneIdstringInitial zone ID
seasonstringInitial season name

Returns: The dialog instance.


Check if a calendar is a bundled (built-in) calendar.

const isBundled = CALENDARIA.api.isBundledCalendar('harptos');
// Returns: true
const isBundled = CALENDARIA.api.isBundledCalendar('custom-mycal');
// Returns: false
ParameterTypeDescription
calendarIdstringCalendar ID to check

Returns: boolean - True if bundled calendar.


Check if current user is the primary GM (responsible for time saves and sync).

const isPrimary = CALENDARIA.api.isPrimaryGM();

Returns: boolean


Check if current user can modify time.

const canModify = CALENDARIA.api.canModifyTime();

Returns: boolean


Check if current user can create/edit notes.

const canManage = CALENDARIA.api.canManageNotes();

Returns: boolean


Individual permission checks are available on the CALENDARIA.permissions namespace. See Permissions for the full permission list and defaults.

Check if current user has a specific permission.

const canChange = CALENDARIA.permissions.hasPermission('changeDateTime');
ParameterTypeDescription
permissionstringPermission key

Permission Keys: viewBigCal, viewMiniCal, viewTimeKeeper, addNotes, editNotes, deleteNotes, changeDateTime, changeWeather, viewWeatherForecast, changeActiveCalendar, editCalendars

Returns: boolean


Check if current user can view the BigCal.

const canView = CALENDARIA.permissions.canViewBigCal();

Returns: boolean


Check if current user can view the MiniCal.

const canView = CALENDARIA.permissions.canViewMiniCal();

Returns: boolean


Check if current user can view the TimeKeeper.

const canView = CALENDARIA.permissions.canViewTimeKeeper();

Returns: boolean


Check if current user can create notes.

const canAdd = CALENDARIA.permissions.canAddNotes();

Returns: boolean


Check if current user can edit notes owned by other players.

const canEdit = CALENDARIA.permissions.canEditNotes();

Returns: boolean


Check if current user can delete notes.

const canDelete = CALENDARIA.permissions.canDeleteNotes();

Returns: boolean


Check if current user can modify date/time.

const canChange = CALENDARIA.permissions.canChangeDateTime();

Returns: boolean


Check if current user can change weather.

const canChange = CALENDARIA.permissions.canChangeWeather();

Returns: boolean


Check if current user can view weather forecasts.

const canView = CALENDARIA.permissions.canViewWeatherForecast();

Returns: boolean


Check if current user can switch the active calendar.

const canChange = CALENDARIA.permissions.canChangeActiveCalendar();

Returns: boolean


Check if current user can access the Calendar Editor.

const canEdit = CALENDARIA.permissions.canEditCalendars();

Returns: boolean


For external module integration. See Widgets for full documentation.

Available widget insertion points.

const points = CALENDARIA.api.widgetPoints;
// { HUD_BUTTONS_LEFT, HUD_BUTTONS_RIGHT, HUD_INDICATORS, HUD_TRAY, MINICAL_SIDEBAR, BIGCAL_ACTIONS }

Built-in indicator elements that can be replaced by widgets.

const elements = CALENDARIA.api.replaceableElements;
// { WEATHER_INDICATOR, SEASON_INDICATOR, ERA_INDICATOR, CYCLE_INDICATOR }

Register a custom widget.

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!')
});
ParameterTypeDescription
moduleIdstringYour module’s ID
configobjectWidget configuration

See Widgets for config options.


Get widgets registered at a specific point.

const widgets = CALENDARIA.api.getRegisteredWidgets('hud.buttons.right');
ParameterTypeDescription
insertPointstringWidget point ID

Returns: array - Registered widget configs.


Get widget that replaces a built-in element.

const widget = CALENDARIA.api.getWidgetByReplacement('weather-indicator');
ParameterTypeDescription
elementIdstringReplaceable element ID

Returns: object|null - Widget config or null.


Force all widgets to re-render.

CALENDARIA.api.refreshWidgets();

Read-only enum getters for building conditions, setting display styles, and managing visibility.

Get the available condition fields for use with createCondition().

const fields = CALENDARIA.api.conditionFields;
// { MONTH: 'month', WEEKDAY: 'weekday', SEASON: 'season', MOON_PHASE: 'moonPhase', ... }

Returns: object - CONDITION_FIELDS enum (45 fields).


Get the available condition operators.

const ops = CALENDARIA.api.conditionOperators;
// { EQUAL: '==', NOT_EQUAL: '!=', GREATER: '>', LESS: '<', MODULO: '%', DAYS_AGO: 'daysAgo', ... }

Returns: object - CONDITION_OPERATORS enum (11 operators).


Get the available condition group modes.

const modes = CALENDARIA.api.conditionGroupModes;
// { AND: 'and', OR: 'or', NAND: 'nand', XOR: 'xor', COUNT: 'count' }

Returns: object - CONDITION_GROUP_MODES enum.


Get the available note display styles.

const styles = CALENDARIA.api.displayStyles;
// { ICON: 'icon', PIP: 'pip', BANNER: 'banner' }

Returns: object - DISPLAY_STYLES enum.


Get the available note visibility levels.

const levels = CALENDARIA.api.noteVisibility;
// { VISIBLE: 'visible', HIDDEN: 'hidden', SECRET: 'secret' }

Returns: object - NOTE_VISIBILITY enum.


Get all available Calendaria hook name constants. See Hooks for full documentation, parameters, and examples.

const hooks = CALENDARIA.api.hooks;
// Use: Hooks.on(hooks.DAY_CHANGE, (data) => { ... });

Returns: object - Hook name constants (e.g., DAY_CHANGE, WEATHER_CHANGE, CLOCK_START_STOP).


Fires after note condition evaluation via the evaluateNote() API method (unless silent is true).

Hooks.on(CALENDARIA.api.hooks.CONDITION_EVALUATED, (pageId, date, result) => {
console.log(`Note ${pageId} on ${date.year}-${date.month}-${date.day}: ${result}`);
});
ParameterTypeDescription
pageIdstringJournal entry page ID
dateobjectDate that was evaluated
resultbooleanWhether the note matched the date