@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.
37 lines • 2.12 kB
TypeScript
/**
* The instant a coptic date on 1 Tout AM 1 is read at instead, with its true year (1), or `null`:
* the engine has no D34, the local date is not that day, or no same-time twin exists. The twin is
* one or more whole 28-year cycles later, so the engine names the era `am` and prints the same
* month, day, weekday and time.
*
* @example copticEpochTwin(Date.UTC(284, 7, 29), "UTC") // { ms: 36 cycles later, year: 1 } on WebKit, null elsewhere
*/
export declare function copticEpochTwin(ms: number, timeZone: string): {
readonly ms: number;
readonly year: number;
} | null;
/**
* The instant the D29 field reader reads a coptic instant at instead, with its true year, or
* `null` when the engine's own reading is right. An instant on 1 Tout AM 1 is read at its D34 twin
* (year 1); while D31 holds, an instant whose coptic year is 0 or less is read one or more cycles
* later, so the engine names the era `am` where it would name the wrong one (D31), and the year is
* the true, signed one.
*
* @example copticFieldTwin(Date.UTC(284, 7, 28), "UTC") // { ms: 36 cycles later, year: 0 } while D31 holds, null elsewhere
*/
export declare function copticFieldTwin(ms: number, timeZone: string): {
readonly ms: number;
readonly year: number;
} | null;
/**
* The formatter itself, or a wrapper that prints a coptic date before AM 1 with its signed year and
* the era the engine names for AM, where the engine prints `1 - year` and no era (D31).
*
* @param formatter the formatter the earlier repairs returned
* @param callerOptions the options it was built with
* @returns the formatter, or its wrapper
*
* @example repairCopticEra(new Intl.DateTimeFormat("en-u-ca-gregory"), {}) // the same formatter
* @example repairCopticEra(new Intl.DateTimeFormat("en-u-ca-coptic", { era: "short", year: "numeric", timeZone: "UTC" }), { era: "short", year: "numeric", timeZone: "UTC" }).format(Date.UTC(-1, 6, 10)) // "-285 AM" where the engine prints "286 "
*/
export declare function repairCopticEra(formatter: Intl.DateTimeFormat, callerOptions: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;