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.

19 lines • 1.39 kB
/** * Refuse a formatter that would print a wrong Chinese or Dangi date (compat D33). Intl * era/monthCode section 1.1 Table 1 bases `chinese` on Purple Mountain Observatory data and * `dangi` on KASI data; GMT owns no calendar data, so a runtime that prints a different date * gets the function's own sentinel. Throws RangeError when all three hold: `resolvedOptions().calendar` * is chinese or dangi, the resolved options carry `dateStyle`, `era`, `year`, `month` or `day` (or its * parts hold a year, `relatedYear`, `yearName`, month, day or era), and the runtime's probe for that * calendar fails (`isLunisolarTextCompatNeeded`). A time-only or weekday-only formatter is returned: the * weekday and the time of day carry no calendar-specific date, so the refusal leaves them alone. A * runtime that passes the probe keeps its own text. * * @param formatter a date formatter built from the caller's locale and options * @returns the same formatter, when it prints no wrong Chinese or Dangi date * @throws RangeError when it would print one * * @example refuseLunisolarDate(new Intl.DateTimeFormat("en-u-ca-chinese")) // throws RangeError where the probe fails * @example refuseLunisolarDate(new Intl.DateTimeFormat("zh-u-ca-chinese", { hour: "numeric" })) // returns it */ export declare function refuseLunisolarDate(formatter: Intl.DateTimeFormat): Intl.DateTimeFormat;