UNPKG

2.91 kBTypeScriptView Raw
1// Type definitions for dateformat 5.0
2// Project: https://github.com/felixge/node-dateformat
3// Definitions by: Kombu <https://github.com/aicest>
4// BendingBender <https://github.com/BendingBender>
5// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
7export as namespace dateFormat;
8
9/**
10 * @param date Defaults to the current date/time.
11 * @param mask Defaults to `masks.default`.
12 * @returns A formatted version of the given date.
13 */
14export default function dateFormat(date?: Date | string | number, mask?: string, utc?: boolean, gmt?: boolean): string;
15export default function dateFormat(mask?: string, utc?: boolean, gmt?: boolean): string;
16
17/**
18 * Get proper timezone abbreviation or timezone offset.
19 *
20 * This will fall back to `GMT+xxxx` if it does not recognize the
21 * timezone within the `timezone` RegEx above. Currently only common
22 * American and Australian timezone abbreviations are supported.
23 */
24export function formatTimezone(date: string | Date): string;
25
26/**
27 * Predefined Formats
28 */
29export let masks: DateFormatMasks;
30
31/**
32 * Internationalization strings
33 *
34 * @example
35 * import { i18n } from 'dateformat';
36 *
37 * i18n.dayNames = [
38 * 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
39 * 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
40 * ];
41 * i18n.monthNames = [
42 * 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
43 * 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
44 * ];
45 * i18n.timeNames = [
46 * 'a', 'p', 'am', 'pm', 'A', 'P', 'AM', 'PM'
47 * ];
48 */
49export let i18n: DateFormatI18n;
50
51export interface DateFormatMasks {
52 /**
53 * @default "ddd mmm dd yyyy HH:MM:ss"
54 */
55 default: string;
56 /**
57 * @default "m/d/yy"
58 */
59 shortDate: string;
60 /**
61 * @default "mm/dd/yyyy"
62 */
63 paddedShortDate: string;
64 /**
65 * @default "mmm d, yyyy"
66 */
67 mediumDate: string;
68 /**
69 * @default "mmmm d, yyyy"
70 */
71 longDate: string;
72 /**
73 * @default "dddd, mmmm d, yyyy"
74 */
75 fullDate: string;
76 /**
77 * @default "h:MM TT"
78 */
79 shortTime: string;
80 /**
81 * @default "h:MM:ss TT"
82 */
83 mediumTime: string;
84 /**
85 * @default "h:MM:ss TT Z"
86 */
87 longTime: string;
88 /**
89 * @default "yyyy-mm-dd"
90 */
91 isoDate: string;
92 /**
93 * @default "HH:MM:ss"
94 */
95 isoTime: string;
96 /**
97 * @default "yyyy-mm-dd'T'HH:MM:sso"
98 */
99 isoDateTime: string;
100 /**
101 * @default "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
102 */
103 isoUtcDateTime: string;
104 /**
105 * @default "ddd, dd mmm yyyy HH:MM:ss Z"
106 */
107 expiresHeaderFormat: string;
108 [key: string]: string;
109}
110
111export interface DateFormatI18n {
112 dayNames: string[];
113 monthNames: string[];
114 timeNames: string[];
115}