-
Notifications
You must be signed in to change notification settings - Fork 8
/
types.ts
46 lines (37 loc) · 842 Bytes
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export type DatePartName =
| 'weekday'
| 'year'
| 'month'
| 'lmonth'
| 'day'
| 'dayPeriod'
| 'hour'
| 'lhour'
| 'minute'
| 'second'
export type DateParts = { [k in DatePartName]: string }
export type Token = { type: DatePartName | 'literal'; value: string }
export type Parser = (date: Date) => DateParts
export type FormatterMask =
| 'YYYY'
| 'YY'
| 'MMMM'
| 'MMM'
| 'MM'
| 'DD'
| 'dddd'
| 'ddd'
| 'A'
| 'a'
| 'HH'
| 'hh'
| 'mm'
| 'ss'
export type Formatter = (tokens: DateParts, date: Date) => string
export type Formatters = { [k in FormatterMask]: Formatter }
export type CustomFormatters = { [k: string]: Formatter }
export type FormatFunction = (date: Date, format: string, options?: FormatOptions) => string
export type FormatOptions = {
locale?: string
timezone?: string
}