@formkit/tempo 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,826 @@
1
+ /**
2
+ * The date format used as an input value. Either a date or an ISO8601 string.
3
+ */
4
+ type DateInput = Date | string;
5
+ /**
6
+ * The date format used as a maybe input value. Either a date, ISO8601 string or null for current time
7
+ */
8
+ type MaybeDateInput = DateInput | null;
9
+ /**
10
+ * Format parts with text names use these descriptors:
11
+ */
12
+ type NamedFormatOption = "long" | "short" | "narrow";
13
+ /**
14
+ * Extended part types that include custom tokens not in Intl.DateTimeFormatPartTypes.
15
+ */
16
+ type ExtendedPartTypes = Intl.DateTimeFormatPartTypes | "fractionalSecond";
17
+ /**
18
+ * A registry of named format parts. Each type of part has every option.
19
+ */
20
+ interface NamedFormats {
21
+ weekday: Record<string, NamedFormatOption>;
22
+ month: Record<string, NamedFormatOption>;
23
+ dayPeriod: Record<string, NamedFormatOption>;
24
+ }
25
+ /**
26
+ * Internal format for "pieces" of a date form. Each part represents a single
27
+ * logical grouping, like "month", or "seconds".
28
+ */
29
+ interface Part {
30
+ /**
31
+ * An object of partName to partValue For example:
32
+ * ```js
33
+ * { hour: '2-digit' }
34
+ * ```
35
+ */
36
+ option: FormatPattern[1];
37
+ /**
38
+ * The name of the part, these must be valid parts of a date format as
39
+ * specified in Intl.DateTimeFormatPartTypes, plus custom extensions.
40
+ * Valid values are: day, dayPeriod, era, hour, literal, minute, month,
41
+ * second, timeZoneName, weekday, year, fractionalSecond
42
+ */
43
+ partName: ExtendedPartTypes;
44
+ /**
45
+ * The value of a given part. For example "2-digit", or "narrow".
46
+ */
47
+ partValue: string;
48
+ /**
49
+ * The string token that represents the regex. For example "YYYY".
50
+ */
51
+ token: string;
52
+ /**
53
+ * A regular expression if the above token.
54
+ */
55
+ pattern: RegExp;
56
+ /**
57
+ * Does this part require a the hour12 clock.
58
+ */
59
+ hour12: boolean;
60
+ }
61
+ /**
62
+ * A date part with an actual value applied.
63
+ */
64
+ type FilledPart = Part & {
65
+ value: string;
66
+ };
67
+ /**
68
+ * A tuple describing a given formatting token.
69
+ */
70
+ type FormatPattern = [
71
+ pattern: FormatToken | string,
72
+ option: Partial<Record<ExtendedPartTypes, string>>,
73
+ exp?: RegExp
74
+ ];
75
+ /**
76
+ * Possible options for a format style.
77
+ */
78
+ type FormatStyle = "full" | "long" | "medium" | "short";
79
+ /**
80
+ * Possible objects for the dateStyle and timeStyle.
81
+ */
82
+ type FormatStyleObj = {
83
+ date: FormatStyle;
84
+ time: FormatStyle;
85
+ } | {
86
+ date: FormatStyle;
87
+ } | {
88
+ time: FormatStyle;
89
+ };
90
+ type Format = FormatStyle | FormatStyleObj | (string & {});
91
+ /**
92
+ * A union of all available formatting tokens.
93
+ */
94
+ type FormatToken = "YYYY" | "YY" | "MMMM" | "MMM" | "MM" | "M" | "DD" | "D" | "dddd" | "ddd" | "d" | "mm" | "m" | "ss" | "s" | "SSS" | "HH" | "H" | "hh" | "h" | "a" | "A" | "ZZ" | "Z";
95
+ interface ParseOptions {
96
+ /**
97
+ * A string representing a date.
98
+ */
99
+ date: string;
100
+ /**
101
+ * The format that should be used to parse the date. This is a string composed
102
+ * of tokens.
103
+ */
104
+ format: Format;
105
+ /**
106
+ * The locale used to parse the date.
107
+ */
108
+ locale: string;
109
+ /**
110
+ * A function that can be used to filter out parts of the format. This is
111
+ * useful when using the native Intl formats like
112
+ * `{ date: 'full', time: 'full' }` and not wanting to keep all the parts of
113
+ * the given format.
114
+ */
115
+ partFilter?: (part: Part) => boolean;
116
+ /**
117
+ * The behavior to use when a date overflows a given month. For example, if
118
+ * the date to parse is February 29, 2023 — there is no 29th day of February.
119
+ * In this case overflow "forward" would result in March 1, 2023, "backward"
120
+ * would result in February 28, 2023, and "throw" would throw an error.
121
+ */
122
+ dateOverflow?: "forward" | "backward" | "throw";
123
+ }
124
+ interface FormatOptions {
125
+ /**
126
+ * A date object or ISO 8601 string.
127
+ */
128
+ date: DateInput;
129
+ /**
130
+ * A format string or object.
131
+ */
132
+ format: Format;
133
+ /**
134
+ * A locale or en by default.
135
+ */
136
+ locale?: string;
137
+ /**
138
+ * Whether or not to escape literals.
139
+ */
140
+ genitive?: boolean;
141
+ /**
142
+ * A function to filter parts.
143
+ */
144
+ tz?: string;
145
+ /**
146
+ * A function to filter parts.
147
+ */
148
+ partFilter?: (part: Part) => boolean;
149
+ }
150
+ interface Duration {
151
+ years?: number;
152
+ months?: number;
153
+ weeks?: number;
154
+ days?: number;
155
+ hours?: number;
156
+ minutes?: number;
157
+ seconds?: number;
158
+ milliseconds?: number;
159
+ }
160
+ interface DurationObj extends Duration {
161
+ microseconds?: number;
162
+ nanoseconds?: number;
163
+ }
164
+
165
+ /**
166
+ * Returns a new Date object with the duration applied.
167
+ * @param [inputDate] - A date to increment or null to increment from the current time.
168
+ * @param duration - An object with values for the amount of time to add to the original date.
169
+ * @param [dateOverflow] - Whether to allow month/year changes to overflow into a later month.
170
+ */
171
+ declare function add(inputDate: MaybeDateInput, duration: Duration, dateOverflow?: boolean): Date;
172
+
173
+ /**
174
+ * Returns a new date object 1/n days after the original one.
175
+ * @param [inputDate] - A date to increment or null to increment from the current time.
176
+ * @param [count] - The quantity to add.
177
+ */
178
+ declare function addDay(inputDate?: MaybeDateInput, count?: number): Date;
179
+
180
+ /**
181
+ * Returns a new date object 1/n months after the original one. Keep in mind if you
182
+ * start with a date late in a given month you could get a date after the next
183
+ * month.
184
+ * @param [inputDate] - A date to increment or null to increment from the current time
185
+ * @param [count] - The quantity to add.
186
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
187
+ */
188
+ declare function addMonth(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
189
+
190
+ /**
191
+ * Returns a new date object 1/n years after the original one. Keep in mind if
192
+ * you start with a date late in a given month you could get a date after the
193
+ * next month.
194
+ * @param [inputDate] - A date to increment or null to increment from the current time.
195
+ * @param [count] - The quantity of years add.
196
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
197
+ */
198
+ declare function addYear(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
199
+
200
+ /**
201
+ * Returns a new date object 1/n hours after the original one.
202
+ * @param [inputDate] - A date to increment or null to increment from the current time.
203
+ * @param [count] - The quantity to add.
204
+ */
205
+ declare function addHour(inputDate?: MaybeDateInput, count?: number): Date;
206
+
207
+ /**
208
+ * Returns a new date object 1/n minutes after the original one.
209
+ * @param [inputDate] - A date to increment or null to increment from the current time.
210
+ * @param [count] - The quantity to add.
211
+ */
212
+ declare function addMinute(inputDate?: MaybeDateInput, count?: number): Date;
213
+
214
+ /**
215
+ * Returns a new date object 1/n seconds after the original one.
216
+ * @param [inputDate] - A date to increment or null to increment from the current time.
217
+ * @param [count] - The quantity to add.
218
+ */
219
+ declare function addSecond(inputDate?: MaybeDateInput, count?: number): Date;
220
+
221
+ /**
222
+ * Returns a new date object 1/n milliseconds after the original one.
223
+ * @param [inputDate] - A date to increment or null to increment from the current time.
224
+ * @param [count] - The quantity to add.
225
+ */
226
+ declare function addMillisecond(inputDate?: MaybeDateInput, count?: number): Date;
227
+
228
+ /**
229
+ * Determines the correct value for am/pm by locale and memoizes it.
230
+ * @param ampm - am or pm
231
+ * @param locale - The locale to fetch.
232
+ */
233
+ declare function ap(ampm: "am" | "pm", locale: string): string;
234
+
235
+ /**
236
+ * Apply a given offset to a date, returning a new date with the offset
237
+ * applied by adding or subtracting the given number of seconds.
238
+ * @param [dateInput] - The date to apply the offset to. (default: current time)
239
+ * @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.
240
+ */
241
+ declare function applyOffset(dateInput?: MaybeDateInput, offset?: string): Date;
242
+
243
+ /**
244
+ * A date to parse.
245
+ * @param date - A Date object or an ISO 8601 date.
246
+ */
247
+ declare function date(date?: MaybeDateInput): Date;
248
+
249
+ /**
250
+ * Creates a date object for the input date at the given timezone. For example
251
+ * `tzDate("2017-05-06T12:00", "Europe/Amsterdam")` will return a date object
252
+ * for 2017-05-06T10:00:00Z since 12:00 in Amsterdam is 10:00Z.
253
+ *
254
+ * If given a Date object it will use local time and convert it to the given
255
+ * timezone, thus "changing" the date.
256
+ *
257
+ * if given no string or date object, it'll use the current locale time and convert to the given timezone
258
+ * @param [inputDate] - An iso8601 date string with no timezone
259
+ * @param tz - A timezone string
260
+ */
261
+ declare function tzDate(inputDate: MaybeDateInput, tz: string): Date;
262
+
263
+ /**
264
+ * Gets the what day of the year a given date is. For example, August 1st is
265
+ * the 213th day of the year on non- years and 214th on leap years.
266
+ * @param [inputDate] - The input date or nothing for the current day.
267
+ */
268
+ declare function dayOfYear(inputDate?: MaybeDateInput): number;
269
+
270
+ /**
271
+ * Returns a Date object for end of the given day.
272
+ * @param [inputDate] - A string, Date object or nothing for the current day
273
+ */
274
+ declare function dayEnd(inputDate?: MaybeDateInput): Date;
275
+
276
+ /**
277
+ * Returns a Date object for start of the given day.
278
+ * @param [inputDate] - A string, Date object or nothing for the current day
279
+ */
280
+ declare function dayStart(inputDate?: MaybeDateInput): Date;
281
+
282
+ /**
283
+ * Produce a formatted string. Available strings:
284
+ * token | description
285
+ * ------|------------
286
+ * YY | 2 digit year
287
+ * YYYY | 4 digit year
288
+ * M | The month 1-12
289
+ * MM | The month 01-12
290
+ * MMM | Short name Jan-Dec
291
+ * MMMM | Full name January | December
292
+ * D | The day of the month 1-31
293
+ * DD | The day of the month 01-31
294
+ * d | Single digit day "T"
295
+ * ddd | Short day name Thu
296
+ * dddd | Full day name Wednesday
297
+ * H | Minimum hour digits, 24 hour, 0-23
298
+ * HH | 2 hour digits, 24 hour, 00-23
299
+ * h | Minimum hour digits, 12 hour clock, 1-12
300
+ * hh | 2 hour digits, 12 hour clock, 01-12
301
+ * m | The minute 0-59
302
+ * mm | The minute 00-59
303
+ * s | The second 0-59
304
+ * ss | The second 00-59
305
+ * a | am/pm
306
+ * A | AM/PM
307
+ * Z | +0800, +0530, -1345
308
+ *
309
+ * @param inputDate - A date object or ISO 8601 string
310
+ * @param format - A format
311
+ */
312
+ declare function format(options: FormatOptions): string;
313
+ declare function format(inputDate: DateInput, format?: Format, locale?: string, genitive?: boolean, partFilter?: (part: Part) => boolean): string;
314
+
315
+ /**
316
+ * Return the string format for a given format. For example:
317
+ * ```js
318
+ * formatStr({ date: 'long' }, 'en') // dddd, MMMM D, YYYY
319
+ * ```
320
+ * @param format - A format string or object.
321
+ * @param locale - A locale or en by default.
322
+ */
323
+ declare function formatStr(format: Format, locale?: string, escapeLiterals?: boolean, filterParts?: (part: Part) => boolean): string;
324
+
325
+ /**
326
+ * Converts a 2 digit year into a 4 digit year. This function assumes years 20
327
+ * years into the future belong to the current century, and the past 80 are in
328
+ * the past.
329
+ *
330
+ * @param value - 2 digits in string format
331
+ */
332
+ declare function fourDigitYear(value: string): number;
333
+
334
+ /**
335
+ * Returns a Date object for end of the given hour.
336
+ * @param [inputDate] - A string, Date object or nothing for the current time
337
+ */
338
+ declare function hourEnd(inputDate?: MaybeDateInput): Date;
339
+
340
+ /**
341
+ * Returns a Date object for start of the given hour.
342
+ * @param [inputDate] - A string, Date object or nothing for the current time
343
+ */
344
+ declare function hourStart(inputDate?: MaybeDateInput): Date;
345
+
346
+ /**
347
+ * True when the date string is valid ISO 8601.
348
+ * @param date - A date string.
349
+ */
350
+ declare function iso8601(date: string): boolean;
351
+
352
+ /**
353
+ * Returns a Date object for end of the given minute.
354
+ * @param [inputDate] - A string, Date object or nothing for the current time
355
+ */
356
+ declare function minuteEnd(inputDate?: MaybeDateInput): Date;
357
+
358
+ /**
359
+ * Returns a Date object for start of the given minute.
360
+ * @param [inputDate] - A string, Date object or nothing for the current time
361
+ */
362
+ declare function minuteStart(inputDate?: MaybeDateInput): Date;
363
+
364
+ /**
365
+ * Returns the total number of days from a given month.
366
+ * @param [inputDate] - A string, Date object or nothing for the current month
367
+ */
368
+ declare function monthDays(inputDate?: MaybeDateInput): number;
369
+
370
+ /**
371
+ * Returns a Date object for the with the input date set to the last day of
372
+ * the current month. Does not change the time.
373
+ * @param [inputDate] - A string, Date object or nothing for the current month
374
+ */
375
+ declare function monthEnd(inputDate?: MaybeDateInput): Date;
376
+
377
+ /**
378
+ * Returns a Date object for the first day of a month.
379
+ * @param [inputDate] - A string, Date object or nothing for the current time
380
+ */
381
+ declare function monthStart(inputDate?: MaybeDateInput): Date;
382
+
383
+ /**
384
+ * Performs a bidirectional search for the nearest date that passes a function.
385
+ * @param [inputDate] - Performs a search for the nearest passing date.
386
+ * @param search - The search function to use, given a date returns a boolean.
387
+ * @param constraint - The number of iterations to perform before giving up, or logical constraint like "month", or "week".
388
+ *
389
+ */
390
+ declare function nearestDay(inputDate: MaybeDateInput, search: (date: Date) => boolean, constraint?: number | "month" | "week" | "year"): Date | null;
391
+
392
+ /**
393
+ * Timezone tokens.
394
+ */
395
+ declare const timeZoneTokens: readonly ["Z", "ZZ"];
396
+ /**
397
+ * Timezone token type.
398
+ */
399
+ type TimezoneToken = (typeof timeZoneTokens)[number];
400
+
401
+ /**
402
+ * Returns the offset between two timezones on a given date. The results are
403
+ * ISO8601 compatible offsets like -0800 or +0530.
404
+ *
405
+ * @param [dateInput] - (default: current time) The date on which to determine the offset
406
+ * @param [tzA] - (default: UTC) The second timezone to compare determine the offset between.
407
+ * @param [tzB] - (default: device) The first timezone to compare determine the offset between.
408
+ */
409
+ declare function offset(utcTime?: MaybeDateInput, tzA?: string, tzB?: string, timeZoneToken?: TimezoneToken): string;
410
+
411
+ declare function parse(options: ParseOptions): Date | never;
412
+ declare function parse(dateStr: string, format?: Format, locale?: string): Date | never;
413
+ declare function parseParts(dateStr: string, formatParts: Part[], strict?: boolean): FilledPart[];
414
+
415
+ /**
416
+ * Given a format string, produce an array of matching "parts", each part
417
+ * contains a regular expression and the corresponding
418
+ * Intl.DateTimeFormatPartTypesRegistry key/value.
419
+ * @param format - A format string like MM/DD/YYYY
420
+ * @param locale - The locale to parse for.
421
+ */
422
+ declare function parts(format: Format, locale: string): Part[];
423
+
424
+ /**
425
+ * Returns an array of options for a given token in a given locale.
426
+ * @param token - Get the full range of options for a given token
427
+ * @param locale - The locale to fetch the options for.
428
+ */
429
+ declare function range(token: FormatToken, locale?: string, genitive?: boolean): string[];
430
+
431
+ /**
432
+ * Inverts the offset and applies it to the given date, returning a new date.
433
+ * @param [dateInput] - The date to remove the offset from. (default: current time)
434
+ * @param [offset] - The offset to remove in the +-HHmm or +-HH:mm format.
435
+ */
436
+ declare function removeOffset(dateInput?: MaybeDateInput, offset?: string): Date;
437
+
438
+ /**
439
+ * Checks if two date objects refer to the same date. Ignores time.
440
+ * @param inputDateA - First date to compare
441
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
442
+ */
443
+ declare function sameDay(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
444
+ /**
445
+ * Checks if two date objects refer to the same date. Ignores time.
446
+ * @param [inputDateA] - First date to compare or the current time if null given
447
+ * @param inputDateB - Second date to compare
448
+ */
449
+ declare function sameDay(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
450
+
451
+ /**
452
+ * Checks if two date objects refer to the same time minutes. Ignores date.
453
+ * @param inputDateA - First date to compare
454
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
455
+ */
456
+ declare function sameMonth(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
457
+ /**
458
+ * Checks if two date objects refer to the same time minutes. Ignores date.
459
+ * @param [inputDateA] - First date to compare or the current time if null given
460
+ * @param inputDateB - Second date to compare
461
+ */
462
+ declare function sameMonth(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
463
+
464
+ /**
465
+ * Checks if two date objects refer to the same time seconds. Ignores date.
466
+ * @param inputDateA - First date to compare
467
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
468
+ */
469
+ declare function sameSecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
470
+ /**
471
+ * Checks if two date objects refer to the same time seconds. Ignores date.
472
+ * @param [inputDateA] - First date to compare or the current time if null given
473
+ * @param inputDateB - Second date to compare
474
+ */
475
+ declare function sameSecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
476
+
477
+ /**
478
+ * Checks if two date objects refer to the same millisecond. Ignores date.
479
+ * @param inputDateA - First date to compare
480
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
481
+ */
482
+ declare function sameMillisecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
483
+ /**
484
+ * Checks if two date objects refer to the same millisecond. Ignores date.
485
+ * @param [inputDateA] - First date to compare or the current time if null given
486
+ * @param inputDateB - Second date to compare
487
+ */
488
+ declare function sameMillisecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
489
+
490
+ /**
491
+ * Checks if two date objects refer to the same time minutes. Ignores date.
492
+ * @param inputDateA - First date to compare
493
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
494
+ */
495
+ declare function sameMinute(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
496
+ /**
497
+ * Checks if two date objects refer to the same time minutes. Ignores date.
498
+ * @param [inputDateA] - First date to compare or the current time if null given
499
+ * @param inputDateB - Second date to compare
500
+ */
501
+ declare function sameMinute(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
502
+
503
+ /**
504
+ * Checks if two date objects refer to the same time hour. Ignores date.
505
+ * @param inputDateA - First date to compare
506
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
507
+ */
508
+ declare function sameHour(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
509
+ /**
510
+ * Checks if two date objects refer to the same time hour. Ignores date.
511
+ * @param [inputDateA] - First date to compare or the current time if null given
512
+ * @param inputDateB - Second date to compare
513
+ */
514
+ declare function sameHour(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
515
+
516
+ /**
517
+ * Checks if two date objects refer to the same year.
518
+ * @param inputDateA - First date to compare
519
+ * @param [inputDateB] - Second date to compare or the current time if null given
520
+ */
521
+ declare function sameYear(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
522
+ /**
523
+ * Checks if two date objects refer to the same year.
524
+ * @param [inputDateA] - First date to compare or the current time if null given
525
+ * @param inputDateB - Second date to compare
526
+ */
527
+ declare function sameYear(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
528
+
529
+ /**
530
+ * set the millisecond of a date object
531
+ * @param [inputDate] - a date or null for current time
532
+ * @param ms - the milliseconds you want the date set to (0 - 999) (can over/underflow)
533
+ */
534
+ declare function setMilliseconds(inputDate: MaybeDateInput, ms: number): Date;
535
+
536
+ /**
537
+ * set the second of a date object
538
+ * @param [inputDate] - a date or null for current time
539
+ * @param second - the second you want the date set to (0 - 59) (can over/underflow)
540
+ */
541
+ declare function setSeconds(inputDate: MaybeDateInput, second: number): Date;
542
+
543
+ /**
544
+ * set the minute of a date object
545
+ * @param [inputDate] - a date or null for current time
546
+ * @param minute - the minute you want the date set to (0 - 59) (can over/underflow)
547
+ */
548
+ declare function setMinutes(inputDate: MaybeDateInput, minute: number): Date;
549
+
550
+ /**
551
+ * set the hour of a date object
552
+ * @param [inputDate] - a date or null for current time
553
+ * @param hour - the hour you want the date set to (0 - 23) (can over/underflow)
554
+ */
555
+ declare function setHour(inputDate: MaybeDateInput, hour: number): Date;
556
+
557
+ /**
558
+ * set the day of the month in a date object
559
+ * @param [inputDate] - a date or null for current time
560
+ * @param day - the day of the month you want the date set to (1-28/29/30/31) (can over/underflow)
561
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the given day isn't in the current month
562
+ */
563
+ declare function setDayOfMonth(inputDate: MaybeDateInput, day: number, dateOverflow?: boolean): Date;
564
+
565
+ /**
566
+ * set the month of a date
567
+ * @param [inputDate] - a date or null for current time
568
+ * @param month - the zero-based month to set (0-11, where 0 is January) (can over/underflow)
569
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
570
+ */
571
+ declare function setMonth(inputDate: MaybeDateInput, month: number, dateOverflow?: boolean): Date;
572
+
573
+ /**
574
+ * set the year of a date object
575
+ * @param inputDate - a date or null for current time
576
+ * @param year - the full year you want the date to be set to
577
+ * @param [dateOverflow] - Whether or not to allow the date to overflow to another month if the inputDate’s month is out of range of the new month.
578
+ */
579
+ declare function setYear(inputDate: MaybeDateInput, year: number, dateOverflow?: boolean): Date;
580
+
581
+ /**
582
+ * Returns a Date object for the last day at the last second of the given week.
583
+ * Defaults to Sunday as the first day of the week:
584
+ * 0 = Sunday ... 6 = Saturday
585
+ * @param [inputDate] - Gets the last day of the week
586
+ * @param [startOfWeekDay] - The first day of the week
587
+ */
588
+ declare function weekEnd(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
589
+
590
+ /**
591
+ * Returns a Date object for start of the given week. Defaults to Sunday as the
592
+ * first day of the week:
593
+ * 0 = Sunday ... 6 = Saturday
594
+ * @param [inputDate] - A string, Date object or nothing for current week
595
+ * @param [startOfWeekDay] - Determines which day of the week is the first
596
+ */
597
+ declare function weekStart(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
598
+
599
+ /**
600
+ * Get the number of days in the given date’s year.
601
+ * @param [inputDate] - A string, Date object or nothing for the current year
602
+ */
603
+ declare function yearDays(inputDate?: MaybeDateInput): number;
604
+
605
+ /**
606
+ * Returns a Date object for the with the input date set to the start of the current year.
607
+ * @param [inputDate] - A string, Date object or nothing for the current year
608
+ */
609
+ declare function yearStart(inputDate?: MaybeDateInput): Date;
610
+
611
+ /**
612
+ * Returns a Date object for the with the input date set to the end of the current year.
613
+ * @param [inputDate] - A string, Date object or nothing for the current year
614
+ */
615
+ declare function yearEnd(inputDate?: MaybeDateInput): Date;
616
+
617
+ /**
618
+ * Is the first date before the second one or the current time?
619
+ *
620
+ * @param inputDate - The date that should be before the other one to return true
621
+ * @param [dateToCompare] - The date to compare with or the current time if nothing given
622
+ *
623
+ * @returns The first date is before the second date or the current time.
624
+ */
625
+ declare function isBefore(inputDate: DateInput, dateToCompare?: MaybeDateInput): boolean;
626
+
627
+ /**
628
+ * @name isAfter
629
+ * @category Common Helpers
630
+ * @summary Is the first date after the second one or the current time?
631
+ *
632
+ * @description
633
+ * Is the first date after the second one or the current time?
634
+ *
635
+ * @param inputDate - The date that should be after the other one to return true
636
+ * @param [dateToCompare] - The date to compare with or the current time if nothing given
637
+ *
638
+ * @returns The first date is after the second date or the current time.
639
+ */
640
+ declare function isAfter(inputDate: DateInput, dateToCompare?: MaybeDateInput): boolean;
641
+
642
+ /**
643
+ * Are the given dates equal or given date to the current time?
644
+ *
645
+ * @param dateLeft - The first date to compare
646
+ * @param [dateRight] - The second date to compare or the current time of nothing given
647
+ *
648
+ * @returns The dates are equal or date to the current time
649
+ */
650
+ declare function isEqual(dateLeft: DateInput, dateRight?: MaybeDateInput): boolean;
651
+ /**
652
+ * Are the given dates equal or given date to the current time?
653
+ *
654
+ * @param [dateLeft] - The first date to compare or the current time if null given
655
+ * @param dateRight - The second date to compare
656
+ *
657
+ * @returns The dates are equal or date to the current time
658
+ */
659
+ declare function isEqual(dateLeft: MaybeDateInput, dateRight: DateInput): boolean;
660
+
661
+ /**
662
+ * is the date in the past compared to the current time
663
+ * @param inputDate - The date that should be in the past
664
+ * @returns the given date is in the past compared to the current time
665
+ */
666
+ declare function isPast(inputDate: DateInput): boolean;
667
+
668
+ /**
669
+ * is the date in the future compared to the current time
670
+ * @param inputDate - The date that should be in the future
671
+ * @returns the given date is in the future compared to the current time
672
+ */
673
+ declare function isFuture(inputDate: DateInput): boolean;
674
+
675
+ /**
676
+ * Returns the difference between 2 dates in milliseconds.
677
+ * @param dateA - A date to compare with the right date
678
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
679
+ */
680
+ declare function diffMilliseconds(dateA: DateInput, dateB?: MaybeDateInput): number;
681
+ /**
682
+ * Returns the difference between 2 dates in milliseconds.
683
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
684
+ * @param dateB - A date to compare with the left date
685
+ */
686
+ declare function diffMilliseconds(dateA: MaybeDateInput, dateB: DateInput): number;
687
+
688
+ type DiffRoundingMethod = "trunc" | "round" | "floor" | "ceil";
689
+
690
+ /**
691
+ * Returns the difference between 2 dates in seconds.
692
+ * @param dateA - A date to compare with the right date
693
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time.
694
+ * @param [roundingMethod] - the rounding method to use, default: trunc
695
+ */
696
+ declare function diffSeconds(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
697
+ /**
698
+ * Returns the difference between 2 dates in seconds.
699
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
700
+ * @param dateB - A date to compare with the left date
701
+ * @param [roundingMethod] - the rounding method to use, default: trunc
702
+ */
703
+ declare function diffSeconds(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
704
+
705
+ /**
706
+ * Returns the difference between 2 dates in minutes.
707
+ * @param dateA - A date to compare with the right date
708
+ * @param [dateB] - A Date to compare with the left date or nothing to compare with the current time
709
+ * @param [roundingMethod] the rounding method to use, default: trunc
710
+ */
711
+ declare function diffMinutes(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
712
+ /**
713
+ * Returns the difference between 2 dates in minutes.
714
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
715
+ * @param dateB - A Date to compare with the left date
716
+ * @param [roundingMethod] the rounding method to use, default: trunc
717
+ */
718
+ declare function diffMinutes(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
719
+
720
+ /**
721
+ * Returns the difference between 2 dates in hours.
722
+ * @param dateA - A date to compare with the right date
723
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
724
+ * @param [roundingMethod] - the rounding method to use, default: trunc
725
+ */
726
+ declare function diffHours(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
727
+ /**
728
+ * Returns the difference between 2 dates in hours.
729
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
730
+ * @param dateB - A date to compare with the left date
731
+ * @param [roundingMethod] - the rounding method to use, default: trunc
732
+ */
733
+ declare function diffHours(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
734
+
735
+ /**
736
+ * Returns the difference between 2 dates in days.
737
+ * @param dateA - A date to compare with the right date
738
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
739
+ * @param [roundingMethod] - the rounding method to use, default: trunc
740
+ */
741
+ declare function diffDays(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
742
+ /**
743
+ * Returns the difference between 2 dates in days.
744
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
745
+ * @param dateB - A date to compare with the left date
746
+ * @param [roundingMethod] - the rounding method to use, default: trunc
747
+ */
748
+ declare function diffDays(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
749
+
750
+ /**
751
+ * Returns the difference between 2 dates in weeks.
752
+ * @param dateA - A date to compare with the right date
753
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
754
+ * @param [roundingMethod] - the rounding method to use, default: trunc
755
+ */
756
+ declare function diffWeeks(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
757
+ /**
758
+ * Returns the difference between 2 dates in weeks.
759
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
760
+ * @param dateB - A date to compare with the left date
761
+ * @param [roundingMethod] - the rounding method to use, default: trunc
762
+ */
763
+ declare function diffWeeks(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
764
+
765
+ /**
766
+ * Returns the difference between 2 dates in months.
767
+ * @param dateA - A date to compare with the dateB date
768
+ * @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
769
+ */
770
+ declare function diffMonths(dateA: DateInput, dateB?: MaybeDateInput): number;
771
+ /**
772
+ * Returns the difference between 2 dates in months.
773
+ * @param [dateA] - A date to compare with the dateB date or null to compare with the current time
774
+ * @param dateB - A date to compare with the dateA date
775
+ */
776
+ declare function diffMonths(dateA: MaybeDateInput, dateB: DateInput): number;
777
+
778
+ /**
779
+ * Returns the difference between 2 dates in years.
780
+ * @param dateA - A date to compare with the dateB date
781
+ * @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
782
+ */
783
+ declare function diffYears(dateA: DateInput, dateB?: MaybeDateInput): number;
784
+ /**
785
+ * Returns the difference between 2 dates in years.
786
+ * @param [dateA] - A date to compare with the dateB date or null to compare with the current time
787
+ * @param dateB - A date to compare with the dateA date
788
+ */
789
+ declare function diffYears(dateA: MaybeDateInput, dateB: DateInput): number;
790
+
791
+ type DurationKey = keyof Duration;
792
+ /**
793
+ * Options for `diff` function
794
+ */
795
+ interface DiffOptions {
796
+ /**
797
+ * whether the difference should be absolute (not negative)
798
+ */
799
+ abs?: boolean;
800
+ /**
801
+ * units you want to skip, for example weeks
802
+ */
803
+ skip?: DurationKey[] | Set<DurationKey>;
804
+ }
805
+ /**
806
+ * Returns the difference between 2 dates in an object
807
+ * @param dateA - A date to compare with the right date
808
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
809
+ * @param [options] additional options
810
+ * @param [options.skip] units you want skip
811
+ * @param [options.abs] whether the difference should be absolute
812
+ * @returns an object which could be used with `Intl.DurationFormat.format'`
813
+ */
814
+ declare function diff(dateA: DateInput, dateB?: MaybeDateInput, options?: DiffOptions): Duration;
815
+ /**
816
+ * Returns the difference between 2 dates in an object
817
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
818
+ * @param dateB - A date to compare with the left date
819
+ * @param [options] additional options
820
+ * @param [options.skip] units you want skip
821
+ * @param [options.abs] whether the difference should be absolute
822
+ * @returns an object which could be used with `Intl.DurationFormat.format'`
823
+ */
824
+ declare function diff(dateA: MaybeDateInput, dateB: DateInput, options?: DiffOptions): Duration;
825
+
826
+ export { type DateInput, type DiffOptions, type Duration, type DurationObj, type ExtendedPartTypes, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type MaybeDateInput, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, add, addDay, addHour, addMillisecond, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diff, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, isFuture, isPast, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMillisecond, sameMinute, sameMonth, sameSecond, sameYear, setDayOfMonth, setHour, setMilliseconds, setMinutes, setMonth, setSeconds, setYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };