UNPKG

2.41 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/dateformat`
3
4# Summary
5This package contains type definitions for dateformat (https://github.com/felixge/node-dateformat).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dateformat/v1.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dateformat/v1/index.d.ts)
10````ts
11/**
12 * dateFormat.masks
13 *
14 * Predefined Formats
15 *
16 * https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L107
17 */
18interface DateFormatMasks {
19 default: string;
20 shortDate: string;
21 mediumDate: string;
22 longDate: string;
23 fullDate: string;
24 shortTime: string;
25 mediumTime: string;
26 longTime: string;
27 isoDate: string;
28 isoTime: string;
29 isoDateTime: string;
30 isoUtcDateTime: string;
31 expiresHeaderFormat: string;
32 [key: string]: string;
33}
34
35/**
36 * dateFormat.i18n
37 *
38 * Internationalization strings
39 *
40 * Example:
41 *
42 * ```
43 * dateFormat.i18n = {
44 * dayNames: [
45 * 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
46 * 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
47 * ],
48 * monthNames: [
49 * 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
50 * 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
51 * ]
52 * }
53 * ```
54 *
55 * https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L124
56 */
57interface DateFormatI18n {
58 dayNames: string[];
59 monthNames: string[];
60}
61
62/**
63 * dateFormat()
64 *
65 * Accepts a date, a mask, or a date and a mask.
66 * Returns a formatted version of the given date.
67 * The date defaults to the current date/time.
68 * The mask defaults to dateFormat.masks.default.
69 *
70 * https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L18
71 */
72interface DateFormatStatic {
73 (date?: Date | string | number, mask?: string, utc?: boolean, gmt?: boolean): string;
74 (mask?: string, utc?: boolean, gmt?: boolean): string;
75 masks: DateFormatMasks;
76 i18n: DateFormatI18n;
77}
78
79declare const dateFormat: DateFormatStatic;
80export = dateFormat;
81
82````
83
84### Additional Details
85 * Last updated: Tue, 07 Nov 2023 15:11:37 GMT
86 * Dependencies: none
87
88# Credits
89These definitions were written by [Kombu](https://github.com/aicest).
90
\No newline at end of file