@formkit/tempo 0.1.1 → 1.0.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.
Files changed (147) hide show
  1. package/dist/addDay.d.ts +4 -3
  2. package/dist/addDay.mjs.map +1 -1
  3. package/dist/addHour.d.ts +4 -3
  4. package/dist/addHour.mjs.map +1 -1
  5. package/dist/addMillisecond.d.ts +10 -0
  6. package/dist/addMillisecond.mjs +11 -0
  7. package/dist/addMillisecond.mjs.map +1 -0
  8. package/dist/addMinute.d.ts +5 -4
  9. package/dist/addMinute.mjs.map +1 -1
  10. package/dist/addMonth.d.ts +5 -5
  11. package/dist/addMonth.mjs +1 -2
  12. package/dist/addMonth.mjs.map +1 -1
  13. package/dist/addSecond.d.ts +4 -3
  14. package/dist/addSecond.mjs.map +1 -1
  15. package/dist/addYear.d.ts +5 -5
  16. package/dist/addYear.mjs +1 -2
  17. package/dist/addYear.mjs.map +1 -1
  18. package/dist/ap.mjs +1 -2
  19. package/dist/ap.mjs.map +1 -1
  20. package/dist/applyOffset.d.ts +5 -5
  21. package/dist/applyOffset.mjs +5 -11
  22. package/dist/applyOffset.mjs.map +1 -1
  23. package/dist/bundle.d.ts +256 -115
  24. package/dist/bundle.mjs +158 -140
  25. package/dist/bundle.mjs.map +1 -1
  26. package/dist/common.d.ts +27 -7
  27. package/dist/common.mjs +47 -42
  28. package/dist/common.mjs.map +1 -1
  29. package/dist/date.d.ts +2 -2
  30. package/dist/date.mjs +1 -3
  31. package/dist/date.mjs.map +1 -1
  32. package/dist/dayEnd.d.ts +3 -3
  33. package/dist/dayEnd.mjs.map +1 -1
  34. package/dist/dayOfYear.d.ts +3 -3
  35. package/dist/dayOfYear.mjs.map +1 -1
  36. package/dist/dayStart.d.ts +3 -3
  37. package/dist/dayStart.mjs +1 -1
  38. package/dist/dayStart.mjs.map +1 -1
  39. package/dist/diffDays.d.ts +12 -5
  40. package/dist/diffDays.mjs +1 -0
  41. package/dist/diffDays.mjs.map +1 -1
  42. package/dist/diffHours.d.ts +12 -5
  43. package/dist/diffHours.mjs +1 -0
  44. package/dist/diffHours.mjs.map +1 -1
  45. package/dist/diffMilliseconds.d.ts +10 -4
  46. package/dist/diffMilliseconds.mjs.map +1 -1
  47. package/dist/diffMinutes.d.ts +11 -3
  48. package/dist/diffMinutes.mjs +5 -1
  49. package/dist/diffMinutes.mjs.map +1 -1
  50. package/dist/diffMonths.d.ts +10 -4
  51. package/dist/diffMonths.mjs.map +1 -1
  52. package/dist/diffSeconds.d.ts +12 -5
  53. package/dist/diffSeconds.mjs +5 -1
  54. package/dist/diffSeconds.mjs.map +1 -1
  55. package/dist/diffWeeks.d.ts +10 -3
  56. package/dist/diffWeeks.mjs.map +1 -1
  57. package/dist/diffYears.d.ts +10 -4
  58. package/dist/diffYears.mjs +4 -1
  59. package/dist/diffYears.mjs.map +1 -1
  60. package/dist/format.mjs +2 -3
  61. package/dist/format.mjs.map +1 -1
  62. package/dist/hourEnd.d.ts +3 -3
  63. package/dist/hourEnd.mjs.map +1 -1
  64. package/dist/hourStart.d.ts +3 -3
  65. package/dist/hourStart.mjs +1 -1
  66. package/dist/hourStart.mjs.map +1 -1
  67. package/dist/index.cjs +165 -143
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.cts +256 -115
  70. package/dist/index.d.ts +5 -1
  71. package/dist/index.mjs +8 -0
  72. package/dist/index.mjs.map +1 -1
  73. package/dist/isAfter.d.ts +6 -6
  74. package/dist/isAfter.mjs.map +1 -1
  75. package/dist/isBefore.d.ts +5 -5
  76. package/dist/isBefore.mjs.map +1 -1
  77. package/dist/isEqual.d.ts +13 -4
  78. package/dist/isEqual.mjs.map +1 -1
  79. package/dist/isFuture.d.ts +10 -0
  80. package/dist/isFuture.mjs +9 -0
  81. package/dist/isFuture.mjs.map +1 -0
  82. package/dist/isPast.d.ts +10 -0
  83. package/dist/isPast.mjs +9 -0
  84. package/dist/isPast.mjs.map +1 -0
  85. package/dist/iso8601.d.ts +1 -1
  86. package/dist/iso8601.mjs +4 -7
  87. package/dist/iso8601.mjs.map +1 -1
  88. package/dist/minuteEnd.d.ts +3 -3
  89. package/dist/minuteEnd.mjs.map +1 -1
  90. package/dist/minuteStart.d.ts +3 -3
  91. package/dist/minuteStart.mjs +1 -1
  92. package/dist/minuteStart.mjs.map +1 -1
  93. package/dist/monthDays.d.ts +3 -3
  94. package/dist/monthDays.mjs.map +1 -1
  95. package/dist/monthEnd.d.ts +3 -3
  96. package/dist/monthEnd.mjs.map +1 -1
  97. package/dist/monthStart.d.ts +3 -3
  98. package/dist/monthStart.mjs +1 -1
  99. package/dist/monthStart.mjs.map +1 -1
  100. package/dist/nearestDay.d.ts +3 -3
  101. package/dist/nearestDay.mjs +2 -4
  102. package/dist/nearestDay.mjs.map +1 -1
  103. package/dist/offset.d.ts +5 -5
  104. package/dist/offset.mjs +3 -3
  105. package/dist/offset.mjs.map +1 -1
  106. package/dist/parse.mjs +33 -23
  107. package/dist/parse.mjs.map +1 -1
  108. package/dist/parts.mjs +14 -24
  109. package/dist/parts.mjs.map +1 -1
  110. package/dist/range.mjs +1 -2
  111. package/dist/range.mjs.map +1 -1
  112. package/dist/removeOffset.d.ts +4 -4
  113. package/dist/removeOffset.mjs.map +1 -1
  114. package/dist/sameDay.d.ts +8 -2
  115. package/dist/sameDay.mjs.map +1 -1
  116. package/dist/sameHour.d.ts +8 -2
  117. package/dist/sameHour.mjs.map +1 -1
  118. package/dist/sameMillisecond.d.ts +16 -0
  119. package/dist/sameMillisecond.mjs +11 -0
  120. package/dist/sameMillisecond.mjs.map +1 -0
  121. package/dist/sameMinute.d.ts +8 -2
  122. package/dist/sameMinute.mjs.map +1 -1
  123. package/dist/sameMonth.d.ts +16 -0
  124. package/dist/sameMonth.mjs +11 -0
  125. package/dist/sameMonth.mjs.map +1 -0
  126. package/dist/sameSecond.d.ts +8 -2
  127. package/dist/sameSecond.mjs.map +1 -1
  128. package/dist/sameYear.d.ts +8 -2
  129. package/dist/sameYear.mjs.map +1 -1
  130. package/dist/types.d.ts +15 -7
  131. package/dist/tzDate.d.ts +5 -3
  132. package/dist/tzDate.mjs.map +1 -1
  133. package/dist/weekEnd.d.ts +4 -4
  134. package/dist/weekEnd.mjs +1 -1
  135. package/dist/weekEnd.mjs.map +1 -1
  136. package/dist/weekStart.d.ts +4 -4
  137. package/dist/weekStart.mjs +2 -3
  138. package/dist/weekStart.mjs.map +1 -1
  139. package/dist/yearDays.d.ts +3 -3
  140. package/dist/yearDays.mjs.map +1 -1
  141. package/dist/yearEnd.d.ts +3 -3
  142. package/dist/yearEnd.mjs +1 -2
  143. package/dist/yearEnd.mjs.map +1 -1
  144. package/dist/yearStart.d.ts +3 -3
  145. package/dist/yearStart.mjs +2 -3
  146. package/dist/yearStart.mjs.map +1 -1
  147. package/package.json +32 -23
