@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
48 lines (47 loc) • 2.39 kB
TypeScript
import { Temporal } from "@js-temporal/polyfill";
export type EthiopicFamilyCalendar = "ethiopic" | "ethiopic-amete-alem" | "coptic";
export declare function isEthiopicFamilyCalendar(value: string): value is EthiopicFamilyCalendar;
export interface EthiopicFamilyFields {
year: number;
era?: "ethioaa" | "ethiopic";
eraYear?: number;
month: number;
day: number;
}
/**
* Derive an Ethiopic-family calendar's native year/month/day (+ era, for "ethiopic") from a
* Temporal.PlainDate, via Temporal's ICU-independent "ethioaa" calendar rather than the
* target's own native calendar id. See the module comment above for why.
*/
export declare function ethiopicFamilyFieldsFromDate(date: Temporal.PlainDate, calendar: EthiopicFamilyCalendar): EthiopicFamilyFields;
/**
* Construct a Temporal.PlainDate from an Ethiopic-family calendar's native fields, backed
* by Temporal's "ethioaa" calendar rather than the target's own native calendar id. Throws
* on an unrecognized era or a missing required field — callers wrap this in try-catch per
* GMT's sentinel-return contract. See the module comment above for why.
*/
export declare function dateFromEthiopicFamilyFields(calendar: EthiopicFamilyCalendar, fields: {
year?: number;
era?: string;
eraYear?: number;
month: number;
day: number;
}): Temporal.PlainDate;
/**
* Split a Temporal.PlainDate into GMT's calendar-annotated string halves for an Ethiopic-family
* calendar, mirroring `calendarDateParts`' shape for the rest of the calendar systems but
* routed entirely through `ethiopicFamilyFieldsFromDate` — see the module comment above.
*
* Returned as `{ date, annotation }` rather than one string so the zoned grammar can splice its
* time/offset between the two halves — see `calendarDateParts`' doc comment for why.
*/
export declare function ethiopicFamilyDateParts(date: Temporal.PlainDate, calendar: EthiopicFamilyCalendar): {
date: string;
annotation: string;
};
/**
* Format a Temporal.PlainDate as GMT's calendar-annotated string for an Ethiopic-family
* calendar, mirroring `formatCalendarDate`'s shape for the rest of the calendar systems but
* routed entirely through `ethiopicFamilyFieldsFromDate` — see the module comment above.
*/
export declare function formatEthiopicFamilyDate(date: Temporal.PlainDate, calendar: EthiopicFamilyCalendar): string;