-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdatef.d.ts
91 lines (82 loc) · 2.82 KB
/
datef.d.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
declare module "datef" {
type DateInput = Date | Number | string;
interface Formatter {
(date: DateInput): string;
}
/**
* Formats date according to `format` string.
* Format string may consist of any characters, but some of them considered tokens,
* and will be replaced by appropriate value from `date`.
* Possible tokens include:
* * **YYYY**: 4-digit year
* * **YY**: last 2 digit of year
* * **MMMM**: full name of month
* * **MMM**: short name of month
* * **MM**: ISO8601-compatible number of month (i.e. zero-padded) in year (with January being 1st month)
* * **M**: number of month in year without zero-padding (with January being 1st month)
* * **DDD**: full name of day
* * **DD**: short name of day
* * **D**: min name of day
* * **dd**: zero-padded number of day in month
* * **d**: number of day in month
* * **HH**: zero-padded hour in 24-hr format
* * **H**: hour in 24-hr format
* * **hh**: zero-padded hour in 12-hr format
* * **h**: hour in 12-hr format
* * **mm**: zero-padded minutes
* * **m**: minutes
* * **ss**: zero-padded seconds
* * **s**: seconds
* * **ff**: zero-padded milliseconds
* * **f**: milliseconds
* * **A**: AM/PM
* * **a**: am/pm
* * **ZZ**: time-zone in ISO8601-compatible basic format (i.e. "-0400")
* * **Z**: time-zone in ISO8601-compatible extended format (i.e. "-04:00")
*
* Longer tokens take precedence over shorter ones (so "MM" will aways be "04", not "44" in april).
*/
interface DatefStatic {
(format: string): string;
(format: string, date: DateInput): string;
}
export default DatefStatic;
/**
* Creates and returns formatting function and files it under `datef.formatters[name]`
* Using is just `datef('myformat')`
*
* @example
* ```js
* datef.register('longDate', 'd MMMM');
* datef.register('longDateAndTime', {
* 'en': 'MMMM d, h:mma',
* 'default': 'd MMMM, HH:mm'
* });
* ```
*/
export function register (name: string, format: string): Formatter;
/**
* Return list of custom formats
*/
export function formatters (): Formatter[];
interface LangOptions {
_months: {
nominative: string[],
accusative: string[],
};
month: (date, format) => string;
_monthsShort: {
nominative: string[],
accusative: string[],
};
monthsShort: (date, format) => string;
weekDays: string;
weekdaysShort: string;
weekdaysMin: string;
meridiem: (number) => string;
}
/**
* Creates lang function.
*/
export function lang (lang: string, options: LangOptions): string;
}