DateCalendar
Defined in: packages/engine/src/calendar/DateCalendar.ts:27
The default CalendarBackend: the JavaScript Date object, read in
the host process’s time zone, with Intl.DateTimeFormat for named zones.
This is the calendar code the engine has always run, moved behind the
interface method by method rather than rewritten, so a host that configures
nothing sees the same instants and the same strings it did before the
backend existed. Where Date has a quirk (a two-digit year in a
constructor maps to the 1900s, an out-of-range instant answers NaN), the
quirk is kept here deliberately: the point of this backend is to be the
behaviour the Temporal backend is measured against, not to improve on it.
It stays the default because it is the one calendar every supported runtime
has. Temporal ships unflagged in Node 26 and in current Chrome, Firefox
and Deno, but not in Safari or in the Node 22 and 24 the engine supports,
and the smallest polyfill adds about twenty kilobytes gzipped to a bundle
that a host doing plain arithmetic never needs. A host that wants
Temporal opts in through the engine’s calendar option with the backend
from solve-engine/temporal, and pays for it only then.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DateCalendar(): DateCalendar;Returns
Section titled “Returns”DateCalendar
Methods
Section titled “Methods”addDays()
Section titled “addDays()”addDays(epochMs, days): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:58
Move an instant by whole calendar days, holding the local wall-clock time. A day that contains a daylight-saving transition is 23 or 25 hours long, so this is a field step, not an addition of milliseconds.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
epochMs | number |
days | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”addMonths()
Section titled “addMonths()”addMonths(epochMs, months): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:64
Move an instant by whole calendar months, holding the local wall-clock time and clamping the day to the length of the month landed in: 31 January plus a month is 28 February, or 29 in a leap year, never 3 March.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
epochMs | number |
months | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”fields()
Section titled “fields()”fields(epochMs): CalendarFields;Defined in: packages/engine/src/calendar/DateCalendar.ts:32
The local calendar fields of an instant, weekday included. See CalendarFields.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
epochMs | number |
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”fieldsInZone()
Section titled “fieldsInZone()”fieldsInZone(zone, epochMs): ZonedFields;Defined in: packages/engine/src/calendar/DateCalendar.ts:106
The calendar date and wall-clock time a named IANA zone shows for an
instant. Throws the runtime’s RangeError for a zone it does not know or
an instant it cannot represent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
zone | string |
epochMs | number |
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”formatDateInZone()
Section titled “formatDateInZone()”formatDateInZone(zone, epochMs): string;Defined in: packages/engine/src/calendar/DateCalendar.ts:114
The calendar date in a named IANA zone, July 31, 2026, in the en-US
style the timezone forms answer in. Throws the runtime’s RangeError for
a zone it does not know or an instant it cannot represent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
zone | string |
epochMs | number |
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”CalendarBackend.formatDateInZone
formatLongDate()
Section titled “formatLongDate()”formatLongDate(epochMs, locale): string;Defined in: packages/engine/src/calendar/DateCalendar.ts:89
The spelled-out local date in a locale, Tuesday, March 10, 2026 in en.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
epochMs | number |
locale | string |
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”CalendarBackend.formatLongDate
formatTimeInZone()
Section titled “formatTimeInZone()”formatTimeInZone(zone, epochMs): string;Defined in: packages/engine/src/calendar/DateCalendar.ts:110
The wall-clock time in a named IANA zone, 1:00 AM, in the en-US style
the timezone forms answer in. Throws the runtime’s RangeError for a
zone it does not know or an instant it cannot represent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
zone | string |
epochMs | number |
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”CalendarBackend.formatTimeInZone
formatTimeOfDay()
Section titled “formatTimeOfDay()”formatTimeOfDay(epochMs, locale): string;Defined in: packages/engine/src/calendar/DateCalendar.ts:93
The local time of day in a locale, 9:30:00 AM in en.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
epochMs | number |
locale | string |
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”CalendarBackend.formatTimeOfDay
localMidnight()
Section titled “localMidnight()”localMidnight( year, month0, day): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:46
Local midnight on a calendar date, in epoch milliseconds.
Fields overflow the way Date’s do (month 12 is January of the next
year, day 0 the last day of the month before), which is what a caller
checking for a rolled-over literal relies on: build the date, read its
fields back, and a 30 February shows up as 1 or 2 March.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
year | number |
month0 | number |
day | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”localWallClock()
Section titled “localWallClock()”localWallClock( year, month0, day, minutesPastMidnight): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:50
A wall-clock time on a calendar date, given as minutes past local midnight, in epoch milliseconds.
The minutes name a clock reading, not an elapsed span: 540 minutes is 09:00 on that date even on a day with a daylight-saving transition, where 540 minutes of elapsed time from midnight would land at 10:00 or 08:00.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
year | number |
month0 | number |
day | number |
minutesPastMidnight | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”CalendarBackend.localWallClock
now(): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:28
The current instant, in epoch milliseconds. Read at evaluation time, never baked into bytecode.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”parseIso8601()
Section titled “parseIso8601()”parseIso8601(text): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:85
Parse an ISO 8601 date or date-time string to epoch milliseconds, or
NaN when it names no instant.
A date-only string (2019-04-01) is UTC midnight; a date-time with no
offset and no Z is local time. Both readings are the ECMAScript ones,
and every backend reproduces them so the two spellings of a literal keep
meaning the same instant whichever backend is in use.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
text | string |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”utcOffsetMinutes()
Section titled “utcOffsetMinutes()”utcOffsetMinutes(epochMs): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:77
The local zone’s offset from UTC at an instant, in minutes, positive when ahead of UTC.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
epochMs | number |
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”CalendarBackend.utcOffsetMinutes
zoneOffsetMinutes()
Section titled “zoneOffsetMinutes()”zoneOffsetMinutes(zone, epochMs): number;Defined in: packages/engine/src/calendar/DateCalendar.ts:97
A named IANA zone’s offset from UTC at an instant, in minutes, positive
when ahead of UTC. Throws the runtime’s RangeError for a zone it does
not know or an instant it cannot represent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
zone | string |
epochMs | number |
Returns
Section titled “Returns”number