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.

47 lines • 3.34 kB
/** The most moments one environment keeps per kind; they are the caller's, so the map starts again. */ export declare const MAX_MOMENTS = 1024; /** Forget every verdict and environment (a replaced `Intl`, a test seam). */ export declare function forgetWeekYearRange(): void; /** * Whether the formatter's range pattern prints a week-based year where the calendar year is meant * (defect D24 in ranges). A digit run is a year run when it moves exactly as a year under a shift * of one or both endpoints by k years; each is compared with ICU's calendar year for its * endpoint, signed with the locale's minus, and under `year: "2-digit"` only the last two digits * (chinese and dangi print the related year at full width). A formatter whose range text holds no * decimal year is not flagged. A probe whose year runs cannot be located counts as flagged. * * Computed once per formatter, on its first range call; only `format` and `formatRange` are called. * * @param formatter the formatter whose range text is read * @param options the options it was built with * @returns `true` when its range text needs `repairRangeYear` * * @example rangeYearVerdict(new Intl.DateTimeFormat("en", { year: "numeric", month: "short" }), { year: "numeric", month: "short" }) // false * @example rangeYearVerdict(new Intl.DateTimeFormat("my-u-ca-buddhist", { year: "numeric", month: "short", day: "numeric" }), { year: "numeric", month: "short", day: "numeric" }) // true */ export declare function rangeYearVerdict(formatter: Intl.DateTimeFormat, options: Intl.DateTimeFormatOptions): boolean; /** * The range text with each week-based year run replaced by the endpoint's calendar year: ICU's * year, signed with the locale's minus, in the formatter's numbering system, ungrouped, at the * width printed (full, or the last two digits). Only the runs found wrong change, and every other * character is kept. * * @param formatter the formatter that prints the range * @param options the options it was built with * @param startMs the start of the range, in epoch milliseconds * @param endMs the end of the range, in epoch milliseconds * @returns the repaired text, or `null` when the year runs cannot be located or a run is not one * whole week-year value * * @example repairRangeYear(new Intl.DateTimeFormat("kok-u-ca-japanese", { year: "numeric", month: "numeric", day: "numeric", timeZone: "UTC" }), { year: "numeric", month: "numeric", day: "numeric", timeZone: "UTC" }, Date.UTC(2018, 11, 27), Date.UTC(2019, 11, 27)) // the end year is 1 (Reiwa), not 2019 */ export declare function repairRangeYear(formatter: Intl.DateTimeFormat, options: Intl.DateTimeFormatOptions, startMs: number, endMs: number): string | null; /** * The formatter's range text with the calendar year where the engine prints the week-year: the * one call every library `formatRange` goes through. The verdict is computed on the formatter's * first call and kept; a formatter that is not flagged answers with the engine's own text, and a * stand-in that repairs its own range is called as it is. * * @returns the text, or `null` when a flagged formatter's year runs cannot be repaired */ export declare function formatRangeChecked(formatter: Intl.DateTimeFormat, options: Intl.DateTimeFormatOptions, startMs: number, endMs: number): string | null;