UNPKG

@phensley/cldr-core

Version:
52 lines (51 loc) 2.72 kB
import { Internals } from '../internals'; import { Bundle } from '../../resource'; import { Cache } from '../../utils/cache'; import { DateFormatOptions, DateIntervalFormatOptions } from '../../common'; import { DateTimeNode } from '../../parsing/patterns/date'; import { CalendarDate } from '../../systems/calendars'; import { NumberParams } from '../../common/private'; import { CalendarPatterns } from './patterns'; import { DateSkeleton } from './skeleton'; import { DateFormatRequest, DateIntervalFormatRequest } from './types'; import { DateTimePatternFieldType } from '@phensley/cldr-schema'; export declare class CalendarManager { readonly bundle: Bundle; readonly internals: Internals; readonly patternCache: Cache<CalendarPatterns>; constructor(bundle: Bundle, internals: Internals); getCalendarPatterns(calendar: string): CalendarPatterns; getDateFormatRequest(date: CalendarDate, options: DateFormatOptions, params: NumberParams): DateFormatRequest; /** * * Best-fit match an input skeleton. The skeleton can contain both date and * time fields. * * The field of greatest difference between the start and end dates can be * either a date or time field. * * Given this we need to cover the following cases: * * 1. Input skeleton requests both date and time fields. * a. "yMd" same: split skeleton, format date standalone, followed by time range. * b. "yMd" differ: format full start / end with fallback format. * * 2. Input skeleton requests date fields only: * a. "yMd" same: format date standalone * b. "yMd" differ: select and format date range * * 3. Input skeleton requests time fields only: * a. "yMd" same, "ahms" same: format time standalone * b. "yMd" same, "ahms" differ: select and format time range. * c. "yMd" differ: prepend "yMd" to skeleton and go to (1a). * */ getDateIntervalFormatRequest(calendar: string, start: CalendarDate, fieldDiff: DateTimePatternFieldType, options: DateIntervalFormatOptions, params: NumberParams): DateIntervalFormatRequest; protected matchAvailablePattern(patterns: CalendarPatterns, date: CalendarDate, query: DateSkeleton, params: NumberParams): DateTimeNode[] | undefined; protected getAvailablePattern(patterns: CalendarPatterns, date: CalendarDate, query: DateSkeleton, match: DateSkeleton, params: NumberParams): DateTimeNode[] | undefined; /** * Select appropriate wrapper based on fields in the date skeleton. */ protected selectWrapper(patterns: CalendarPatterns, dateSkel: DateSkeleton, date: DateTimeNode[]): string; protected supportedOption(key?: string): string; }