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.

131 lines • 8.13 kB
import { DefectId, ProbeRepro } from "./probeRepros.js"; /** The repro's output, or `ERR <name>: <message>` when it throws. */ export declare function runRepro(repro: Pick<ProbeRepro, "run">): string; /** True when a repro's output is the spec-correct value, i.e. the installed runtime is fixed. */ export declare function reproPasses(repro: Pick<ProbeRepro, "expected">, output: string): boolean; /** * True when any of `candidates` for this defect and Temporal calendar id fails. Stops at the first * failure, so the order of a defect's repros is the order they are tried in. */ export declare function anyReproFails(candidates: readonly (Omit<ProbeRepro, "defect"> & { defect: string; })[], defect: DefectId, calendar: string): boolean; /** * True when any repro for this defect and Temporal calendar id fails in the installed runtime. * A calendar with no repro for the defect is not affected by it. */ export declare function isDefectPresent(defect: DefectId, calendar: string): boolean; /** * True when this runtime never retries the calendar nudge window (defect D11). * * TC39 bounds a duration between `relativeTo + r1 units` and `relativeTo + r2 units`, and recomputes * the window one unit further along when the target falls outside it. A runtime that computes the * window once answers `Duration#total`, `Duration#round` and `until`/`since` with a calendar * `smallestUnit` over the wrong bounds. Only a `relativeTo` on the 29th, 30th or 31st can reach it, * because only there does adding a month constrain the day. ISO-only: the non-ISO calendars already * take the spec path through `isCalendarArithmeticCompatNeeded`. */ export declare function isNudgeWindowCompatNeeded(): boolean; /** * True when this runtime mismeasures from either pass of a repeated hour (defect D22). * * TC39 `ComputeNudgeWindow` takes the window's start from the origin's own exact time when no unit * has been added, and `DifferenceZonedDateTime` subtracts the exact times when both fall on one local * date. A runtime that turns the wall clock back into an exact time with `"compatible"` moves a * later-pass origin an hour early, and one with no same-date branch backs up a day from an earlier-pass * origin when the end falls in the later pass at a lower wall clock. So `Duration#total` in a date unit, * and `Duration#round` and `until` with a date `largestUnit`, answer from an instant the caller never * named. tc39/ecma262#3759 commit `1f4e6717ef23` decides when the window starts at the origin: an * empty start duration, not `r1 = 0`. */ export declare function isNudgeOriginCompatNeeded(): boolean; /** * True when this runtime matches a zoned string's offset by minutes even when the offset is * written with seconds (defect D12). * * TC39 `ToTemporalZonedDateTime` matches by minutes only an offset with no seconds part; one * written with seconds must equal the zone's offset exactly. A runtime that always matches by * minutes accepts `-00:45:00[Africa/Monrovia]` for a zone at −00:44:30, and picks the wrong pass * of a second repeated by a sub-minute transition (Pacific/Niue, 1952). */ export declare function isSecondsOffsetMatchCompatNeeded(): boolean; /** * True when this runtime's time zone transition search cannot be trusted (defect D13). * * TC39 `GetNamedTimeZoneNextTransition` returns the first offset change after an instant. A runtime * that samples the offset in steps longer than the gap between two changes skips a pair that * returns to the same offset, and can loop for ever on three different offsets in one step. The * skipped-pair repros come first and none of them can stall, so on such a runtime the probe * answers before a stalling repro is reached. Every repro has to pass for the workaround to go * dormant: a runtime that fixes the skipped pairs and still stalls on one zone keeps it. */ export declare function isTransitionSearchCompatNeeded(): boolean; /** * True when this runtime rounds to the day wrongly where a date starts twice (defect D14). * * A fall-back across midnight re-enters a date after the next date has started, as * America/Goose_Bay did on 2010-11-06, and America/Sitka on 1867-10-18. TC39 * `ZonedDateTime#round` clamps an instant in the second piece of that date to the end of the date * (tc39/ecma262#3966, commit 5f44331e0a11; test262 `same-date-starts-twice.js`). A runtime without * that change answers the next date for `floor` and `trunc`, and in some zones (Sitka 1867) for the * half modes, `ceil` and `expand` too, or throws. */ export declare function isDayRoundClampCompatNeeded(): boolean; /** * True when this runtime applies `offset: "ignore"` to a `Z` string (defect D15). * * TC39 `ToTemporalZonedDateTime` reads a `Z` string as an exact instant under every `offset` * option; `InterpretISODateTimeOffset` applies `ignore` only to an offset written as an option. A * runtime that ignores the `Z` and reads the wall clock in the zone returns a different instant * whenever the zone's offset is not zero. */ export declare function isZIgnoreExactCompatNeeded(): boolean; /** * True when this runtime's `formatRange` changes the `timeZoneName` width of a range (defect D16). * * UTS #35 (Matching Skeletons) expects "fields in the skeleton and pattern ... to be adjusted in * parallel", so the range pattern chosen for a `timeZoneName: "long"` skeleton keeps a long zone * name; ECMA-402 §11.5.8 builds each range part with FormatDateTimePattern over the range * pattern's own fields, so it prints what that pattern holds. ICU-20548 makes `DateIntervalFormat` * cut `long` and `longGeneric` to short names and drop `shortOffset` and `longOffset`. The probe * runs once per style, on the first call for it. A style with no repro (an unknown one) is not * affected, and is not cached, so a caller passing arbitrary text cannot grow the cache. */ export declare function isRangeZoneNameCompatNeeded(style: string): boolean; /** * True when this runtime's `formatRange` writes the AM/PM day period where `dayPeriod` asks for a * flexible one, with a `timeZoneName` set (defect D17). * * Not a width rule (UTS #35 treats a, b and B as close matches). ECMA-402 §11.5.8 picks the range * pattern by the resolved [[HourCycle]] only: en-US resolves to h12 whether `hourCycle: "h12"` is * given or omitted, yet SpiderMonkey (Firefox 155) prints the flexible period for the first and * AM/PM for the second. Identical resolved options give two range outputs, and GMT's contract is * that a range keeps the fields the caller asked for. */ export declare function isRangeDayPeriodCompatNeeded(): boolean; /** * True when this runtime's `ZonedDateTime#equals` answers false for two identifiers of one time * zone (defect D19). * * ECMA-262 TimeZoneEquals compares the two [[PrimaryIdentifier]]s, and ECMA-402 §6.5 fixes * `"UTC"` as primary and `"Etc/UTC"` as a non-primary identifier that resolves to it. The polyfill * finds a non-primary identifier's primary through `Intl.DateTimeFormat#resolvedOptions`, which * JavaScriptCore returns as written, so `Etc/UTC` and `UTC` compare unequal there. */ export declare function isTimeZoneEqualsCompatNeeded(): boolean; /** * True when this runtime's `Temporal.PlainMonthDay.from` or `Temporal.PlainYearMonth.from` throws * for an upper-case `iso8601` calendar annotation (defect D20). * * Temporal ParseISODateTime, for the goals TemporalMonthDayString (no DateYear) and * TemporalYearMonthString (no DateDay), lower-cases the `u-ca` value before comparing it with * `"iso8601"`; polyfill 0.5.1 compares it as written in both parsers. */ export declare function isIsoCalendarCaseCompatNeeded(): boolean; /** * True when calendar arithmetic in `calendarId` needs the compat layer in this runtime: any of its * add, until or read probes fails. `iso8601` never does, and costs nothing. * Callers that own a spec path for a whole operation (zoned differences, `Duration` rounding, * totals and comparisons) take it when this is true. */ export declare function isCalendarArithmeticCompatNeeded(calendarId: string): boolean;