@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.
38 lines • 2.17 kB
TypeScript
import { Temporal } from "../temporal.js";
/** A date's fields in one calendar. `month` is ordinal (Hebrew leap year: `M05L` is 6). */
export interface CalendarFields {
year: number;
month: number;
monthCode: string;
day: number;
/** As the runtime reads it; corrected only for "japanese", the one calendar GMT tags with an era. */
era: string | undefined;
eraYear: number | undefined;
}
/**
* The fields of `date` in the Temporal calendar `calendarId`. Every calendar-field read in GMT's
* calendar string formatters and in the field search goes through here, so the runtime's read is
* corrected in one place, and only where a capability probe shows the runtime is wrong (D2, D3,
* D4, D5, D8, D18 in README.md). Otherwise this is exactly `date.withCalendar(calendarId)`'s fields.
*/
export declare function calendarFieldsOf(date: Temporal.PlainDate, calendarId: string): CalendarFields;
/**
* True when reads of `calendarYear` in `calendarId` are corrected in this runtime, so the
* polyfill's own fields → ISO conversion for that year cannot be trusted either. The year ranges
* are supersets of each defect's reach: Hebrew years <= 0 hold every D3/D4 date, and every ISO
* date before year 1 lies in a Saka year whose Chaitra 1 falls in a Gregorian year <= 0.
*/
export declare function hasReadCorrection(calendarId: string, calendarYear: number): boolean;
/**
* True when the polyfill's Islamic reads need a correction in this runtime (D18, WebKit): some
* years then cannot be asked of it at all (`polyfillCannotReturn`), and its answer for any other
* year is trusted only when it reads back.
*/
export declare function polyfillMisreadsIslamicEra(calendarId: string): boolean;
/**
* True when the polyfill must not be asked about `calendarYear` in `calendarId`: its fields → ISO
* conversion and its month and year arithmetic for that year do not return, or return the mirror
* year, in this runtime (D18: Islamic years <= 1 in WebKit). The field search and the read-backed
* model answer instead, over the corrected reads.
*/
export declare function polyfillCannotReturn(calendarId: string, calendarYear: number): boolean;