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.

29 lines • 1.8 kB
import { CalendarSystem } from "../types/calendar-system.js"; import "../types/index.js"; /** * Every `CalendarSystem`, by canonical calendar id: the CLDR `common/bcp47/calendar.xml` type, * which is also what Temporal's `CanonicalizeCalendar` returns and what RFC 9557's `[u-ca=<id>]` * carries. `"iso8601"` plus the Intl Era and Month Code proposal's `table-calendar-types` rows * GMT supports (not `"chinese"` or `"dangi"`). */ export declare const calendarSystems: readonly CalendarSystem[]; /** True when `value` is exactly a canonical `CalendarSystem` id (no alias, no case folding). */ export declare function isCalendarSystem(value: string): value is CalendarSystem; /** * The `CalendarSystem` a calendar id names, or `null` when GMT does not support it. * * Canonicalization is Temporal's (`CanonicalizeCalendar`: ASCII-lowercase, then the CLDR alias * mapping, so `"ethiopic-amete-alem"` is `"ethioaa"` and `"islamicc"` is `"islamic-civil"`), * asked of the polyfill rather than kept as a GMT copy of the alias table. Constructing a * `PlainDate` reads no calendar fields, so this is safe for every calendar. */ export declare function canonicalCalendarSystem(id: string): CalendarSystem | null; /** * The Temporal calendar a `CalendarSystem` computes in. The Ethiopic family (`"ethiopic"`, * `"coptic"`) computes in `"ethioaa"`: polyfill 0.5.1 cannot read `"ethiopic"`/`"coptic"` fields * under ICU >= 78, and the three calendars share months, days and arithmetic, differing only by a * constant year offset (test262 `extreme-dates.js`: ethiopic = ethioaa − 5500, coptic = ethioaa − * 5776 at both limits). Strings still carry the * requested id; only the computation is routed. */ export declare function computationCalendarId(calendar: CalendarSystem): string;