package/dist/bundle.d.ts CHANGED
@@ -2,10 +2,18 @@
2
2
  * The date format used as an input value. Either a date or an ISO8601 string.
3
3
  */
4
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;
5
9
  /**
6
10
  * Format parts with text names use these descriptors:
7
11
  */
8
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";
9
17
  /**
10
18
  * A registry of named format parts. Each type of part has every option.
11
19
  */
@@ -28,11 +36,11 @@ interface Part {
28
36
  option: FormatPattern[1];
29
37
  /**
30
38
  * The name of the part, these must be valid parts of a date format as
31
- * specified in Intl.DateTimeFormatPartTypes. Valid values are:
32
- * day, dayPeriod, era, hour, literal, minute, month, second, timeZoneName,
33
- * weekday, year
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
34
42
  */
35
- partName: Intl.DateTimeFormatPartTypes;
43
+ partName: ExtendedPartTypes;
36
44
  /**
37
45
  * The value of a given part. For example "2-digit", or "narrow".
38
46
  */
@@ -61,7 +69,7 @@ type FilledPart = Part & {
61
69
  */
62
70
  type FormatPattern = [
63
71
  pattern: FormatToken | string,
64
- option: Partial<Record<Intl.DateTimeFormatPartTypes, string>>,
72
+ option: Partial<Record<ExtendedPartTypes, string>>,
65
73
  exp?: RegExp
66
74
  ];
67
75
  /**
@@ -83,7 +91,7 @@ type Format = FormatStyle | FormatStyleObj | (string & {});
83
91
  /**
84
92
  * A union of all available formatting tokens.
85
93
  */
86
- type FormatToken = "YYYY" | "YY" | "MMMM" | "MMM" | "MM" | "M" | "DD" | "D" | "dddd" | "ddd" | "d" | "mm" | "m" | "ss" | "s" | "HH" | "H" | "hh" | "h" | "a" | "A" | "ZZ" | "Z";
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";
87
95
  interface ParseOptions {
88
96
  /**
89
97
  * A string representing a date.
@@ -142,47 +150,58 @@ interface FormatOptions {
142
150
 
143
151
  /**
144
152
  * Returns a new date object 1/n days after the original one.
145
- * @param inputDate - A date to increment by 1 day.
153
+ * @param [inputDate] - A date to increment or null to increment from the current time.
154
+ * @param [count] - The quantity to add.
146
155
  */
147
- declare function addDay(inputDate: DateInput, count?: number): Date;
156
+ declare function addDay(inputDate?: MaybeDateInput, count?: number): Date;
148
157
 
149
158
  /**
150
159
  * Returns a new date object 1/n months after the original one. Keep in mind if you
151
160
  * start with a date late in a given month you could get a date after the next
152
161
  * month.
153
- * @param inputDate - A date to increment by 1 or more months.
154
- * @param count - The quantity to add.
155
- * @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.
162
+ * @param [inputDate] - A date to increment or null to increment from the current time
163
+ * @param [count] - The quantity to add.
164
+ * @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.
156
165
  */
157
- declare function addMonth(inputDate: DateInput, count?: number, dateOverflow?: boolean): Date;
166
+ declare function addMonth(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
158
167
 
159
168
  /**
160
169
  * Returns a new date object 1/n years after the original one. Keep in mind if
161
170
  * you start with a date late in a given month you could get a date after the
162
171
  * next month.
163
- * @param inputDate - A date to increment by 1 day.
164
- * @param count - The quantity of years add.
165
- * @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.
172
+ * @param [inputDate] - A date to increment or null to increment from the current time.
173
+ * @param [count] - The quantity of years add.
174
+ * @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.
166
175
  */
167
- declare function addYear(inputDate: DateInput, count?: number, dateOverflow?: boolean): Date;
176
+ declare function addYear(inputDate?: MaybeDateInput, count?: number, dateOverflow?: boolean): Date;
168
177
 
169
178
  /**
170
179
  * Returns a new date object 1/n hours after the original one.
171
- * @param inputDate - A date to increment by 1 day.
180
+ * @param [inputDate] - A date to increment or null to increment from the current time.
181
+ * @param [count] - The quantity to add.
172
182
  */
173
- declare function addHour(inputDate: DateInput, count?: number): Date;
183
+ declare function addHour(inputDate?: MaybeDateInput, count?: number): Date;
174
184
 
175
185
  /**
176
- * Returns a new date object 1/n seconds after the original one.
177
- * @param inputDate - A date to increment by 1 day.
186
+ * Returns a new date object 1/n minutes after the original one.
187
+ * @param [inputDate] - A date to increment or null to increment from the current time.
188
+ * @param [count] - The quantity to add.
178
189
  */
179
- declare function addMinute(inputDate: DateInput, count?: number): Date;
190
+ declare function addMinute(inputDate?: MaybeDateInput, count?: number): Date;
180
191
 
181
192
  /**
182
193
  * Returns a new date object 1/n seconds after the original one.
183
- * @param inputDate - A date to increment by 1 day.
194
+ * @param [inputDate] - A date to increment or null to increment from the current time.
195
+ * @param [count] - The quantity to add.
184
196
  */
185
- declare function addSecond(inputDate: DateInput, count?: number): Date;
197
+ declare function addSecond(inputDate?: MaybeDateInput, count?: number): Date;
198
+
199
+ /**
200
+ * Returns a new date object 1/n milliseconds after the original one.
201
+ * @param [inputDate] - A date to increment or null to increment from the current time.
202
+ * @param [count] - The quantity to add.
203
+ */
204
+ declare function addMillisecond(inputDate?: MaybeDateInput, count?: number): Date;
186
205
 
187
206
  /**
188
207
  * Determines the correct value for am/pm by locale and memoizes it.
@@ -193,17 +212,17 @@ declare function ap(ampm: "am" | "pm", locale: string): string;
193
212
 
194
213
  /**
195
214
  * Apply a given offset to a date, returning a new date with the offset
196
- * applied by adding or subtracting the given number of minutes.
197
- * @param dateInput - The date to apply the offset to.
198
- * @param offset - The offset to apply in the +-HHmm or +-HH:mm format.
215
+ * applied by adding or subtracting the given number of seconds.
216
+ * @param [dateInput] - The date to apply the offset to. (default: current time)
217
+ * @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.
199
218
  */
200
- declare function applyOffset(dateInput: DateInput, offset?: string): Date;
219
+ declare function applyOffset(dateInput?: MaybeDateInput, offset?: string): Date;
201
220
 
202
221
  /**
203
222
  * A date to parse.
204
223
  * @param date - A Date object or an ISO 8601 date.
205
224
  */
206
- declare function date(date?: DateInput): Date;
225
+ declare function date(date?: MaybeDateInput): Date;
207
226
 
208
227
  /**
209
228
  * Creates a date object for the input date at the given timezone. For example
@@ -212,29 +231,31 @@ declare function date(date?: DateInput): Date;
212
231
  *
213
232
  * If given a Date object it will use local time and convert it to the given
214
233
  * timezone, thus "changing" the date.
215
- * @param inputDate - An iso8601 date string with no timezone
234
+ *
235
+ * if given no string or date object, it'll use the current locale time and convert to the given timezone
236
+ * @param [inputDate] - An iso8601 date string with no timezone
216
237
  * @param tz - A timezone string
217
238
  */
218
- declare function tzDate(inputDate: DateInput, tz: string): Date;
239
+ declare function tzDate(inputDate: MaybeDateInput, tz: string): Date;
219
240
 
220
241
  /**
221
242
  * Gets the what day of the year a given date is. For example, August 1st is
222
243
  * the 213th day of the year on non- years and 214th on leap years.
223
- * @param inputDate - The input date.
244
+ * @param [inputDate] - The input date or nothing for the current day.
224
245
  */
225
- declare function dayOfYear(inputDate: DateInput): number;
246
+ declare function dayOfYear(inputDate?: MaybeDateInput): number;
226
247
 
227
248
  /**
228
249
  * Returns a Date object for end of the given day.
229
- * @param inputDate - A string or Date object
250
+ * @param [inputDate] - A string, Date object or nothing for the current day
230
251
  */
231
- declare function dayEnd(inputDate: DateInput): Date;
252
+ declare function dayEnd(inputDate?: MaybeDateInput): Date;
232
253
 
233
254
  /**
234
255
  * Returns a Date object for start of the given day.
235
- * @param inputDate - A string or Date object
256
+ * @param [inputDate] - A string, Date object or nothing for the current day
236
257
  */
237
- declare function dayStart(inputDate: DateInput): Date;
258
+ declare function dayStart(inputDate?: MaybeDateInput): Date;
238
259
 
239
260
  /**
240
261
  * Produce a formatted string. Available strings:
@@ -290,15 +311,15 @@ declare function fourDigitYear(value: string): number;
290
311
 
291
312
  /**
292
313
  * Returns a Date object for end of the given hour.
293
- * @param inputDate - A string or Date object
314
+ * @param [inputDate] - A string, Date object or nothing for the current time
294
315
  */
295
- declare function hourEnd(inputDate: DateInput): Date;
316
+ declare function hourEnd(inputDate?: MaybeDateInput): Date;
296
317
 
297
318
  /**
298
319
  * Returns a Date object for start of the given hour.
299
- * @param inputDate - A string or Date object
320
+ * @param [inputDate] - A string, Date object or nothing for the current time
300
321
  */
301
- declare function hourStart(inputDate: DateInput): Date;
322
+ declare function hourStart(inputDate?: MaybeDateInput): Date;
302
323
 
303
324
  /**
304
325
  * True when the date string is valid ISO 8601.
@@ -308,43 +329,43 @@ declare function iso8601(date: string): boolean;
308
329
 
309
330
  /**
310
331
  * Returns a Date object for end of the given minute.
311
- * @param inputDate - A string or Date object
332
+ * @param [inputDate] - A string, Date object or nothing for the current time
312
333
  */
313
- declare function minuteEnd(inputDate: DateInput): Date;
334
+ declare function minuteEnd(inputDate?: MaybeDateInput): Date;
314
335
 
315
336
  /**
316
337
  * Returns a Date object for start of the given minute.
317
- * @param inputDate - A string or Date object
338
+ * @param [inputDate] - A string, Date object or nothing for the current time
318
339
  */
319
- declare function minuteStart(inputDate: DateInput): Date;
340
+ declare function minuteStart(inputDate?: MaybeDateInput): Date;
320
341
 
321
342
  /**
322
343
  * Returns the total number of days from a given month.
323
- * @param inputDate - A string or Date object
344
+ * @param [inputDate] - A string, Date object or nothing for the current month
324
345
  */
325
- declare function monthDays(inputDate: DateInput): number;
346
+ declare function monthDays(inputDate?: MaybeDateInput): number;
326
347
 
327
348
  /**
328
349
  * Returns a Date object for the with the input date set to the last day of
329
350
  * the current month. Does not change the time.
330
- * @param inputDate - A string or Date object
351
+ * @param [inputDate] - A string, Date object or nothing for the current month
331
352
  */
332
- declare function monthEnd(inputDate: DateInput): Date;
353
+ declare function monthEnd(inputDate?: MaybeDateInput): Date;
333
354
 
334
355
  /**
335
356
  * Returns a Date object for the first day of a month.
336
- * @param inputDate - A string or Date object
357
+ * @param [inputDate] - A string, Date object or nothing for the current time
337
358
  */
338
- declare function monthStart(inputDate: DateInput): Date;
359
+ declare function monthStart(inputDate?: MaybeDateInput): Date;
339
360
 
340
361
  /**
341
362
  * Performs a bidirectional search for the nearest date that passes a function.
342
- * @param target - Performs a search for the nearest passing date.
363
+ * @param [inputDate] - Performs a search for the nearest passing date.
343
364
  * @param search - The search function to use, given a date returns a boolean.
344
365
  * @param constraint - The number of iterations to perform before giving up, or logical constraint like "month", or "week".
345
366
  *
346
367
  */
347
- declare function nearestDay(inputDate: DateInput, search: (date: Date) => boolean, constraint?: number | "month" | "week" | "year"): Date | null;
368
+ declare function nearestDay(inputDate: MaybeDateInput, search: (date: Date) => boolean, constraint?: number | "month" | "week" | "year"): Date | null;
348
369
 
349
370
  /**
350
371
  * Timezone tokens.
@@ -359,11 +380,11 @@ type TimezoneToken = (typeof timeZoneTokens)[number];
359
380
  * Returns the offset between two timezones on a given date. The results are
360
381
  * ISO8601 compatible offsets like -0800 or +0530.
361
382
  *
362
- * @param dateInput - The date on which to determine the offset.
363
- * @param tzA - (default: UTC) The second timezone to compare determine the offset between.
364
- * @param tzB - (default: device) The first timezone to compare determine the offset between.
383
+ * @param [dateInput] - (default: current time) The date on which to determine the offset
384
+ * @param [tzA] - (default: UTC) The second timezone to compare determine the offset between.
385
+ * @param [tzB] - (default: device) The first timezone to compare determine the offset between.
365
386
  */
366
- declare function offset(utcTime: DateInput, tzA?: string, tzB?: string, timeZoneToken?: TimezoneToken): string;
387
+ declare function offset(utcTime?: MaybeDateInput, tzA?: string, tzB?: string, timeZoneToken?: TimezoneToken): string;
367
388
 
368
389
  declare function parse(options: ParseOptions): Date | never;
369
390
  declare function parse(dateStr: string, format?: Format, locale?: string): Date | never;
@@ -393,177 +414,297 @@ declare function range(token: FormatToken, locale?: string, genitive?: boolean):
393
414
 
394
415
  /**
395
416
  * Inverts the offset and applies it to the given date, returning a new date.
396
- * @param dateInput - The date to remove the offset from.
397
- * @param offset - The offset to remove in the +-HHmm or +-HH:mm format.
417
+ * @param [dateInput] - The date to remove the offset from. (default: current time)
418
+ * @param [offset] - The offset to remove in the +-HHmm or +-HH:mm format.
398
419
  */
399
- declare function removeOffset(dateInput: DateInput, offset?: string): Date;
420
+ declare function removeOffset(dateInput?: MaybeDateInput, offset?: string): Date;
400
421
 
401
422
  /**
402
423
  * Checks if two date objects refer to the same date. Ignores time.
403
424
  * @param inputDateA - First date to compare
425
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
426
+ */
427
+ declare function sameDay(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
428
+ /**
429
+ * Checks if two date objects refer to the same date. Ignores time.
430
+ * @param [inputDateA] - First date to compare or the current time if null given
404
431
  * @param inputDateB - Second date to compare
405
432
  */
406
- declare function sameDay(inputDateA: DateInput, inputDateB: DateInput): boolean;
433
+ declare function sameDay(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
407
434
 
408
435
  /**
409
436
  * Checks if two date objects refer to the same time seconds. Ignores date.
410
437
  * @param inputDateA - First date to compare
438
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
439
+ */
440
+ declare function sameSecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
441
+ /**
442
+ * Checks if two date objects refer to the same time seconds. Ignores date.
443
+ * @param [inputDateA] - First date to compare or the current time if null given
411
444
  * @param inputDateB - Second date to compare
412
445
  */
413
- declare function sameSecond(inputDateA: DateInput, inputDateB: DateInput): boolean;
446
+ declare function sameSecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
447
+
448
+ /**
449
+ * Checks if two date objects refer to the same millisecond. Ignores date.
450
+ * @param inputDateA - First date to compare
451
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
452
+ */
453
+ declare function sameMillisecond(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
454
+ /**
455
+ * Checks if two date objects refer to the same millisecond. Ignores date.
456
+ * @param [inputDateA] - First date to compare or the current time if null given
457
+ * @param inputDateB - Second date to compare
458
+ */
459
+ declare function sameMillisecond(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
414
460
 
415
461
  /**
416
462
  * Checks if two date objects refer to the same time minutes. Ignores date.
417
463
  * @param inputDateA - First date to compare
464
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
465
+ */
466
+ declare function sameMinute(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
467
+ /**
468
+ * Checks if two date objects refer to the same time minutes. Ignores date.
469
+ * @param [inputDateA] - First date to compare or the current time if null given
418
470
  * @param inputDateB - Second date to compare
419
471
  */
420
- declare function sameMinute(inputDateA: DateInput, inputDateB: DateInput): boolean;
472
+ declare function sameMinute(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
421
473
 
422
474
  /**
423
475
  * Checks if two date objects refer to the same time hour. Ignores date.
424
476
  * @param inputDateA - First date to compare
477
+ * @param [inputDateB] - Second date to compare or the current time if nothing given
478
+ */
479
+ declare function sameHour(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
480
+ /**
481
+ * Checks if two date objects refer to the same time hour. Ignores date.
482
+ * @param [inputDateA] - First date to compare or the current time if null given
425
483
  * @param inputDateB - Second date to compare
426
484
  */
427
- declare function sameHour(inputDateA: DateInput, inputDateB: DateInput): boolean;
485
+ declare function sameHour(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
428
486
 
429
487
  /**
430
488
  * Checks if two date objects refer to the same year.
431
489
  * @param inputDateA - First date to compare
490
+ * @param [inputDateB] - Second date to compare or the current time if null given
491
+ */
492
+ declare function sameYear(inputDateA: DateInput, inputDateB?: MaybeDateInput): boolean;
493
+ /**
494
+ * Checks if two date objects refer to the same year.
495
+ * @param [inputDateA] - First date to compare or the current time if null given
432
496
  * @param inputDateB - Second date to compare
433
497
  */
434
- declare function sameYear(inputDateA: DateInput, inputDateB: DateInput): boolean;
498
+ declare function sameYear(inputDateA: MaybeDateInput, inputDateB: DateInput): boolean;
435
499
 
436
500
  /**
437
501
  * Returns a Date object for the last day at the last second of the given week.
438
502
  * Defaults to Sunday as the first day of the week:
439
503
  * 0 = Sunday ... 6 = Saturday
440
- * @param inputDate - Gets the last day of the week
441
- * @param startOfWeekDay - The first day of the week
504
+ * @param [inputDate] - Gets the last day of the week
505
+ * @param [startOfWeekDay] - The first day of the week
442
506
  */
443
- declare function weekEnd(inputDate: DateInput, startOfWeekDay?: number): Date;
507
+ declare function weekEnd(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
444
508
 
445
509
  /**
446
510
  * Returns a Date object for start of the given week. Defaults to Sunday as the
447
511
  * first day of the week:
448
512
  * 0 = Sunday ... 6 = Saturday
449
- * @param inputDate - A string or Date object
450
- * @param startOfWeekDay - Determines which day of the week is the first
513
+ * @param [inputDate] - A string, Date object or nothing for current week
514
+ * @param [startOfWeekDay] - Determines which day of the week is the first
451
515
  */
452
- declare function weekStart(inputDate: DateInput, startOfWeekDay?: number): Date;
516
+ declare function weekStart(inputDate?: MaybeDateInput, startOfWeekDay?: number): Date;
453
517
 
454
518
  /**
455
519
  * Get the number of days in the given date’s year.
456
- * @param inputDate - A string or Date object
520
+ * @param [inputDate] - A string, Date object or nothing for the current year
457
521
  */
458
- declare function yearDays(inputDate: DateInput): number;
522
+ declare function yearDays(inputDate?: MaybeDateInput): number;
459
523
 
460
524
  /**
461
525
  * Returns a Date object for the with the input date set to the start of the current year.
462
- * @param inputDate - A string or Date object
526
+ * @param [inputDate] - A string, Date object or nothing for the current year
463
527
  */
464
- declare function yearStart(inputDate: DateInput): Date;
528
+ declare function yearStart(inputDate?: MaybeDateInput): Date;
465
529
 
466
530
  /**
467
531
  * Returns a Date object for the with the input date set to the end of the current year.
468
- * @param inputDate - A string or Date object
532
+ * @param [inputDate] - A string, Date object or nothing for the current year
469
533
  */
470
- declare function yearEnd(inputDate: DateInput): Date;
534
+ declare function yearEnd(inputDate?: MaybeDateInput): Date;
471
535
 
472
536
  /**
473
- * Is the first date before the second one?
537
+ * Is the first date before the second one or the current time?
474
538
  *
475
539
  * @param inputDate - The date that should be before the other one to return true
476
- * @param dateToCompare - The date to compare with
540
+ * @param [dateToCompare] - The date to compare with or the current time if nothing given
477
541
  *
478
- * @returns The first date is before the second date.
542
+ * @returns The first date is before the second date or the current time.
479
543
  */
480
- declare function isBefore(inputDate: DateInput, dateToCompare: DateInput): boolean;
544
+ declare function isBefore(inputDate: DateInput, dateToCompare?: MaybeDateInput): boolean;
481
545
 
482
546
  /**
483
547
  * @name isAfter
484
548
  * @category Common Helpers
485
- * @summary Is the first date after the second one?
549
+ * @summary Is the first date after the second one or the current time?
486
550
  *
487
551
  * @description
488
- * Is the first date after the second one?
552
+ * Is the first date after the second one or the current time?
489
553
  *
490
554
  * @param inputDate - The date that should be after the other one to return true
491
- * @param dateToCompare - The date to compare with
555
+ * @param [dateToCompare] - The date to compare with or the current time if nothing given
492
556
  *
493
- * @returns The first date is after the second date.
557
+ * @returns The first date is after the second date or the current time.
494
558
  */
495
- declare function isAfter(inputDate: DateInput, dateToCompare: DateInput): boolean;
559
+ declare function isAfter(inputDate: DateInput, dateToCompare?: MaybeDateInput): boolean;
496
560
 
497
561
  /**
498
- * Are the given dates equal?
562
+ * Are the given dates equal or given date to the current time?
499
563
  *
500
564
  * @param dateLeft - The first date to compare
565
+ * @param [dateRight] - The second date to compare or the current time of nothing given
566
+ *
567
+ * @returns The dates are equal or date to the current time
568
+ */
569
+ declare function isEqual(dateLeft: DateInput, dateRight?: MaybeDateInput): boolean;
570
+ /**
571
+ * Are the given dates equal or given date to the current time?
572
+ *
573
+ * @param [dateLeft] - The first date to compare or the current time if null given
501
574
  * @param dateRight - The second date to compare
502
575
  *
503
- * @returns The dates are equal.
576
+ * @returns The dates are equal or date to the current time
577
+ */
578
+ declare function isEqual(dateLeft: MaybeDateInput, dateRight: DateInput): boolean;
579
+
580
+ /**
581
+ * is the date in the past compared to the current time
582
+ * @param inputDate - The date that should be in the past
583
+ * @returns the given date is in the past compared to the current time
504
584
  */
505
- declare function isEqual(dateLeft: DateInput, dateRight: DateInput): boolean;
585
+ declare function isPast(inputDate: DateInput): boolean;
586
+
587
+ /**
588
+ * is the date in the future compared to the current time
589
+ * @param inputDate - The date that should be in the future
590
+ * @returns the given date is in the future compared to the current time
591
+ */
592
+ declare function isFuture(inputDate: DateInput): boolean;
506
593
 
507
594
  /**
508
595
  * Returns the difference between 2 dates in milliseconds.
509
- * @param dateA A date to compare with the right date
510
- * @param dateB A date to compare with the left date
596
+ * @param dateA - A date to compare with the right date
597
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
511
598
  */
512
- declare function diffMilliseconds(dateA: DateInput, dateB: DateInput): number;
599
+ declare function diffMilliseconds(dateA: DateInput, dateB?: MaybeDateInput): number;
600
+ /**
601
+ * Returns the difference between 2 dates in milliseconds.
602
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
603
+ * @param dateB - A date to compare with the left date
604
+ */
605
+ declare function diffMilliseconds(dateA: MaybeDateInput, dateB: DateInput): number;
513
606
 
514
607
  type DiffRoundingMethod = "trunc" | "round" | "floor" | "ceil";
515
608
 
516
609
  /**
517
610
  * Returns the difference between 2 dates in seconds.
518
- * @param dateA A date to compare with the right date
519
- * @param dateB A date to compare with the left date
520
- * @param roundingMethod the rounding method to use, default: trunc
611
+ * @param dateA - A date to compare with the right date
612
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time.
613
+ * @param [roundingMethod] - the rounding method to use, default: trunc
614
+ */
615
+ declare function diffSeconds(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
616
+ /**
617
+ * Returns the difference between 2 dates in seconds.
618
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
619
+ * @param dateB - A date to compare with the left date
620
+ * @param [roundingMethod] - the rounding method to use, default: trunc
521
621
  */
522
- declare function diffSeconds(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
622
+ declare function diffSeconds(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
523
623
 
524
624
  /**
525
625
  * Returns the difference between 2 dates in minutes.
526
- * @param dateA A date to compare with the right date
527
- * @param roundingMethod the rounding method to use, default: trunc
626
+ * @param dateA - A date to compare with the right date
627
+ * @param [dateB] - A Date to compare with the left date or nothing to compare with the current time
628
+ * @param [roundingMethod] the rounding method to use, default: trunc
629
+ */
630
+ declare function diffMinutes(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
631
+ /**
632
+ * Returns the difference between 2 dates in minutes.
633
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
634
+ * @param dateB - A Date to compare with the left date
635
+ * @param [roundingMethod] the rounding method to use, default: trunc
528
636
  */
529
637
  declare function diffMinutes(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
530
638
 
531
639
  /**
532
640
  * Returns the difference between 2 dates in hours.
533
- * @param dateA A date to compare with the right date
534
- * @param dateB A date to compare with the left date
535
- * @param roundingMethod the rounding method to use, default: trunc
641
+ * @param dateA - A date to compare with the right date
642
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
643
+ * @param [roundingMethod] - the rounding method to use, default: trunc
536
644
  */
537
- declare function diffHours(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
645
+ declare function diffHours(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
646
+ /**
647
+ * Returns the difference between 2 dates in hours.
648
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
649
+ * @param dateB - A date to compare with the left date
650
+ * @param [roundingMethod] - the rounding method to use, default: trunc
651
+ */
652
+ declare function diffHours(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
538
653
 
539
654
  /**
540
655
  * Returns the difference between 2 dates in days.
541
- * @param dateA A date to compare with the right date
542
- * @param dateB A date to compare with the left date
543
- * @param roundingMethod the rounding method to use, default: trunc
656
+ * @param dateA - A date to compare with the right date
657
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
658
+ * @param [roundingMethod] - the rounding method to use, default: trunc
659
+ */
660
+ declare function diffDays(dateA: DateInput, dateB?: MaybeDateInput, roundingMethod?: DiffRoundingMethod): number;
661
+ /**
662
+ * Returns the difference between 2 dates in days.
663
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
664
+ * @param dateB - A date to compare with the left date
665
+ * @param [roundingMethod] - the rounding method to use, default: trunc
544
666
  */
545
- declare function diffDays(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
667
+ declare function diffDays(dateA: MaybeDateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
546
668
 
547
669
  /**
548
670
  * Returns the difference between 2 dates in days.
549
- * @param dateA A date to compare with the right date
550
- * @param dateB A date to compare with the left date
551
- * @param roundingMethod the rounding method to use, default: trunc
671
+ * @param dateA - A date to compare with the right date
672
+ * @param [dateB] - A date to compare with the left date or nothing to compare with the current time
673
+ * @param [roundingMethod] - the rounding method to use, default: trunc
674
+ */
675
+ declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
676
+ /**
677
+ * Returns the difference between 2 dates in days.
678
+ * @param [dateA] - A date to compare with the right date or null to compare with the current time
679
+ * @param dateB - A date to compare with the left date
680
+ * @param [roundingMethod] - the rounding method to use, default: trunc
552
681
  */
553
682
  declare function diffWeeks(dateA: DateInput, dateB: DateInput, roundingMethod?: DiffRoundingMethod): number;
554
683
 
555
684
  /**
556
685
  * Returns the difference between 2 dates in months.
557
- * @param dateA A date to compare with the dateB date
558
- * @param dateB A date to compare with the dateA date
686
+ * @param dateA - A date to compare with the dateB date
687
+ * @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
688
+ */
689
+ declare function diffMonths(dateA: DateInput, dateB?: MaybeDateInput): number;
690
+ /**
691
+ * Returns the difference between 2 dates in months.
692
+ * @param [dateA] - A date to compare with the dateB date or null to compare with the current time
693
+ * @param dateB - A date to compare with the dateA date
559
694
  */
560
- declare function diffMonths(dateA: DateInput, dateB: DateInput): number;
695
+ declare function diffMonths(dateA: MaybeDateInput, dateB: DateInput): number;
561
696
 
562
697
  /**
563
698
  * Returns the difference between 2 dates in years.
564
- * @param dateA A date to compare with the dateB date
565
- * @param dateB A date to compare with the dateA date
699
+ * @param dateA - A date to compare with the dateB date
700
+ * @param [dateB] - A date to compare with the dateA date or nothing to compare with the current time
701
+ */
702
+ declare function diffYears(dateA: DateInput, dateB?: MaybeDateInput): number;
703
+ /**
704
+ * Returns the difference between 2 dates in years.
705
+ * @param [dateA] - A date to compare with the dateB date or null to compare with the current time
706
+ * @param dateB - A date to compare with the dateA date
566
707
  */
567
- declare function diffYears(dateA: DateInput, dateB: DateInput): number;
708
+ declare function diffYears(dateA: MaybeDateInput, dateB: DateInput): number;
568
709
 
569
- export { type DateInput, type FilledPart, type Format, type FormatOptions, type FormatPattern, type FormatStyle, type FormatStyleObj, type FormatToken, type NamedFormatOption, type NamedFormats, type ParseOptions, type Part, addDay, addHour, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, diffDays, diffHours, diffMilliseconds, diffMinutes, diffMonths, diffSeconds, diffWeeks, diffYears, format, formatStr, fourDigitYear, hourEnd, hourStart, isAfter, isBefore, isEqual, iso8601, minuteEnd, minuteStart, monthDays, monthEnd, monthStart, nearestDay, offset, parse, parseParts, parts, range, removeOffset, sameDay, sameHour, sameMinute, sameSecond, sameYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };
710
+ export { type DateInput, 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, addDay, addHour, addMillisecond, addMinute, addMonth, addSecond, addYear, ap, applyOffset, date, dayEnd, dayOfYear, dayStart, 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, sameSecond, sameYear, tzDate, weekEnd, weekStart, yearDays, yearEnd, yearStart };