UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

38 lines • 1.92 kB
import { Temporal } from "../temporal.js"; /** * The part of a host's `Temporal` this module reads: the `ZonedDateTime` constructor, whose * `equals` applies the host's own TimeZoneEquals. Everything else on the host is ignored. */ export interface HostTemporal { ZonedDateTime?: new (epochNanoseconds: bigint, timeZone: string) => { equals(other: unknown): unknown; }; } /** * TimeZoneEquals for two identifiers as the host's own `Temporal` answers it, or `undefined` when * the host has no `Temporal.ZonedDateTime`, it throws for either identifier, or its `equals` * returns something other than a boolean. * * @param host the host's `Temporal` namespace, or `undefined` when it has none * @param one a time zone identifier * @param two a time zone identifier * @returns the host's answer, or `undefined` when it cannot be had */ export declare function timeZoneEqualsByHost(host: HostTemporal | undefined, one: string, two: string): boolean | undefined; /** * Whether two zoned values are in the same time zone by TC39 TimeZoneEquals: the same * identifier, or two identifiers with one primary identifier (`UTC` and `Etc/UTC`, * `Asia/Kolkata` and `Asia/Calcutta`). * * The polyfill's `ZonedDateTime#equals` answers it, except where probe D19 fails: there the * polyfill cannot find a non-primary identifier's primary. GMT then resolves the names ECMA-402 * §6.5 sends to `"UTC"` itself, which needs no time zone data, and asks the host's own `Temporal` * for any other pair. With no host `Temporal` (Safari 27) the polyfill's answer stands for the * IANA links such as `Asia/Calcutta`: no Intl API there names their primary identifier * (temporalCompat README, D19). * * @param one a zoned value * @param two a zoned value * @returns true when the two time zones are one */ export declare function timeZoneEquals(one: Temporal.ZonedDateTime, two: Temporal.ZonedDateTime): boolean;