CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-temporal-polyfill

A lightweight polyfill for Temporal, successor to the JavaScript Date object

Overall
score

96%

Evaluation96%

1.19x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-10/

Time Zone Snapshot

Build a small utility that captures the present moment in a caller-specified IANA time zone using the dependency's time-zone-aware clock factories.

Capabilities

Capture current moment in a chosen zone

  • Given a time zone identifier like "Europe/Paris", produce four ISO strings that describe the same moment: an absolute instant with a Z suffix, a zone-aware date-time that includes the numeric offset and bracketed zone name, a date string, and a time string. The zone-aware string must reflect the provided identifier (not the system default), and the date/time strings must match the date-time portion of that zone-aware value. @test

Support deterministic clock overrides

  • When overrides provide fixed functions for the instant, zone-aware date-time, date, and time, the snapshot should use those values instead of sampling the real clock, allowing repeatable results in tests. @test

Reject invalid input early

  • Supplying an unknown or blank time zone identifier should raise a descriptive error before any clock sampling occurs. @test

Implementation

@generates

API

export interface ClockOverrides {
  getInstant?: () => unknown;
  getZonedDateTime?: (timeZoneId: string) => unknown;
  getPlainDate?: (timeZoneId: string) => unknown;
  getPlainTime?: (timeZoneId: string) => unknown;
}

export interface Snapshot {
  instant: string;
  zonedDateTime: string;
  date: string;
  time: string;
}

/**
 * Capture the current moment for the requested IANA time zone.
 * When overrides are absent, use the dependency's time-zone-aware clock factories instead of manual date math or system defaults.
 * All four values must describe the same moment so their date/time fields agree with each other and with the provided zone identifier.
 */
export function captureCurrentSnapshot(timeZoneId: string, overrides?: ClockOverrides): Snapshot;

Dependencies { .dependencies }

temporal-polyfill { .dependency }

Provides time-zone-aware clock factories and Temporal types.

Install with Tessl CLI

npx tessl i tessl/npm-temporal-polyfill

tile.json