@dereekb/date 13.4.0 → 13.4.1

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.
@@ -30,24 +30,28 @@ export interface YearMonthDayCodePair {
30
30
  * Extracts the year component from a {@link YearMonthDayCode} by dividing out the month and day digits.
31
31
  *
32
32
  * @param yearMonthDayCode - Encoded YYYYMMDD value to extract the year from
33
+ * @returns the year component of the code
33
34
  */
34
35
  export declare function yearMonthDayCodeYear(yearMonthDayCode: YearMonthDayCode): YearNumber;
35
36
  /**
36
37
  * Extracts the month component (1-12) from a {@link YearMonthDayCode} by isolating the middle two digits.
37
38
  *
38
39
  * @param yearMonthDayCode - Encoded YYYYMMDD value to extract the month from
40
+ * @returns the month component (1-12) of the code
39
41
  */
40
42
  export declare function yearMonthDayCodeMonth(yearMonthDayCode: YearMonthDayCode): MonthOfYear;
41
43
  /**
42
44
  * Extracts the day-of-month component (1-31) from a {@link YearMonthDayCode} by isolating the last two digits.
43
45
  *
44
46
  * @param yearMonthDayCode - Encoded YYYYMMDD value to extract the day from
47
+ * @returns the day-of-month component (1-31) of the code
45
48
  */
46
49
  export declare function yearMonthDayCodeDay(yearMonthDayCode: YearMonthDayCode): DayOfMonth;
47
50
  /**
48
51
  * Decomposes a {@link YearMonthDayCode} into its individual year, month, and day components.
49
52
  *
50
53
  * @param yearMonthDayCode - Encoded YYYYMMDD value to decompose
54
+ * @returns a pair containing the individual year, month, and day components
51
55
  */
52
56
  export declare function yearMonthDayCodePair(yearMonthDayCode: YearMonthDayCode): YearMonthDayCodePair;
53
57
  /**
@@ -56,6 +60,7 @@ export declare function yearMonthDayCodePair(yearMonthDayCode: YearMonthDayCode)
56
60
  * that need timezone-aware conversion should use {@link yearMonthDayCodeFactory} instead.
57
61
  *
58
62
  * @param date - Date to extract components from using local timezone
63
+ * @returns a pair containing the year, month, and day from the date
59
64
  */
60
65
  export declare function yearMonthDayCodePairFromDate(date: Date): YearMonthDayCodePair;
61
66
  /**
@@ -63,6 +68,7 @@ export declare function yearMonthDayCodePairFromDate(date: Date): YearMonthDayCo
63
68
  * using the formula `year * 10000 + month * 100 + day`.
64
69
  *
65
70
  * @param pair - Decomposed date components to encode
71
+ * @returns the encoded YYYYMMDD integer
66
72
  */
67
73
  export declare function yearMonthDayCodeFromPair(pair: YearMonthDayCodePair): YearMonthDayCode;
68
74
  /**
@@ -70,6 +76,7 @@ export declare function yearMonthDayCodeFromPair(pair: YearMonthDayCodePair): Ye
70
76
  * using the system's local timezone. For timezone-aware conversion, use {@link yearMonthDayCodeFactory}.
71
77
  *
72
78
  * @param date - Date to encode using local timezone
79
+ * @returns the encoded YYYYMMDD integer for the given date
73
80
  */
74
81
  export declare function yearMonthDayCodeFromDate(date: Date): YearMonthDayCode;
75
82
  /**
@@ -101,6 +108,7 @@ export interface YearMonthDayCodeConfig {
101
108
  * falling back to the system timezone when no input is provided.
102
109
  *
103
110
  * @param input - Timezone configuration or existing instance to resolve
111
+ * @returns a DateTimezoneUtcNormalInstance, falling back to the system timezone
104
112
  */
105
113
  export declare function yearMonthDayCodeDateTimezoneInstance(input: YearMonthDayCodeDateTimezoneInput): DateTimezoneUtcNormalInstance;
106
114
  /**
@@ -116,6 +124,12 @@ export declare function yearMonthDayCodeDateTimezoneInstance(input: YearMonthDay
116
124
  * // From explicit components (year, month 1-12, day)
117
125
  * const code2 = yearMonthDayCode(2022, 1, 15); // 20220115
118
126
  * ```
127
+ *
128
+ * @param date - a Date to encode (first overload)
129
+ * @param dateOrYear - a Date to encode, or a year number when used with month and day
130
+ * @param month - the month (1-12), required when dateOrYear is a number
131
+ * @param day - the day of month (1-31), required when dateOrYear is a number
132
+ * @returns the encoded YYYYMMDD integer
119
133
  */
120
134
  export declare function yearMonthDayCode(date: Date): YearMonthDayCode;
121
135
  export declare function yearMonthDayCode(year: number, month: MonthOfYear, day: DayOfMonth): YearMonthDayCode;
@@ -135,6 +149,7 @@ export declare function yearMonthDayCode(year: number, month: MonthOfYear, day:
135
149
  * ```
136
150
  *
137
151
  * @param config - Optional timezone configuration; defaults to system timezone
152
+ * @returns a reusable factory function that converts dates to YearMonthDayCode values
138
153
  */
139
154
  export declare function yearMonthDayCodeFactory(config?: YearMonthDayCodeConfig): YearMonthDayCodeFactory;
140
155
  /**
@@ -158,6 +173,7 @@ export type YearMonthDayCodesForDateRangeFactory = (dateOrDateRange: DateOrDateR
158
173
  * ```
159
174
  *
160
175
  * @param dateOrDateRange - A single Date (expanded to its calendar month) or an explicit date range
176
+ * @returns an array of YearMonthDayCode values, one per day in the range
161
177
  */
162
178
  export declare function yearMonthDayCodesForDateRange(dateOrDateRange: DateOrDateRange): YearMonthDayCode[];
163
179
  /**
@@ -166,6 +182,7 @@ export declare function yearMonthDayCodesForDateRange(dateOrDateRange: DateOrDat
166
182
  * Shares timezone normalization with the provided factory for consistent day boundaries.
167
183
  *
168
184
  * @param factory - YearMonthDayCodeFactory to use for encoding; defaults to system timezone
185
+ * @returns a factory that produces arrays of YearMonthDayCode values for date ranges
169
186
  */
170
187
  export declare function yearMonthDayCodesForDateRangeFactory(factory?: YearMonthDayCodeFactory): YearMonthDayCodesForDateRangeFactory;
171
188
  /**
@@ -191,6 +208,7 @@ export type YearMonthDayCodeDateConfig = Pick<YearMonthDayCodeConfig, 'timezone'
191
208
  * ```
192
209
  *
193
210
  * @param config - Optional timezone configuration; defaults to system timezone
211
+ * @returns a factory that decodes YearMonthDayCode values back into Dates
194
212
  */
195
213
  export declare function yearMonthDayCodeDateFactory(config?: YearMonthDayCodeDateConfig): YearMonthDayCodeDateFactory;
196
214
  /**
@@ -246,5 +264,6 @@ export interface YearMonthDayCodeGroupFactoryConfig<B> {
246
264
  * ```
247
265
  *
248
266
  * @param config - Grouping configuration including the date reader and optional timezone
267
+ * @returns a factory that partitions items into day-based groups
249
268
  */
250
269
  export declare function yearMonthDayCodeGroupFactory<B>(config: YearMonthDayCodeGroupFactoryConfig<B>): YearMonthDayCodeGroupFactory<B>;
@@ -45,6 +45,7 @@ export type FormatDateRangeFunctionConfigInput = FormatDateFunction | FormatDate
45
45
  * Useful when the same range formatting logic needs to be applied repeatedly with consistent settings.
46
46
  *
47
47
  * @param inputConfig - format function or full configuration
48
+ * @returns a reusable function that formats date ranges into strings
48
49
  *
49
50
  * @example
50
51
  * ```ts
@@ -67,6 +68,7 @@ export declare function formatDateRangeFunction(inputConfig: FormatDateRangeFunc
67
68
  * @param range - date range to format
68
69
  * @param inputConfig - format function or full configuration
69
70
  * @param separator - optional separator override when inputConfig is a function
71
+ * @returns the formatted date range string
70
72
  *
71
73
  * @example
72
74
  * ```ts
@@ -113,6 +115,7 @@ export type FormatDateRangeDistanceFunctionConfig = {
113
115
  * (e.g., "3 hours", "about 2 days"). Delegates to date-fns `formatDistance` or `formatDistanceStrict`.
114
116
  *
115
117
  * @param inputConfig - controls distance formatting, optional transforms, and same-day handling
118
+ * @returns a reusable function that computes and formats date range distances
116
119
  *
117
120
  * @example
118
121
  * ```ts
@@ -137,6 +140,7 @@ export declare const formatDateDistance: FormatDateRangeFunction;
137
140
  *
138
141
  * @param range - date range to compute distance for
139
142
  * @param inputConfig - optional distance formatting configuration
143
+ * @returns the human-readable distance string
140
144
  *
141
145
  * @example
142
146
  * ```ts
@@ -169,6 +173,11 @@ export declare function formatDateRangeDistance(range: DateRange, inputConfig?:
169
173
  * formatToTimeRangeString({ start: new Date('2024-01-15T09:00:00'), end: new Date('2024-01-16T17:00:00') });
170
174
  * // "01/15/2024 9:00 AM - 01/16/2024 5:00 PM"
171
175
  * ```
176
+ *
177
+ * @param startOrDateRange - date range object or start date
178
+ * @param end - optional end date when a start date is provided
179
+ * @param onlyTimeRange - whether to force time-only formatting regardless of date span
180
+ * @returns the formatted time or date+time range string
172
181
  */
173
182
  export declare function formatToTimeRangeString(startOrDateRange: DateRange): string;
174
183
  export declare function formatToTimeRangeString(start: Date, end?: Maybe<Date>): string;
@@ -186,6 +195,10 @@ export declare function formatToTimeRangeString(startOrDateRange: DateRange | Da
186
195
  * formatToDayTimeRangeString({ start: new Date('2024-01-15T09:00:00'), end: new Date('2024-01-16T17:00:00') });
187
196
  * // "01/15/2024 9:00 AM - 01/16/2024 5:00 PM"
188
197
  * ```
198
+ *
199
+ * @param startOrDateRange - date range object or start date
200
+ * @param end - optional end date when a start date is provided
201
+ * @returns the formatted date+time range string
189
202
  */
190
203
  export declare function formatToDayTimeRangeString(startOrDateRange: DateRange): string;
191
204
  export declare function formatToDayTimeRangeString(start: Date, end?: Maybe<Date>): string;
@@ -205,6 +218,12 @@ export declare function formatToDayTimeRangeString(start: Date, end?: Maybe<Date
205
218
  * formatToDayRangeString({ start: new Date('2024-01-15'), end: new Date('2024-01-15') });
206
219
  * // "01/15/2024"
207
220
  * ```
221
+ *
222
+ * @param startOrDateRange - date range object or start date
223
+ * @param format - optional custom format function (when called with a DateRange)
224
+ * @param endOrFormat - optional end date or custom format function
225
+ * @param inputFormat - optional custom format function when end date is provided separately
226
+ * @returns the formatted day range string
208
227
  */
209
228
  export declare function formatToDayRangeString(startOrDateRange: DateRange, format?: FormatDateFunction): string;
210
229
  export declare function formatToDayRangeString(start: Date, end?: Maybe<Date>, format?: FormatDateFunction): string;
@@ -213,6 +232,7 @@ export declare function formatToDayRangeString(start: Date, end?: Maybe<Date>, f
213
232
  * instead of throwing.
214
233
  *
215
234
  * @param input - date, date string, or nullish value
235
+ * @returns the ISO 8601 date string, or `undefined` if the input is invalid or nullish
216
236
  *
217
237
  * @example
218
238
  * ```ts
@@ -233,6 +253,7 @@ export declare function safeFormatToISO8601DateString(input: Maybe<DateOrDateStr
233
253
  * Formats a Date to a full ISO 8601 date-time string via `Date.toISOString()`. Defaults to the current date/time.
234
254
  *
235
255
  * @param date - date to format; defaults to `new Date()`
256
+ * @returns the full ISO 8601 date-time string
236
257
  *
237
258
  * @example
238
259
  * ```ts
@@ -250,6 +271,7 @@ export declare function formatToISO8601DateString(date?: Date): ISO8601DayString
250
271
  * Use {@link toISO8601DayStringForUTC} when the UTC date is needed instead.
251
272
  *
252
273
  * @param dateOrString - date or existing day string
274
+ * @returns the ISO 8601 day string in system timezone
253
275
  *
254
276
  * @example
255
277
  * ```ts
@@ -268,6 +290,7 @@ export declare function toISO8601DayStringForSystem(dateOrString: DateOrDayStrin
268
290
  * Defaults to the current date.
269
291
  *
270
292
  * @param date - date to format; defaults to `new Date()`
293
+ * @returns the ISO 8601 day string in system timezone
271
294
  *
272
295
  * @example
273
296
  * ```ts
@@ -285,6 +308,7 @@ export declare function formatToISO8601DayStringForSystem(date?: Date): ISO8601D
285
308
  * Use {@link toISO8601DayStringForSystem} when the system-local date is needed instead.
286
309
  *
287
310
  * @param dateOrString - date or existing day string
311
+ * @returns the ISO 8601 day string in UTC
288
312
  *
289
313
  * @example
290
314
  * ```ts
@@ -304,6 +328,7 @@ export declare function toISO8601DayStringForUTC(dateOrString: DateOrDayString):
304
328
  * Defaults to the current date.
305
329
  *
306
330
  * @param date - date to format; defaults to `new Date()`
331
+ * @returns the ISO 8601 day string using UTC date components
307
332
  *
308
333
  * @example
309
334
  * ```ts
@@ -314,14 +339,19 @@ export declare function toISO8601DayStringForUTC(dateOrString: DateOrDayString):
314
339
  * ```
315
340
  */
316
341
  export declare function formatToISO8601DayStringForUTC(date?: Date): ISO8601DayString;
317
- /** date-fns format string for `MM/dd/yyyy` (e.g., `"01/15/2024"`). */
342
+ /**
343
+ * date-fns format string for `MM/dd/yyyy` (e.g., `"01/15/2024"`).
344
+ */
318
345
  export declare const MONTH_DAY_SLASH_DATE_STRING_FORMAT = "MM/dd/yyyy";
319
- /** @deprecated use MONTH_DAY_SLASH_DATE_STRING_FORMAT instead. */
346
+ /**
347
+ * @deprecated Use MONTH_DAY_SLASH_DATE_STRING_FORMAT instead.
348
+ */
320
349
  export declare const monthDaySlashDateStringFormat = "MM/dd/yyyy";
321
350
  /**
322
351
  * Formats a Date as a month/day/year slash-separated string (`MM/dd/yyyy`). Defaults to the current date.
323
352
  *
324
353
  * @param date - date to format; defaults to `new Date()`
354
+ * @returns the formatted `MM/dd/yyyy` string
325
355
  *
326
356
  * @example
327
357
  * ```ts
@@ -336,14 +366,19 @@ export declare function formatToMonthDaySlashDate(date?: Date): MonthDaySlashDat
336
366
  * @deprecated use formatToMonthDaySlashDate instead.
337
367
  */
338
368
  export declare const formatToShortDateString: typeof formatToMonthDaySlashDate;
339
- /** date-fns format string for `MM/dd` (e.g., `"01/15"`). */
369
+ /**
370
+ * date-fns format string for `MM/dd` (e.g., `"01/15"`).
371
+ */
340
372
  export declare const DATE_MONTH_DAY_STRING_FORMAT = "MM/dd";
341
- /** @deprecated use DATE_MONTH_DAY_STRING_FORMAT instead. */
373
+ /**
374
+ * @deprecated Use DATE_MONTH_DAY_STRING_FORMAT instead.
375
+ */
342
376
  export declare const dateMonthDayStringFormat = "MM/dd";
343
377
  /**
344
378
  * Formats a Date as a month/day string (`MM/dd`) without the year. Defaults to the current date.
345
379
  *
346
380
  * @param date - date to format; defaults to `new Date()`
381
+ * @returns the formatted `MM/dd` string
347
382
  *
348
383
  * @example
349
384
  * ```ts
@@ -358,6 +393,7 @@ export declare function formatToMonthDayString(date?: Date): ISO8601DayString;
358
393
  * Formats a Date as a human-friendly weekday and month/day string (e.g., `"Mon, Jan 15th"`).
359
394
  *
360
395
  * @param date - date to format
396
+ * @returns the formatted weekday and month/day string
361
397
  *
362
398
  * @example
363
399
  * ```ts
@@ -368,14 +404,19 @@ export declare function formatToMonthDayString(date?: Date): ISO8601DayString;
368
404
  * ```
369
405
  */
370
406
  export declare function formatToDateString(date: Date): string;
371
- /** date-fns format string for 12-hour time with AM/PM (e.g., `"9:00 AM"`). */
407
+ /**
408
+ * date-fns format string for 12-hour time with AM/PM (e.g., `"9:00 AM"`).
409
+ */
372
410
  export declare const DATE_TIME_STRING_FORMAT = "h:mm a";
373
- /** @deprecated use DATE_TIME_STRING_FORMAT instead. */
411
+ /**
412
+ * @deprecated Use DATE_TIME_STRING_FORMAT instead.
413
+ */
374
414
  export declare const dateTimeStringFormat = "h:mm a";
375
415
  /**
376
416
  * Formats a Date as a 12-hour time string with AM/PM (e.g., `"9:00 AM"`).
377
417
  *
378
418
  * @param date - date to format
419
+ * @returns the formatted 12-hour time string with AM/PM
379
420
  *
380
421
  * @example
381
422
  * ```ts
@@ -386,14 +427,19 @@ export declare const dateTimeStringFormat = "h:mm a";
386
427
  * ```
387
428
  */
388
429
  export declare function formatToTimeString(date: Date): string;
389
- /** Combined date-fns format string for `MM/dd/yyyy h:mm a` (e.g., `"01/15/2024 9:00 AM"`). */
430
+ /**
431
+ * Combined date-fns format string for `MM/dd/yyyy h:mm a` (e.g., `"01/15/2024 9:00 AM"`).
432
+ */
390
433
  export declare const DATE_SHORT_DATE_AND_TIME_STRING_FORMAT = "MM/dd/yyyy h:mm a";
391
- /** @deprecated use DATE_SHORT_DATE_AND_TIME_STRING_FORMAT instead. */
434
+ /**
435
+ * @deprecated Use DATE_SHORT_DATE_AND_TIME_STRING_FORMAT instead.
436
+ */
392
437
  export declare const dateShortDateAndTimeStringFormat = "MM/dd/yyyy h:mm a";
393
438
  /**
394
439
  * Formats a Date as a short date and time string (e.g., `"01/15/2024 9:00 AM"`).
395
440
  *
396
441
  * @param date - date to format
442
+ * @returns the formatted short date and time string
397
443
  *
398
444
  * @example
399
445
  * ```ts
@@ -410,6 +456,7 @@ export declare function formatToShortDateAndTimeString(date: Date): string;
410
456
  *
411
457
  * @param start - start date/time
412
458
  * @param end - end date/time
459
+ * @returns the formatted time string with an appended duration indicator
413
460
  *
414
461
  * @example
415
462
  * ```ts
@@ -444,6 +491,11 @@ export declare function formatToTimeAndDurationString(start: Date, end: Date): s
444
491
  * formatStartedEndedDistanceString(activeRange);
445
492
  * // "started about 1 hour ago"
446
493
  * ```
494
+ *
495
+ * @param dateRange - date range with start and end dates
496
+ * @param dateRange.start - the start date of the range
497
+ * @param dateRange.end - the end date of the range
498
+ * @returns the relative-time label describing the date range state
447
499
  */
448
500
  export declare function formatStartedEndedDistanceString({ start, end }: DateRange): string;
449
501
  /**
@@ -451,6 +503,7 @@ export declare function formatStartedEndedDistanceString({ start, end }: DateRan
451
503
  * Useful for converting heterogeneous date inputs into a consistent midnight-aligned Date.
452
504
  *
453
505
  * @param input - date or day string to normalize
506
+ * @returns a Date set to midnight of the corresponding day in the system timezone
454
507
  *
455
508
  * @example
456
509
  * ```ts
@@ -469,6 +522,7 @@ export declare function toJsDayDate(input: DateOrDayString): Date;
469
522
  * in the system timezone. Supports year formats with more than 4 digits but does not support negative years.
470
523
  *
471
524
  * @param dayString - ISO 8601 day or date string to parse
525
+ * @returns a Date at the start of the parsed day in the system timezone
472
526
  *
473
527
  * @example
474
528
  * ```ts
@@ -8,6 +8,9 @@ export interface DateRangeStart {
8
8
  /**
9
9
  * Type guard to check if a value conforms to the {@link DateRangeStart} interface.
10
10
  *
11
+ * @param value - the value to check
12
+ * @returns true if the value has a valid Date `start` property
13
+ *
11
14
  * @example
12
15
  * ```ts
13
16
  * isDateRangeStart({ start: new Date() }); // true
@@ -41,6 +44,9 @@ export interface DateRange extends DateRangeStart {
41
44
  * Counts the total number of calendar days spanned by the range, inclusive of both endpoints.
42
45
  * Always returns at least 1, even for same-day ranges.
43
46
  *
47
+ * @param dateRange - the date range to measure
48
+ * @returns the number of days in the range, inclusive
49
+ *
44
50
  * @example
45
51
  * ```ts
46
52
  * const range = { start: new Date('2024-01-01'), end: new Date('2024-01-03') };
@@ -51,6 +57,9 @@ export declare function dateRangeDaysCount(dateRange: DateRange): number;
51
57
  /**
52
58
  * Type guard to check if a value is a valid {@link DateRange} with both start and end as Date objects.
53
59
  *
60
+ * @param input - the value to check
61
+ * @returns true if the value has valid Date `start` and `end` properties
62
+ *
54
63
  * @example
55
64
  * ```ts
56
65
  * isDateRange({ start: new Date(), end: new Date() }); // true
@@ -63,6 +72,10 @@ export declare function isDateRange(input: unknown): input is DateRange;
63
72
  * Compares two date ranges for exact millisecond equality on both start and end.
64
73
  * Returns true if both are nullish.
65
74
  *
75
+ * @param a - first date range to compare
76
+ * @param b - second date range to compare
77
+ * @returns true if both ranges are equal or both are nullish
78
+ *
66
79
  * @example
67
80
  * ```ts
68
81
  * const a = { start: new Date('2024-01-01'), end: new Date('2024-01-31') };
@@ -76,6 +89,10 @@ export declare function isSameDateRange(a: Maybe<Partial<DateRange>>, b: Maybe<P
76
89
  * Compares two date ranges for calendar-day equality, ignoring time-of-day differences.
77
90
  * Returns true if both are nullish.
78
91
  *
92
+ * @param a - first date range to compare
93
+ * @param b - second date range to compare
94
+ * @returns true if both ranges fall on the same calendar days or both are nullish
95
+ *
79
96
  * @example
80
97
  * ```ts
81
98
  * const a = { start: new Date('2024-01-01T08:00:00'), end: new Date('2024-01-31T10:00:00') };
@@ -87,6 +104,9 @@ export declare function isSameDateDayRange(a: Maybe<Partial<DateRange>>, b: Mayb
87
104
  /**
88
105
  * Checks whether the range is unbounded (neither start nor end is set), meaning it conceptually includes all dates.
89
106
  *
107
+ * @param input - the partial date range to check
108
+ * @returns true if neither start nor end is set
109
+ *
90
110
  * @example
91
111
  * ```ts
92
112
  * isInfiniteDateRange({}); // true
@@ -97,6 +117,9 @@ export declare function isInfiniteDateRange(input: Partial<DateRange>): boolean;
97
117
  /**
98
118
  * Checks whether the range has only one of start or end set, but not both.
99
119
  *
120
+ * @param input - the partial date range to check
121
+ * @returns true if exactly one of start or end is set
122
+ *
100
123
  * @example
101
124
  * ```ts
102
125
  * isPartialDateRange({ start: new Date() }); // true
@@ -107,6 +130,9 @@ export declare function isPartialDateRange(input: Partial<DateRange>): input is
107
130
  /**
108
131
  * Checks whether the range has both start and end set.
109
132
  *
133
+ * @param input - the partial date range to check
134
+ * @returns true if both start and end are set
135
+ *
110
136
  * @example
111
137
  * ```ts
112
138
  * isFullDateRange({ start: new Date(), end: new Date() }); // true
@@ -122,6 +148,10 @@ export type DateOrDateRange = Date | DateRange;
122
148
  * Normalizes a Date or {@link DateRange} into a DateRange. When given a single Date,
123
149
  * uses it as start and optionally uses the provided end date (defaults to the same date).
124
150
  *
151
+ * @param startOrDateRange - a Date or existing DateRange
152
+ * @param end - optional end date when the first argument is a plain Date
153
+ * @returns a DateRange
154
+ *
125
155
  * @example
126
156
  * ```ts
127
157
  * const range = dateOrDateRangeToDateRange(new Date('2024-01-01'), new Date('2024-01-31'));
@@ -231,6 +261,9 @@ export type DateRangeInput = (DateRangeTypedInput | DateRangeDistanceInput) & {
231
261
  * Creates a {@link DateRange} from the given type and optional parameters. Supports many range
232
262
  * strategies including fixed periods (day, week, month), directional ranges, and radii.
233
263
  *
264
+ * @param input - the range type or full configuration object
265
+ * @param inputRoundToMinute - optional override to round the date to the start of its minute
266
+ * @returns a computed DateRange
234
267
  * @throws Error if the type is not a recognized {@link DateRangeType}
235
268
  *
236
269
  * @example
@@ -250,6 +283,9 @@ export declare function dateRange(input: DateRangeType | DateRangeInput, inputRo
250
283
  * Returns a range spanning the full calendar day (first to last millisecond) of the given date.
251
284
  * Convenience wrapper around {@link dateRange} with {@link DateRangeType.DAY}.
252
285
  *
286
+ * @param date - the date whose full day range to return
287
+ * @returns a DateRange from start of day to end of day
288
+ *
253
289
  * @example
254
290
  * ```ts
255
291
  * const range = dateRangeFromStartAndEndOfDay(new Date('2024-06-15T14:30:00'));
@@ -308,6 +344,8 @@ export declare function endItreateDaysInDateRangeEarly(): void;
308
344
  * Creates a reusable function that iterates over dates within a range using a configurable step function.
309
345
  * Supports max iteration limits and early bail-out via {@link endItreateDaysInDateRangeEarly}.
310
346
  *
347
+ * @param input - configuration or a step function for advancing between dates
348
+ * @returns a reusable iteration function
311
349
  * @throws Error if max iterations is exceeded and throwErrorOnMaxIterations is true
312
350
  *
313
351
  * @example
@@ -321,6 +359,11 @@ export declare function iterateDaysInDateRangeFunction(input: IterateDaysInDateR
321
359
  /**
322
360
  * Iterates over dates within a {@link DateRange}, advancing by the provided getNextDate step function.
323
361
  * A simpler alternative to {@link iterateDaysInDateRangeFunction} for one-off usage.
362
+ *
363
+ * @param dateRange - the range to iterate over
364
+ * @param forEachFn - callback invoked for each date in the range
365
+ * @param getNextDate - step function that returns the next date from the current one
366
+ * @returns an array of results from forEachFn, or void
324
367
  */
325
368
  export declare function iterateDaysInDateRange(dateRange: DateRange, forEachFn: (date: Date) => void, getNextDate: (date: Date) => Date): void;
326
369
  export declare function iterateDaysInDateRange<T>(dateRange: DateRange, forEachFn: (date: Date) => T, getNextDate: (date: Date) => Date): T[];
@@ -351,6 +394,8 @@ export type ExpandDaysForDateRangeFunction = FactoryWithRequiredInput<Date[], Da
351
394
  * Creates a reusable function that expands a {@link DateRange} into an array of individual day dates.
352
395
  * Includes a configurable safety limit to prevent accidental memory exhaustion from large ranges.
353
396
  *
397
+ * @param config - optional configuration for the max expansion size
398
+ * @returns a function that expands a DateRange into an array of Dates
354
399
  * @throws Error if the range spans more days than the configured maxExpansionSize
355
400
  *
356
401
  * @example
@@ -365,6 +410,9 @@ export declare function expandDaysForDateRangeFunction(config?: ExpandDaysForDat
365
410
  * Expands a {@link DateRange} into an array of one Date per day. Uses the default max expansion size.
366
411
  * Convenience wrapper around {@link expandDaysForDateRangeFunction}.
367
412
  *
413
+ * @param range - the date range to expand
414
+ * @returns an array of Dates, one per day in the range
415
+ *
368
416
  * @example
369
417
  * ```ts
370
418
  * const days = expandDaysForDateRange({ start: new Date('2024-01-01'), end: new Date('2024-01-03') });
@@ -375,6 +423,12 @@ export declare function expandDaysForDateRange(range: DateRange): Date[];
375
423
  /**
376
424
  * Determines whether the current moment (or provided `now`) falls before, within, or after the given range.
377
425
  *
426
+ * @param dateRange - the date range to compare against
427
+ * @param dateRange.start - the start of the range
428
+ * @param dateRange.end - the end of the range
429
+ * @param now - the reference date, defaults to the current moment
430
+ * @returns 'past', 'present', or 'future'
431
+ *
378
432
  * @example
379
433
  * ```ts
380
434
  * const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
@@ -392,6 +446,10 @@ export interface GroupDateRangesByDateRelativeStatesResult<T extends DateRange>
392
446
  /**
393
447
  * Groups an array of date ranges into past, present, and future buckets based on the current moment (or provided `now`).
394
448
  *
449
+ * @param dateRanges - the date ranges to group
450
+ * @param _now - the reference date, defaults to the current moment
451
+ * @returns an object with past, present, and future arrays
452
+ *
395
453
  * @example
396
454
  * ```ts
397
455
  * const ranges = [
@@ -402,7 +460,7 @@ export interface GroupDateRangesByDateRelativeStatesResult<T extends DateRange>
402
460
  * // grouped.past = [first range], grouped.present = [second range], grouped.future = []
403
461
  * ```
404
462
  */
405
- export declare function groupDateRangesByDateRelativeState<T extends DateRange>(dateRanges: T[], now?: Date): GroupDateRangesByDateRelativeStatesResult<T>;
463
+ export declare function groupDateRangesByDateRelativeState<T extends DateRange>(dateRanges: T[], _now?: Date): GroupDateRangesByDateRelativeStatesResult<T>;
406
464
  export type DateRangeFunctionDateRangeRef<T extends Partial<DateRange> = Partial<DateRange>> = {
407
465
  readonly _dateRange: T;
408
466
  };
@@ -416,6 +474,10 @@ export type IsDateInDateRangeFunction<T extends Partial<DateRange> = DateRange>
416
474
  * Checks whether a date falls within a (possibly partial) date range.
417
475
  * Convenience wrapper around {@link isDateInDateRangeFunction}.
418
476
  *
477
+ * @param date - the date to test
478
+ * @param dateRange - the range to test against
479
+ * @returns true if the date falls within the range
480
+ *
419
481
  * @example
420
482
  * ```ts
421
483
  * const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
@@ -429,6 +491,9 @@ export declare function isDateInDateRange(date: Date, dateRange: Partial<DateRan
429
491
  * Handles partial ranges: if only start is set, checks >= start; if only end, checks <= end;
430
492
  * if neither, all dates are considered in range.
431
493
  *
494
+ * @param dateRange - the boundary range to test against
495
+ * @returns a function that tests whether a date falls within the range
496
+ *
432
497
  * @example
433
498
  * ```ts
434
499
  * const isInQ1 = isDateInDateRangeFunction({
@@ -448,6 +513,10 @@ export type IsDateRangeInDateRangeFunction<T extends Partial<DateRange> = Partia
448
513
  * Checks whether a date range is fully contained within another (possibly partial) date range.
449
514
  * Convenience wrapper around {@link isDateRangeInDateRangeFunction}.
450
515
  *
516
+ * @param compareDateRange - the range to test for containment
517
+ * @param dateRange - the boundary range
518
+ * @returns true if compareDateRange is fully within dateRange
519
+ *
451
520
  * @example
452
521
  * ```ts
453
522
  * const outer = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
@@ -460,6 +529,9 @@ export declare function isDateRangeInDateRange(compareDateRange: DateRange, date
460
529
  * Creates a reusable function that tests whether a given date range is fully contained within
461
530
  * the configured boundary range. Both start and end of the input must be within bounds.
462
531
  *
532
+ * @param dateRange - the boundary range
533
+ * @returns a function that tests containment of other ranges
534
+ *
463
535
  * @example
464
536
  * ```ts
465
537
  * const isInYear = isDateRangeInDateRangeFunction({
@@ -479,6 +551,10 @@ export type DateRangeOverlapsDateRangeFunction<T extends DateRange = DateRange>
479
551
  * Checks whether two date ranges overlap in any way (partial or full).
480
552
  * Convenience wrapper around {@link dateRangeOverlapsDateRangeFunction}.
481
553
  *
554
+ * @param compareDateRange - the range to test for overlap
555
+ * @param dateRange - the reference range
556
+ * @returns true if the ranges overlap
557
+ *
482
558
  * @example
483
559
  * ```ts
484
560
  * const a = { start: new Date('2024-01-01'), end: new Date('2024-06-30') };
@@ -491,6 +567,9 @@ export declare function dateRangeOverlapsDateRange(compareDateRange: DateRange,
491
567
  * Creates a reusable function that tests whether input ranges overlap the configured boundary range.
492
568
  * Two ranges overlap if one starts before the other ends, and vice versa.
493
569
  *
570
+ * @param dateRange - the boundary range to test overlap against
571
+ * @returns a function that tests overlap of other ranges
572
+ *
494
573
  * @example
495
574
  * ```ts
496
575
  * const overlapsQ1 = dateRangeOverlapsDateRangeFunction({
@@ -512,6 +591,9 @@ export declare function dateRangeOverlapsDateRangeFunction<T extends DateRange =
512
591
  *
513
592
  * Operates in UTC, so daylight savings transitions are not considered.
514
593
  *
594
+ * @param dateRange - the date range to fit into a single day period
595
+ * @returns a new date range with the same start and an end within 24 hours of start
596
+ *
515
597
  * @example
516
598
  * ```ts
517
599
  * // 10AM to 1PM across 3 days becomes same-day 10AM to 1PM
@@ -530,6 +612,9 @@ export type ClampDateFunction = ((date: Date) => Date) & DateRangeFunctionDateRa
530
612
  * Dates before start are clamped to start; dates after end are clamped to end.
531
613
  * Partial ranges clamp only on the side that is defined.
532
614
  *
615
+ * @param dateRange - the boundary range for clamping
616
+ * @returns a function that clamps dates to the range
617
+ *
533
618
  * @example
534
619
  * ```ts
535
620
  * const clamp = clampDateFunction({
@@ -546,6 +631,10 @@ export declare function clampDateFunction(dateRange: Partial<DateRange>): ClampD
546
631
  * Clamps a single date to fall within the given range boundaries.
547
632
  * Convenience wrapper around {@link clampDateFunction}.
548
633
  *
634
+ * @param date - the date to clamp
635
+ * @param dateRange - the boundary range
636
+ * @returns the clamped date
637
+ *
549
638
  * @example
550
639
  * ```ts
551
640
  * const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
@@ -559,6 +648,10 @@ export type ClampDateRangeFunction = ((date: Partial<DateRange>, clampNullValues
559
648
  * Creates a reusable function that clamps an entire date range to fit within the configured boundaries.
560
649
  * When `clampNullValues` is true, missing start/end values on the input are replaced with the boundary values.
561
650
  *
651
+ * @param dateRange - the boundary range for clamping
652
+ * @param defaultClampNullValues - whether to fill missing values with boundary values
653
+ * @returns a function that clamps date ranges
654
+ *
562
655
  * @example
563
656
  * ```ts
564
657
  * const clamp = clampDateRangeFunction({
@@ -575,6 +668,10 @@ export declare function clampDateRangeFunction(dateRange: Partial<DateRange>, de
575
668
  * Clamps a date range to fit within a boundary range.
576
669
  * Convenience wrapper around {@link clampDateRangeFunction}.
577
670
  *
671
+ * @param inputDateRange - the date range to clamp
672
+ * @param limitToDateRange - the boundary range
673
+ * @returns the clamped date range
674
+ *
578
675
  * @example
579
676
  * ```ts
580
677
  * const input = { start: new Date('2023-06-01'), end: new Date('2024-06-30') };
@@ -591,6 +688,9 @@ export type TransformDateRangeDatesFunction = (dateRange: DateRange) => DateRang
591
688
  /**
592
689
  * Creates a function that applies a date transformation to both start and end of a {@link DateRange}.
593
690
  *
691
+ * @param transform - the transformation to apply to both dates
692
+ * @returns a function that transforms both dates of a DateRange
693
+ *
594
694
  * @example
595
695
  * ```ts
596
696
  * import { startOfHour } from 'date-fns';
@@ -616,6 +716,9 @@ export interface DateRangeWithDateOrStringValue {
616
716
  * Returns each unique day of the week present in the range, in the order they appear starting from
617
717
  * the range's start day. For ranges spanning 7+ days, returns all days of the week.
618
718
  *
719
+ * @param dateRange - the date range to inspect
720
+ * @returns an array of unique day-of-week values present in the range
721
+ *
619
722
  * @example
620
723
  * ```ts
621
724
  * // Wednesday through Friday
@@ -32,5 +32,6 @@ export declare function fitDateRangeToDayPeriodFunction(timezone: DateTimezoneUt
32
32
  *
33
33
  * @param dateRange - the range to fit
34
34
  * @param timezone - the timezone for day boundary calculation
35
+ * @returns the date range fitted to a single day period
35
36
  */
36
37
  export declare function fitDateRangeToDayPeriod<T extends DateRange = DateRange>(dateRange: T, timezone: DateTimezoneUtcNormalFunctionInput): T;