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.

34 lines • 2.35 kB
/** * The range text where the engine's range pattern drops, repeats or garbles a field (defect D29) * for this pair of instants, or `null` when the engine's own range is right and is to be used. * * The verdict is per pattern and per class of the greatest field that differs, because an engine's * interval data is per class: a pattern wrong for a day-apart range prints a same-day range right, * and that range is not replaced. Two instants whose field values are equal in every row ECMA-402 * PartitionDateTimeRangePattern checks are the one single text; printed text is never compared. * * @param formatter the formatter whose range is asked for * @param options the options it was built with * @param startMs the start in epoch milliseconds * @param endMs the end in epoch milliseconds * @returns the repaired text, `""` when the fallback joiner is unavailable, or `null` to use the engine's range * * @example rangeFieldsText(new Intl.DateTimeFormat("en", { dateStyle: "medium", timeZone: "UTC" }), { dateStyle: "medium" }, 0, 86_400_000) // null on an engine whose ranges are right */ export declare function rangeFieldsText(formatter: Intl.DateTimeFormat, options: Intl.DateTimeFormatOptions, startMs: number, endMs: number): string | null; /** * The range as the locale's fallback writes it from the formatter's own single texts, or `""` when * the joiner or a single is unavailable (the house value). * * @example rangeFromSingles(new Intl.DateTimeFormat("en", { dateStyle: "medium", timeZone: "UTC" }), 1715731200000, 1715904000000) // "May 15, 2024 – May 17, 2024" */ export declare function rangeFromSingles(formatter: Intl.DateTimeFormat, startMs: number, endMs: number): string; /** * The text of a range: the fields repair of D29 where this pair needs it, else the year repair * (`formatRangeChecked`) of the engine's own range. The one call the range functions make. * * @returns the text, or `null` when a flagged formatter's year runs cannot be repaired * * @example formatRangeRepaired(new Intl.DateTimeFormat("en", { dateStyle: "medium", timeZone: "UTC" }), { dateStyle: "medium" }, 1715731200000, 1715904000000) // "May 15 – 17, 2024" */ export declare function formatRangeRepaired(formatter: Intl.DateTimeFormat, options: Intl.DateTimeFormatOptions, startMs: number, endMs: number): string | null;