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.

17 lines • 1.23 kB
/** * The formatter itself, or a wrapper that writes the era year of a `ja` japanese formatter in the * formatter's numbering system (D27, ICU's `jpanyear` ignores `nu`; ECMA-402 FormatNumeric). * * `jpanyear` prints the era year in Latin digits while every other number honours `nu`, so each run * of Latin digits in the text is the era year: no parts are read from the text, and the week-year * guard above this wrapper sees the same digits in every field. `year: "2-digit"` becomes * `minimumIntegerDigits: 2`. 元 is a name, not a number, and stays. * * @param formatter the formatter to wrap (the engine's, before the week-year guard) * @param callerOptions the options it was built with * @returns the formatter, or its wrapper * * @example repairEraYearNumerals(new Intl.DateTimeFormat("en"), {}) // the same formatter * @example repairEraYearNumerals(new Intl.DateTimeFormat("ja-u-ca-japanese-nu-arab", { year: "numeric", timeZone: "UTC" }), { year: "numeric", timeZone: "UTC" }).format(Date.UTC(2024, 6, 10)) // "令和٦年" where the engine prints 令和6年 */ export declare function repairEraYearNumerals(formatter: Intl.DateTimeFormat, callerOptions: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;