ECMAScript Temporal
Temporal is the TC39 date and time API for JavaScript: a Temporal namespace (like Math) with immutable types for exact time, wall-clock time, time zones, calendars and durations. It reached stage 4 in March 2026 and is expected in ECMAScript 2027. With this skill the agent writes new date and time code against Temporal, reviews it, and migrates Date and older Temporal polyfill code.
Follow the workflow below step by step. Every rule here comes from a source in Sources, with the section it cites. Section numbers (§ 6.3.37) refer to the Temporal spec draft pinned in Sources. When a rule and the pinned source disagree, the source wins; when the source has a newer revision than the pin, follow the refresh steps.
Inputs (fill in, or ask before starting)
- Role: writing new code, reviewing code, or migrating code (from
Date, from a date library, or from an older Temporal polyfill). - Target version: Temporal (ECMAScript 2027) (default, posture build: write against the stage 4 spec; it is not yet merged into the ECMA-262 draft). ECMAScript Date and the Temporal pre-reduction polyfill API are legacy: read them and upgrade from them, never write new code against them. No preview exists. See
references/versions.md. - Revision: the pinned revision in Sources, unless the user names another.
- Sources: when refreshing this skill or when a rule looks out of date, re-read every URL in Sources first, check
finished-proposals.mdand the ECMA-262 draft for the merge of Temporal, and update the pins. - Runtime: whether the target engines ship
Temporalnatively or need a polyfill, and which polyfill version. - Data: what each value means (an exact moment, a wall-clock reading in a known place, a date with no time zone, a recurring month and day), where its time zone comes from, and the string formats exchanged with other systems.
Invariants
- Pick the type from what the value means (§ 3 to § 10; docs README).
Instantis an exact time with no time zone or calendar;ZonedDateTimeis an exact time in a time zone and calendar; thePlaintypes have no time zone. Never store a wall-clock value as anInstant, or an exact time as aPlainDateTime. - Temporal objects are immutable (docs README).
with,add,roundand the other methods return a new object; assign the result. - Compare with
compare()andequals(), never with<,>or==(§ 3.3.33, § 6.3.44, § 7.3.25).valueOf()throws aTypeErroron every Temporal type. compare()andequals()answer different questions (§ 3.2.3, § 3.3.27, § 6.2.3, § 6.3.40).ZonedDateTime.compareuses only the exact time andPlainDate.compareonly the ISO date;equalsalso requires the same calendar, and forZonedDateTimethe same time zone.- Wall-clock to exact time goes through
disambiguation(§ 11.1.12, § 13.7). The default iscompatible: a skipped time moves forward by the gap and a repeated time takes the earlier instant. Userejectwhere a nonexistent or ambiguous local time must be an error. - An offset that conflicts with the time zone is an error when parsing (§ 6.5.2, § 13.9).
ZonedDateTime.fromdefaultsoffsettoreject;withdefaults it toprefer(§ 6.3.31). Chooseuseorignoredeliberately when stored strings may predate a time zone rule change. - Time zones and calendars are string identifiers (§ 11.1.8, § 12.1, § 14.6.2). Use IANA names (
"Europe/Amsterdam","UTC") or minute-precision offsets ("+05:30");"iso8601"is the only calendar every implementation must support. There are noTemporal.TimeZoneorTemporal.Calendarobjects. - Calendar units need a reference point (§ 7.3.20, § 7.3.21, § 7.2.3, § 7.5.41).
Duration.round,totalandcompareneedrelativeTowhen years, months or weeks are involved;Duration.addandsubtractthrow aRangeErrorfor them. ZonedDateTimearithmetic adds the date part in calendar days and the time part in exact time (§ 6.5.5). One day across a DST change is 23 or 25 hours;{ hours: 24 }is always 24 hours.- Differences use defaults per type (§ 13.43).
largestUnitdefaults todayforPlainDateandPlainDateTime,hourforPlainTimeandZonedDateTime,secondforInstant,yearforPlainYearMonth;roundingModedefaults totrunc.ZonedDateTime.untilwith a date unit needs both objects in the same time zone, and every difference needs the same calendar (§ 6.5.9). - Strings follow RFC 9557 with Temporal's restrictions (§ 13.31, § 13.35). A
ZonedDateTimestring needs a bracketed time zone annotation; anInstantstring needsZor an offset;Plaintypes rejectZ. An unknown annotation marked critical (!) throws aRangeError. Intl.DateTimeFormatdoes not formatZonedDateTime(§ 15.6.22). UsezonedDateTime.toLocaleString(), which formats in the object's own time zone (§ 15.11.8.1). A non-ISO calendar on aPlainvalue must match the formatter's calendar (§ 15.6.15 to § 15.6.19).
Workflow
- Pick the version. Write against the current line unless the runtime only has an older polyfill; then plan the upgrade.
->
references/versions.md✓ The target version is recorded, and no legacy API (Temporal.Calendar, Temporal.TimeZone,getISOFields,withPlainDate,epochSeconds) is in new code. - Model each value with one type. Map every date and time field in the data to a Temporal type and record where its time zone and calendar come from.
->
references/types.md✓ Every value has a type, exact times carry a time zone only when local wall-clock behaviour matters, andTemporal.Nowcalls name the time zone on servers. - Handle time zones, DST and calendars. Choose
disambiguationandoffsetfor each conversion, and validate external calendar input. ->references/time-zones-and-calendars.md✓ Every wall-clock to exact-time conversion has a chosendisambiguation, every parse of a storedZonedDateTimestring has a chosenoffset, and calendars are compared or converted explicitly. - Write the arithmetic. Use
add,subtract,until,since,roundandtotalwith explicit units. ->references/arithmetic-and-rounding.md✓ Every difference setslargestUnit(andsmallestUnitandroundingModewhen rounding), and every duration with calendar units is rounded or totalled withrelativeTo. - Parse, serialize and format. Exchange RFC 9557 or RFC 3339 strings; format for people with
toLocaleStringorIntl.DateTimeFormat. ->references/parsing-and-migration.md✓ Round-trips throughtoString()andfrom()return an equal value, and no code parses localized strings. - Upgrade (only when asked). Replace
Datecode, or polyfill-era Temporal code, following the upgrade steps for the source line. ->references/versions.md,references/parsing-and-migration.md✓ The upgraded code produces the same exact times and wall-clock values as before on the test cases, including a DST gap and a DST overlap.
Verify before done
- No Temporal value is compared with
<,>,==or===, sorted withoutcompare, or used where a number is expected. - Every
PlainDateTime.toZonedDateTime,ZonedDateTime.fromandwithcall that can hit a DST transition has a deliberatedisambiguation, andfromon stored strings a deliberateoffset. - Every
Duration.round,totalorcompareover years, months or weeks passesrelativeTo. - Every difference sets
largestUnitwhen the default for its type is not what the caller wants. - Strings parsed into
Plaintypes have noZ;ZonedDateTimestrings carry a[time zone]annotation. -
ZonedDateTimevalues are formatted withtoLocaleString, not passed toIntl.DateTimeFormat.prototype.format. - No removed pre-2024 API is used;
calendarIdandtimeZoneIdare read instead ofcalendarandtimeZoneobjects. - Conversions to
Datego throughepochMillisecondsand note the loss of sub-millisecond precision.
Reference index
references/versions.md: the three version lines with status, which to use, what changed, and upgrade steps fromDateand from pre-reduction polyfills. Load for steps 1 and 6.references/types.md: each type, its fields and conversions,Temporal.Now, constructors versusfrom, and comparison. Load for step 2.references/time-zones-and-calendars.md: time zone identifiers, DSTdisambiguationandoffsetoptions, transitions, calendars and month codes. Load for step 3.references/arithmetic-and-rounding.md:add,subtract,until,since,round,total, units, rounding modes, balancing and duration limits. Load for step 4.references/parsing-and-migration.md: RFC 9557 and RFC 3339 strings,toStringoptions,Intl.DateTimeFormat, andDatemigration recipes. Load for steps 5 and 6.
Related skills
For localized messages that embed formatted dates and times, use the messageformat skill: npx skills add ScaleDockHQ/scaledock-skills --skill messageformat.
Sources
Status uses the publishing body's own maturity term. Checked is the date the source was last read.
- Temporal proposal specification: Stage 4 Draft, July 27, 2026, checked 2026-10-05.
- Temporal documentation: proposal documentation and cookbook, main branch at commit e8cc03f (2026-07-27), checked 2026-10-05.
- Temporal cookbook: proposal documentation, main branch at commit e8cc03f (2026-07-27), checked 2026-10-05.
- tc39/proposal-temporal: Stage 4, README at commit e8cc03f (2026-07-27), checked 2026-10-05.
- TC39 finished proposals: Temporal finished, expected publication year 2027, commit ee92ecf (2026-09-29), checked 2026-10-05.
- ECMA-262 draft: Draft ECMAScript 2027, October 3, 2026, does not yet contain Temporal, checked 2026-10-05.
- ECMAScript 2026 Language Specification: ECMAScript 2026, 17th edition, used for the Date line, checked 2026-10-05.
- ecma262 pull request #3966: Temporal stage 4, round 2: open, updated 2026-09-24, checked 2026-10-05.
- Temporal proposal polyfill changelog: changelog up to 0.9.0, main branch at commit e8cc03f, checked 2026-10-05.
- @js-temporal/polyfill changelog: changelog, 0.5.0 (TC39 changes from May 2023 to March 2025), checked 2026-10-05.
- TC39 meeting notes, 12 June 2024: Temporal stage 3 update and scope reduction, checked 2026-10-05.
- RFC 9557: Date and Time on the Internet: Timestamps with Additional Information: Proposed Standard, April 2024, checked 2026-10-05.
- RFC 3339: Date and Time on the Internet: Timestamps: Proposed Standard, July 2002, updated by RFC 9557, checked 2026-10-05.