@everwhen/temporal
Version:
65 lines (64 loc) • 2.06 kB
TypeScript
type DateTimeFormatOptions = Intl.DateTimeFormatOptions;
export declare const TIME_STYLE_MAPPINGS: {
readonly short: {
readonly hour: "numeric";
readonly minute: "numeric";
readonly hour12: true;
};
readonly medium: {
readonly hour: "numeric";
readonly minute: "numeric";
readonly second: "numeric";
readonly hour12: true;
};
readonly long: {
readonly hour: "numeric";
readonly minute: "numeric";
readonly second: "numeric";
readonly timeZoneName: "short";
readonly hour12: true;
};
readonly full: {
readonly hour: "numeric";
readonly minute: "numeric";
readonly second: "numeric";
readonly timeZoneName: "long";
readonly hour12: true;
};
};
export declare const DATE_STYLE_MAPPINGS: {
readonly short: {
readonly year: "2-digit";
readonly month: "numeric";
readonly day: "numeric";
};
readonly medium: {
readonly year: "numeric";
readonly month: "short";
readonly day: "numeric";
};
readonly long: {
readonly year: "numeric";
readonly month: "long";
readonly day: "numeric";
readonly weekday: "long";
};
readonly full: {
readonly year: "numeric";
readonly month: "long";
readonly day: "numeric";
readonly weekday: "long";
readonly era: "long";
};
};
/**
* Resolves {@linkcode Intl.DateTimeFormatOptions} by expanding style shorthands
* if any of the more granular options are present. Essentially treating granular properties
* like `year`, `month`, `hour`, etc., as overrides for `dateStyle` and `timeStyle` settings.
*
* @example
* Input: { dateStyle: 'medium', timeStyle: 'short', month: 'short' }
* Output: { hour: 'numeric', minute: 'numeric', hour12: true, year: 'numeric', month: 'short', day: 'numeric' }
*/
export declare function resolveDateTimeOptions(options: DateTimeFormatOptions): DateTimeFormatOptions;
export {};