1 | import { EndOfWeekOptions, FormatOptions as DateFnsFormatOptions, StartOfWeekOptions, addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, getWeek, isAfter, isBefore, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
2 | import type { Locale } from "date-fns/locale";
|
3 | import { endOfBroadcastWeek } from "../helpers/endOfBroadcastWeek.js";
|
4 | import { startOfBroadcastWeek } from "../helpers/startOfBroadcastWeek.js";
|
5 | export type { Locale } from "date-fns/locale";
|
6 | export type { Month as DateFnsMonth } from "date-fns";
|
7 |
|
8 | export type FormatOptions = DateLibOptions;
|
9 |
|
10 | export type LabelOptions = DateLibOptions;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | export interface DateLibOptions extends DateFnsFormatOptions, StartOfWeekOptions, EndOfWeekOptions {
|
21 |
|
22 | Date?: typeof Date;
|
23 |
|
24 | locale?: Locale;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export declare class DateLib {
|
37 |
|
38 | readonly options: DateLibOptions;
|
39 |
|
40 | readonly overrides?: Partial<typeof DateLib.prototype>;
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | constructor(options?: DateLibOptions, overrides?: Partial<typeof DateLib.prototype>);
|
48 | /** Reference to the built-in Date constructor. */
|
49 | Date: typeof Date;
|
50 | /**
|
51 | * Adds the specified number of days to the given date.
|
52 | *
|
53 | * @param date The date to add days to.
|
54 | * @param amount The number of days to add.
|
55 | * @returns The new date with the days added.
|
56 | */
|
57 | addDays: typeof addDays;
|
58 | /**
|
59 | * Adds the specified number of months to the given date.
|
60 | *
|
61 | * @param date The date to add months to.
|
62 | * @param amount The number of months to add.
|
63 | * @returns The new date with the months added.
|
64 | */
|
65 | addMonths: typeof addMonths;
|
66 | /**
|
67 | * Adds the specified number of weeks to the given date.
|
68 | *
|
69 | * @param date The date to add weeks to.
|
70 | * @param amount The number of weeks to add.
|
71 | * @returns The new date with the weeks added.
|
72 | */
|
73 | addWeeks: typeof addWeeks;
|
74 | /**
|
75 | * Adds the specified number of years to the given date.
|
76 | *
|
77 | * @param date The date to add years to.
|
78 | * @param amount The number of years to add.
|
79 | * @returns The new date with the years added.
|
80 | */
|
81 | addYears: typeof addYears;
|
82 | /**
|
83 | * Returns the number of calendar days between the given dates.
|
84 | *
|
85 | * @param dateLeft The later date.
|
86 | * @param dateRight The earlier date.
|
87 | * @returns The number of calendar days between the dates.
|
88 | */
|
89 | differenceInCalendarDays: typeof differenceInCalendarDays;
|
90 | /**
|
91 | * Returns the number of calendar months between the given dates.
|
92 | *
|
93 | * @param dateLeft The later date.
|
94 | * @param dateRight The earlier date.
|
95 | * @returns The number of calendar months between the dates.
|
96 | */
|
97 | differenceInCalendarMonths: typeof differenceInCalendarMonths;
|
98 | /**
|
99 | * Returns the end of the broadcast week for the given date.
|
100 | *
|
101 | * @param date The original date.
|
102 | * @returns The end of the broadcast week.
|
103 | */
|
104 | endOfBroadcastWeek: typeof endOfBroadcastWeek;
|
105 | /**
|
106 | * Returns the end of the ISO week for the given date.
|
107 | *
|
108 | * @param date The original date.
|
109 | * @returns The end of the ISO week.
|
110 | */
|
111 | endOfISOWeek: typeof endOfISOWeek;
|
112 | /**
|
113 | * Returns the end of the month for the given date.
|
114 | *
|
115 | * @param date The original date.
|
116 | * @returns The end of the month.
|
117 | */
|
118 | endOfMonth: typeof endOfMonth;
|
119 | /**
|
120 | * Returns the end of the week for the given date.
|
121 | *
|
122 | * @param date The original date.
|
123 | * @returns The end of the week.
|
124 | */
|
125 | endOfWeek: typeof endOfWeek;
|
126 | /**
|
127 | * Returns the end of the year for the given date.
|
128 | *
|
129 | * @param date The original date.
|
130 | * @returns The end of the year.
|
131 | */
|
132 | endOfYear: typeof endOfYear;
|
133 | /**
|
134 | * Formats the given date using the specified format string.
|
135 | *
|
136 | * @param date The date to format.
|
137 | * @param formatStr The format string.
|
138 | * @returns The formatted date string.
|
139 | */
|
140 | format: typeof format;
|
141 | /**
|
142 | * Returns the ISO week number for the given date.
|
143 | *
|
144 | * @param date The date to get the ISO week number for.
|
145 | * @returns The ISO week number.
|
146 | */
|
147 | getISOWeek: typeof getISOWeek;
|
148 | /**
|
149 | * Returns the local week number for the given date.
|
150 | *
|
151 | * @param date The date to get the week number for.
|
152 | * @returns The week number.
|
153 | */
|
154 | getWeek: typeof getWeek;
|
155 | /**
|
156 | * Checks if the first date is after the second date.
|
157 | *
|
158 | * @param date The date to compare.
|
159 | * @param dateToCompare The date to compare with.
|
160 | * @returns True if the first date is after the second date.
|
161 | */
|
162 | isAfter: typeof isAfter;
|
163 | /**
|
164 | * Checks if the first date is before the second date.
|
165 | *
|
166 | * @param date The date to compare.
|
167 | * @param dateToCompare The date to compare with.
|
168 | * @returns True if the first date is before the second date.
|
169 | */
|
170 | isBefore: typeof isBefore;
|
171 | /**
|
172 | * Checks if the given value is a Date object.
|
173 | *
|
174 | * @param value The value to check.
|
175 | * @returns True if the value is a Date object.
|
176 | */
|
177 | isDate: (value: unknown) => value is Date;
|
178 | /**
|
179 | * Checks if the given dates are on the same day.
|
180 | *
|
181 | * @param dateLeft The first date to compare.
|
182 | * @param dateRight The second date to compare.
|
183 | * @returns True if the dates are on the same day.
|
184 | */
|
185 | isSameDay: typeof isSameDay;
|
186 | /**
|
187 | * Checks if the given dates are in the same month.
|
188 | *
|
189 | * @param dateLeft The first date to compare.
|
190 | * @param dateRight The second date to compare.
|
191 | * @returns True if the dates are in the same month.
|
192 | */
|
193 | isSameMonth: typeof isSameMonth;
|
194 | /**
|
195 | * Checks if the given dates are in the same year.
|
196 | *
|
197 | * @param dateLeft The first date to compare.
|
198 | * @param dateRight The second date to compare.
|
199 | * @returns True if the dates are in the same year.
|
200 | */
|
201 | isSameYear: typeof isSameYear;
|
202 | /**
|
203 | * Returns the latest date in the given array of dates.
|
204 | *
|
205 | * @param dates The array of dates to compare.
|
206 | * @returns The latest date.
|
207 | */
|
208 | max: typeof max;
|
209 | /**
|
210 | * Returns the earliest date in the given array of dates.
|
211 | *
|
212 | * @param dates The array of dates to compare.
|
213 | * @returns The earliest date.
|
214 | */
|
215 | min: typeof min;
|
216 | /**
|
217 | * Sets the month of the given date.
|
218 | *
|
219 | * @param date The date to set the month on.
|
220 | * @param month The month to set (0-11).
|
221 | * @returns The new date with the month set.
|
222 | */
|
223 | setMonth: typeof setMonth;
|
224 | /**
|
225 | * Sets the year of the given date.
|
226 | *
|
227 | * @param date The date to set the year on.
|
228 | * @param year The year to set.
|
229 | * @returns The new date with the year set.
|
230 | */
|
231 | setYear: typeof setYear;
|
232 | /**
|
233 | * Returns the start of the broadcast week for the given date.
|
234 | *
|
235 | * @param date The original date.
|
236 | * @returns The start of the broadcast week.
|
237 | */
|
238 | startOfBroadcastWeek: typeof startOfBroadcastWeek;
|
239 | /**
|
240 | * Returns the start of the day for the given date.
|
241 | *
|
242 | * @param date The original date.
|
243 | * @returns The start of the day.
|
244 | */
|
245 | startOfDay: typeof startOfDay;
|
246 | /**
|
247 | * Returns the start of the ISO week for the given date.
|
248 | *
|
249 | * @param date The original date.
|
250 | * @returns The start of the ISO week.
|
251 | */
|
252 | startOfISOWeek: typeof startOfISOWeek;
|
253 | /**
|
254 | * Returns the start of the month for the given date.
|
255 | *
|
256 | * @param date The original date.
|
257 | * @returns The start of the month.
|
258 | */
|
259 | startOfMonth: typeof startOfMonth;
|
260 | /**
|
261 | * Returns the start of the week for the given date.
|
262 | *
|
263 | * @param date The original date.
|
264 | * @returns The start of the week.
|
265 | */
|
266 | startOfWeek: typeof startOfWeek;
|
267 | /**
|
268 | * Returns the start of the year for the given date.
|
269 | *
|
270 | * @param date The original date.
|
271 | * @returns The start of the year.
|
272 | */
|
273 | startOfYear: typeof startOfYear;
|
274 | }
|
275 | /** The default locale (English). */
|
276 | export { enUS as defaultLocale } from "date-fns/locale/en-US";
|
277 | /**
|
278 | * The default date library with English locale.
|
279 | *
|
280 | * @since 9.2.0
|
281 | */
|
282 | export declare const defaultDateLib: DateLib;
|
283 | /** @deprecated Use `defaultDateLib`. */
|
284 | export declare const dateLib: DateLib;
|