@phensley/cldr-core
Version:
Core library for @phensley/cldr
92 lines (91 loc) • 4.05 kB
TypeScript
import { DateFieldType, DateTimePatternFieldType } from '@phensley/cldr-schema';
import { Calendars } from '../api';
import { Bundle } from '../../resource';
import { DateFormatOptions, DateIntervalFormatOptions, DateRawFormatOptions, RelativeTimeFormatOptions, ZonedDateTime } from '../../common';
import { Internals } from '../../internals';
import { BuddhistDate, CalendarDate, CalendarType, GregorianDate, ISO8601Date, JapaneseDate, PersianDate } from '../../systems/calendars';
import { DecimalArg } from '../../types/numbers';
import { Part } from '../../types';
import { CalendarManager } from '../../internals/calendars/manager';
import { PrivateApiImpl } from '../private';
export declare class CalendarsImpl implements Calendars {
protected readonly bundle: Bundle;
protected readonly internals: Internals;
protected readonly privateApi: PrivateApiImpl;
readonly manager: CalendarManager;
readonly firstDay: number;
readonly minDays: number;
constructor(bundle: Bundle, internals: Internals, privateApi: PrivateApiImpl);
/**
* @alpha
*/
dayPeriods(type?: CalendarType): {
[x: string]: string;
};
/**
* @alpha
*/
months(type?: CalendarType): {
[x: string]: string;
};
/**
* @alpha
*/
quarters(type?: CalendarType): {
[x: string]: string;
};
/**
* @alpha
*/
weekdays(type?: CalendarType): {
[x: string]: string;
};
/**
* Convert the given date to the Buddhist calendar.
*/
toBuddhistDate(date: CalendarDate | ZonedDateTime | Date): BuddhistDate;
/**
* Convert the given date to the Gregorian calendar.
*/
toGregorianDate(date: CalendarDate | ZonedDateTime | Date): GregorianDate;
/**
* Convert the given date to the ISO-8601 calendar.
*/
toISO8601Date(date: CalendarDate | ZonedDateTime | Date): ISO8601Date;
/**
* Convert the given date to the Japanese calendar.
*/
toJapaneseDate(date: CalendarDate | ZonedDateTime | Date): JapaneseDate;
/**
* Convert the given date to the Persian calendar.
*/
toPersianDate(date: CalendarDate | ZonedDateTime | Date): PersianDate;
/**
* Find the field of greatest difference between two dates. This can be used by applications
* to select an appropriate skeleton for date interval formatting.
*/
fieldOfGreatestDifference(a: CalendarDate | ZonedDateTime | Date, b: CalendarDate | ZonedDateTime | Date): DateTimePatternFieldType;
/**
* Format a calendar date to string using the given options.
*/
formatDate(date: CalendarDate | ZonedDateTime | Date, options?: DateFormatOptions): string;
/**
* Format a calendar date to a parts array using the given options.
*/
formatDateToParts(date: CalendarDate | ZonedDateTime | Date, options?: DateFormatOptions): Part[];
formatDateInterval(start: CalendarDate | ZonedDateTime | Date, end: CalendarDate | ZonedDateTime | Date, options?: DateIntervalFormatOptions): string;
formatDateIntervalToParts(start: CalendarDate | ZonedDateTime | Date, end: CalendarDate | ZonedDateTime | Date, options?: DateIntervalFormatOptions): Part[];
formatRelativeTimeField(value: DecimalArg, field: DateFieldType, options?: RelativeTimeFormatOptions): string;
/**
* Format a raw date pattern. Note: This should not be used, but is available for debugging or
* extreme cases where an application must implement a custom format.
*/
formatDateRaw(date: CalendarDate | ZonedDateTime | Date, options?: DateRawFormatOptions): string;
formatDateRawToParts(date: CalendarDate | ZonedDateTime | Date, options?: DateRawFormatOptions): Part[];
private _formatDate<R>(renderer, date, options?);
private _formatInterval<R>(renderer, start, end, options?);
private _formatDateRaw<R>(renderer, date, options);
private convertDate<T>(cons, date);
private convertEpoch<T>(cons, epoch, zoneId);
private convertDateTo(target, date, zoneId?);
}