1 | export type Locale = string;
|
2 |
|
3 | export type Style = 'long' | 'short' | 'narrow';
|
4 |
|
5 | type Numeric = 'auto' | 'always';
|
6 |
|
7 | export type Unit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
8 |
|
9 |
|
10 | export type Count = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';
|
11 |
|
12 | export type CountLabels = {
|
13 | [count in Count]?: string;
|
14 | }
|
15 |
|
16 | export interface PastAndFutureLabels {
|
17 | past: string | CountLabels;
|
18 | future: string | CountLabels;
|
19 | previous?: string;
|
20 | current?: string;
|
21 | next?: string;
|
22 | }
|
23 |
|
24 | export type UnitLabels = string | CountLabels | PastAndFutureLabels
|
25 |
|
26 | export type Labels = {
|
27 |
|
28 |
|
29 | year: UnitLabels;
|
30 | quarter: UnitLabels;
|
31 | month: UnitLabels;
|
32 | week: UnitLabels;
|
33 | day: UnitLabels;
|
34 | hour: UnitLabels;
|
35 | minute: UnitLabels;
|
36 | second: UnitLabels;
|
37 | }
|
38 |
|
39 | export type LocaleData = {
|
40 | locale: Locale;
|
41 | long: Labels;
|
42 | short: Labels;
|
43 | narrow: Labels;
|
44 | }
|
45 |
|
46 |
|
47 | export type LocaleMatcher = 'lookup' | 'best fit';
|
48 |
|
49 | export class PluralRules {
|
50 | constructor(locale: Locale | Locale[], options?: { type?: 'cardinal' });
|
51 | select(number: number): Count;
|
52 | static supportedLocalesOf(locale: Locale | Locale[]): Locale[];
|
53 | }
|
54 |
|
55 | interface LiteralPart {
|
56 | type: 'literal';
|
57 | value: string;
|
58 | }
|
59 |
|
60 | interface IntegerPart {
|
61 | type: 'integer';
|
62 | value: string;
|
63 | unit: Unit;
|
64 | }
|
65 |
|
66 | export type Part = LiteralPart | IntegerPart;
|
67 |
|
68 |
|
69 |
|
70 | type NumberingSystem = string;
|
71 |
|
72 | export default class RelativeTimeFormat {
|
73 | constructor(locale: Locale | Locale[], options?: { style?: Style, numeric?: Numeric, localeMatcher?: LocaleMatcher });
|
74 |
|
75 | format(number: number, unit: Unit): string;
|
76 | formatToParts(number: number, unit: Unit): Part[];
|
77 | resolvedOptions(): { locale: Locale, style: Style, numeric: Numeric, numberingSystem: NumberingSystem };
|
78 |
|
79 | static addLocale(localeData: LocaleData): void;
|
80 | static addDefaultLocale(localeData: LocaleData): void;
|
81 | static setDefaultLocale(locale: Locale): void;
|
82 |
|
83 | static PluralRules: PluralRules;
|
84 | static supportedLocalesOf(locale: Locale | Locale[], options?: { localeMatcher?: LocaleMatcher }): Locale[];
|
85 | } |
\ | No newline at end of file |