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.

31 lines • 1.56 kB
/** What the detector calls on a formatter. */ export interface RangeSource { format(date: number): string; formatRange(start: number, end: number): string; /** * The flexible day period the formatter prints for an instant (`in the afternoon`), when its * pattern prints one. Present, it splits the hour probes into the day-period class and the hour * class (ECMA-402 Table 6 orders [[AmPm]], [[DayPeriod]], [[Hour]]); absent, there is no `B` class. */ dayPeriod?(date: number): string; } /** Why a formatter was flagged. */ export interface RangeVerdict { readonly flagged: boolean; readonly kind?: string | undefined; /** The probe classes whose range is wrong: `y` `M` `d` `a` `B` `h` `m` and `G` (the greatest differing field). */ readonly classes: readonly string[]; } /** The runs of a text: a number is `#value` (so `05` and `5` are one value), a word is itself. */ export declare function rangeRuns(text: string): string[]; /** * Whether a formatter's `formatRange` drops an endpoint's field, prints one twice, prints another * value for one, or puts a date's field on the other date's side. * * @param source `format` and `formatRange` of one formatter (a UTC clone, no zone moves a pattern) * @param calendar the formatter's calendar, which chooses the era probe pair * @returns the verdict * * @example rangeVerdict(new Intl.DateTimeFormat("en", { dateStyle: "medium", timeZone: "UTC" }), "gregory") // { flagged: false } */ export declare function rangeVerdict(source: RangeSource, calendar: string): RangeVerdict;