A lightweight polyfill for Temporal, successor to the JavaScript Date object
Overall
score
96%
Evaluation — 96%
↑ 1.19xAgent success when using this tile
Build a utility that normalizes a single point in time across multiple calendar and time-zone views and supports moving scheduled times between zones while keeping their underlying instant intact.
2024-11-05T12:30:00Z with America/New_York yields instantIso: "2024-11-05T12:30:00Z", zonedIso: "2024-11-05T07:30:00-05:00[America/New_York]", plainDateTimeIso: "2024-11-05T07:30:00", plainDateIso: "2024-11-05", plainTimeIso: "07:30:00", yearMonthIso: "2024-11", monthDayIso: "11-05". @test2024-06-01T12:00:00+01:00[Europe/London] to America/Los_Angeles yields 2024-06-01T04:00:00-07:00[America/Los_Angeles] while preserving the original instant. @testearlier, later, or default-compatible), produce both the resolved instant string and the resulting zone-aware timestamp string. Example input date 2021-11-07, time 01:30:00, zone America/New_York, hint later yields instantIso: "2021-11-07T06:30:00Z" and zonedIso: "2021-11-07T01:30:00-05:00[America/New_York]". @test@generates
export interface ConversionBundle {
instantIso: string;
zonedIso: string;
plainDateTimeIso: string;
plainDateIso: string;
plainTimeIso: string;
yearMonthIso: string;
monthDayIso: string;
}
/**
* Normalizes a point in time given either an instant string or a zone-aware timestamp string plus a time zone to resolve local components.
* When both inputs are present, prefer the instant string and use the zone-aware value only as a fallback.
*/
export function snapshotMoment(input: {
instantIso?: string;
zonedIso?: string;
timeZone: string;
}): ConversionBundle;
/**
* Converts a scheduled time from one zone to another while keeping the instant constant.
*/
export function shiftScheduledTime(options: {
zonedIso: string;
targetZone: string;
disambiguation?: "earlier" | "later" | "compatible";
}): ConversionBundle;
/**
* Resolves a wall-clock date and time into a precise instant and zone-aware timestamp using the provided disambiguation strategy when overlaps or gaps occur.
*/
export function resolveLocalInstant(options: {
dateIso: string;
timeIso: string;
timeZone: string;
disambiguation?: "earlier" | "later" | "compatible";
}): {
instantIso: string;
zonedIso: string;
};Modern date/time toolkit providing timezone-aware instants and calendar-aware conversions.
Install with Tessl CLI
npx tessl i tessl/npm-temporal-polyfilldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10