1 | export interface DateIOFormats<TLibFormatToken = string> {
|
2 |
|
3 | fullDate: TLibFormatToken;
|
4 |
|
5 | fullDateWithWeekday: TLibFormatToken;
|
6 |
|
7 | normalDate: TLibFormatToken;
|
8 |
|
9 | normalDateWithWeekday: TLibFormatToken;
|
10 |
|
11 | shortDate: TLibFormatToken;
|
12 |
|
13 | year: TLibFormatToken;
|
14 |
|
15 | month: TLibFormatToken;
|
16 |
|
17 | monthShort: TLibFormatToken;
|
18 |
|
19 | monthAndYear: TLibFormatToken;
|
20 |
|
21 | monthAndDate: TLibFormatToken;
|
22 |
|
23 | weekday: TLibFormatToken;
|
24 |
|
25 | weekdayShort: TLibFormatToken;
|
26 |
|
27 | dayOfMonth: TLibFormatToken;
|
28 |
|
29 | hours12h: TLibFormatToken;
|
30 |
|
31 | hours24h: TLibFormatToken;
|
32 |
|
33 | minutes: TLibFormatToken;
|
34 |
|
35 | seconds: TLibFormatToken;
|
36 |
|
37 | fullTime: TLibFormatToken;
|
38 |
|
39 | fullTime12h: TLibFormatToken;
|
40 |
|
41 | fullTime24h: TLibFormatToken;
|
42 |
|
43 | fullDateTime: TLibFormatToken;
|
44 |
|
45 | fullDateTime12h: TLibFormatToken;
|
46 |
|
47 | fullDateTime24h: TLibFormatToken;
|
48 |
|
49 | keyboardDate: TLibFormatToken;
|
50 |
|
51 | keyboardDateTime: TLibFormatToken;
|
52 |
|
53 | keyboardDateTime12h: TLibFormatToken;
|
54 |
|
55 | keyboardDateTime24h: TLibFormatToken;
|
56 | }
|
57 |
|
58 | export type Unit =
|
59 | | "years"
|
60 | | "quarters"
|
61 | | "months"
|
62 | | "weeks"
|
63 | | "days"
|
64 | | "hours"
|
65 | | "minutes"
|
66 | | "seconds"
|
67 | | "milliseconds";
|
68 |
|
69 | type ConstructorOptions<TLocale> = {
|
70 | formats?: Partial<DateIOFormats>;
|
71 | locale?: TLocale;
|
72 | instance?: any;
|
73 | };
|
74 |
|
75 | export interface IUtils<TDate, TLocale> {
|
76 | formats: DateIOFormats<any>;
|
77 | locale?: TLocale;
|
78 | moment?: any;
|
79 | dayjs?: any;
|
80 |
|
81 | lib: string;
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | |
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | date<
|
98 | TArg extends unknown = undefined,
|
99 | TResultingDate extends unknown = TArg extends null
|
100 | ? null
|
101 | : TArg extends undefined
|
102 | ? TDate
|
103 | : TDate | null
|
104 | >(
|
105 | value?: TArg
|
106 | ): TResultingDate;
|
107 | toJsDate(value: TDate): Date;
|
108 | parseISO(isString: string): TDate;
|
109 | toISO(value: TDate): string;
|
110 | parse(value: string, format: string): TDate | null;
|
111 |
|
112 | getCurrentLocaleCode(): string;
|
113 | is12HourCycleInCurrentLocale(): boolean;
|
114 | |
115 |
|
116 |
|
117 |
|
118 | getFormatHelperText(format: string): string;
|
119 |
|
120 | isNull(value: TDate | null): boolean;
|
121 | isValid(value: any): boolean;
|
122 | getDiff(value: TDate, comparing: TDate | string, unit?: Unit): number;
|
123 | isEqual(value: any, comparing: any): boolean;
|
124 |
|
125 | isSameDay(value: TDate, comparing: TDate): boolean;
|
126 | isSameMonth(value: TDate, comparing: TDate): boolean;
|
127 | isSameYear(value: TDate, comparing: TDate): boolean;
|
128 | isSameHour(value: TDate, comparing: TDate): boolean;
|
129 |
|
130 | isAfter(value: TDate, comparing: TDate): boolean;
|
131 | isAfterDay(value: TDate, comparing: TDate): boolean;
|
132 | isAfterMonth(value: TDate, comparing: TDate): boolean;
|
133 | isAfterYear(value: TDate, comparing: TDate): boolean;
|
134 |
|
135 | isBefore(value: TDate, comparing: TDate): boolean;
|
136 | isBeforeDay(value: TDate, comparing: TDate): boolean;
|
137 | isBeforeMonth(value: TDate, comparing: TDate): boolean;
|
138 | isBeforeYear(value: TDate, comparing: TDate): boolean;
|
139 |
|
140 | isWithinRange(value: TDate, range: [TDate, TDate]): boolean;
|
141 |
|
142 | startOfYear(value: TDate): TDate;
|
143 | endOfYear(value: TDate): TDate;
|
144 | startOfMonth(value: TDate): TDate;
|
145 | endOfMonth(value: TDate): TDate;
|
146 | startOfWeek(value: TDate): TDate;
|
147 | endOfWeek(value: TDate): TDate;
|
148 |
|
149 | addSeconds(value: TDate, count: number): TDate;
|
150 | addMinutes(value: TDate, count: number): TDate;
|
151 | addHours(value: TDate, count: number): TDate;
|
152 | addDays(value: TDate, count: number): TDate;
|
153 | addWeeks(value: TDate, count: number): TDate;
|
154 | addMonths(value: TDate, count: number): TDate;
|
155 | addYears(value: TDate, count: number): TDate;
|
156 |
|
157 | startOfDay(value: TDate): TDate;
|
158 | endOfDay(value: TDate): TDate;
|
159 |
|
160 | format(value: TDate, formatKey: keyof DateIOFormats): string;
|
161 | formatByString(value: TDate, formatString: string): string;
|
162 | formatNumber(numberToFormat: string): string;
|
163 |
|
164 | getHours(value: TDate): number;
|
165 | setHours(value: TDate, count: number): TDate;
|
166 |
|
167 | getMinutes(value: TDate): number;
|
168 | setMinutes(value: TDate, count: number): TDate;
|
169 |
|
170 | getSeconds(value: TDate): number;
|
171 | setSeconds(value: TDate, count: number): TDate;
|
172 |
|
173 | getDate(value: TDate): number;
|
174 | setDate(value: TDate, count: number): TDate;
|
175 |
|
176 | getWeek(value: TDate): number;
|
177 | getMonth(value: TDate): number;
|
178 | getDaysInMonth(value: TDate): number;
|
179 | setMonth(value: TDate, count: number): TDate;
|
180 | getNextMonth(value: TDate): TDate;
|
181 | getPreviousMonth(value: TDate): TDate;
|
182 |
|
183 | getMonthArray(value: TDate): TDate[];
|
184 |
|
185 | getYear(value: TDate): number;
|
186 | setYear(value: TDate, count: number): TDate;
|
187 |
|
188 | mergeDateAndTime(date: TDate, time: TDate): TDate;
|
189 |
|
190 | getWeekdays(): string[];
|
191 | getWeekArray(date: TDate): TDate[][];
|
192 | getYearRange(start: TDate, end: TDate): TDate[];
|
193 |
|
194 |
|
195 | getMeridiemText(ampm: "am" | "pm"): string;
|
196 | }
|