UNPKG

1.81 kBTypeScriptView Raw
1/**
2 * dateFormat.masks
3 *
4 * Predefined Formats
5 *
6 * https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L107
7 */
8interface DateFormatMasks {
9 default: string;
10 shortDate: string;
11 mediumDate: string;
12 longDate: string;
13 fullDate: string;
14 shortTime: string;
15 mediumTime: string;
16 longTime: string;
17 isoDate: string;
18 isoTime: string;
19 isoDateTime: string;
20 isoUtcDateTime: string;
21 expiresHeaderFormat: string;
22 [key: string]: string;
23}
24
25/**
26 * dateFormat.i18n
27 *
28 * Internationalization strings
29 *
30 * Example:
31 *
32 * ```
33 * dateFormat.i18n = {
34 * dayNames: [
35 * 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
36 * 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
37 * ],
38 * monthNames: [
39 * 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
40 * 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
41 * ]
42 * }
43 * ```
44 *
45 * https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L124
46 */
47interface DateFormatI18n {
48 dayNames: string[];
49 monthNames: string[];
50}
51
52/**
53 * dateFormat()
54 *
55 * Accepts a date, a mask, or a date and a mask.
56 * Returns a formatted version of the given date.
57 * The date defaults to the current date/time.
58 * The mask defaults to dateFormat.masks.default.
59 *
60 * https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L18
61 */
62interface DateFormatStatic {
63 (date?: Date | string | number, mask?: string, utc?: boolean, gmt?: boolean): string;
64 (mask?: string, utc?: boolean, gmt?: boolean): string;
65 masks: DateFormatMasks;
66 i18n: DateFormatI18n;
67}
68
69declare const dateFormat: DateFormatStatic;
70export = dateFormat;