UNPKG

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