@dereekb/date 13.0.7 → 13.1.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 (40) hide show
  1. package/index.cjs.js +3526 -993
  2. package/index.esm.js +3515 -983
  3. package/package.json +5 -6
  4. package/src/lib/date/date.calendar.d.ts +63 -9
  5. package/src/lib/date/date.cell.d.ts +203 -104
  6. package/src/lib/date/date.cell.factory.d.ts +319 -86
  7. package/src/lib/date/date.cell.filter.d.ts +104 -2
  8. package/src/lib/date/date.cell.index.d.ts +202 -92
  9. package/src/lib/date/date.cell.schedule.d.ts +285 -102
  10. package/src/lib/date/date.cell.schedule.day.d.ts +13 -3
  11. package/src/lib/date/date.cell.validator.d.ts +6 -8
  12. package/src/lib/date/date.cell.week.d.ts +24 -3
  13. package/src/lib/date/date.d.ts +481 -54
  14. package/src/lib/date/date.day.d.ts +139 -49
  15. package/src/lib/date/date.duration.d.ts +49 -11
  16. package/src/lib/date/date.format.d.ts +355 -36
  17. package/src/lib/date/date.hashset.d.ts +11 -0
  18. package/src/lib/date/date.logical.d.ts +61 -3
  19. package/src/lib/date/date.range.d.ts +355 -77
  20. package/src/lib/date/date.range.string.d.ts +39 -0
  21. package/src/lib/date/date.range.timezone.d.ts +18 -6
  22. package/src/lib/date/date.round.d.ts +46 -1
  23. package/src/lib/date/date.rxjs.d.ts +29 -7
  24. package/src/lib/date/date.sort.d.ts +36 -9
  25. package/src/lib/date/date.time.d.ts +197 -26
  26. package/src/lib/date/date.time.limit.d.ts +67 -4
  27. package/src/lib/date/date.time.minute.d.ts +269 -30
  28. package/src/lib/date/date.timezone.d.ts +286 -70
  29. package/src/lib/date/date.unix.d.ts +3 -0
  30. package/src/lib/date/date.week.d.ts +115 -51
  31. package/src/lib/query/query.builder.d.ts +91 -0
  32. package/src/lib/query/query.builder.mongo.d.ts +50 -0
  33. package/src/lib/query/query.filter.d.ts +29 -2
  34. package/src/lib/query/query.request.d.ts +16 -0
  35. package/src/lib/rrule/date.recurrence.d.ts +66 -22
  36. package/src/lib/rrule/date.rrule.d.ts +131 -8
  37. package/src/lib/rrule/date.rrule.extension.d.ts +50 -9
  38. package/src/lib/rrule/date.rrule.parse.d.ts +85 -2
  39. package/src/lib/timezone/timezone.d.ts +102 -2
  40. package/src/lib/timezone/timezone.validator.d.ts +9 -4
@@ -4,7 +4,11 @@ import { type DateCellRange, type DateCellRangeWithRange, type DateOrDateRangeOr
4
4
  import { type DateRange, type DateRangeStart } from './date.range';
5
5
  import { type DateTimezoneConversionConfigUseSystemTimezone, type DateTimezoneUtcNormalInstance } from './date.timezone';
6
6
  /**
7
- * Input for dateCellRange
7
+ * Configuration for creating a {@link DateCellRangeOfTimingFactory} that converts dates or indexes
8
+ * into a bounded {@link DateCellRangeWithRange} relative to a given timing schedule.
9
+ *
10
+ * Controls whether the output range is clamped to the timing's bounds and whether
11
+ * only completed (fully elapsed) indexes are included.
8
12
  */
9
13
  export interface DateCallIndexRangeFromDatesFactoryConfig {
10
14
  /**
@@ -31,7 +35,8 @@ export interface DateCallIndexRangeFromDatesFactoryConfig {
31
35
  readonly now?: GetterOrValue<Date>;
32
36
  }
33
37
  /**
34
- * DateCellRangeOfTimingFactory input
38
+ * Input for {@link DateCellRangeOfTimingFactory}, specifying optional start and end boundaries
39
+ * as either dates or cell indexes.
35
40
  */
36
41
  export interface DateCellRangeOfTimingInput {
37
42
  /**
@@ -44,80 +49,106 @@ export interface DateCellRangeOfTimingInput {
44
49
  readonly to?: Maybe<DateOrDateCellIndex>;
45
50
  }
46
51
  /**
47
- * Creates a DateCellRange from the input.
52
+ * Factory function that produces a clamped {@link DateCellRangeWithRange} from optional start/end input.
48
53
  */
49
54
  export type DateCellRangeOfTimingFactory = (input?: Maybe<DateCellRangeOfTimingInput>) => DateCellRangeWithRange;
50
55
  /**
51
- * Creates a DateCellRangeOfTimingFactory.
56
+ * Creates a {@link DateCellRangeOfTimingFactory} that converts dates or indexes into a clamped
57
+ * {@link DateCellRangeWithRange} relative to the configured timing.
58
+ *
59
+ * When `fitToTimingRange` is true (default), the returned range is clamped to the timing's valid index bounds.
60
+ * When `limitToCompletedIndexes` is true, only indexes whose timing duration has fully elapsed are included,
61
+ * with the max boundary lazily refreshed as time passes.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
66
+ * const factory = dateCellRangeOfTimingFactory({ timing });
52
67
  *
53
- * @param config
54
- * @returns
68
+ * // Clamp an arbitrary range to the timing's bounds (0..4)
69
+ * const range = factory({ i: -10, to: 10 });
70
+ * // range.i === 0, range.to === 4
71
+ *
72
+ * // With no input, defaults to 0..now
73
+ * const defaultRange = factory();
74
+ * ```
55
75
  */
56
76
  export declare function dateCellRangeOfTimingFactory(config: DateCallIndexRangeFromDatesFactoryConfig): DateCellRangeOfTimingFactory;
57
77
  /**
58
- * Creates a DateCellRange from the input.
59
- *
60
- * Convenience function for calling dateCellRangeOfTimingFactory() then passing the input.
78
+ * Computes a {@link DateCellRangeWithRange} from a timing and optional start/end input.
61
79
  *
62
- * @param config
63
- * @param input
64
- * @returns
80
+ * Shorthand for creating a {@link dateCellRangeOfTimingFactory} and immediately invoking it.
65
81
  */
66
82
  export declare function dateCellRangeOfTiming(config: DateCellTiming | DateCallIndexRangeFromDatesFactoryConfig, input?: Maybe<DateCellRangeOfTimingInput>): DateCellRangeWithRange;
83
+ /**
84
+ * Configuration subset for {@link dateCellTimingCompletedTimeRange}.
85
+ */
67
86
  export type DateCellTimingCompleteTimeRangeConfig = Pick<DateCallIndexRangeFromDatesFactoryConfig, 'now' | 'fitToTimingRange'>;
68
87
  /**
69
- * Convenience function for dateCellRangeOfTiming() that returns the latest completed index.
88
+ * Returns a {@link DateCellRangeWithRange} representing only the completed (fully elapsed) portion
89
+ * of the timing schedule. Useful for determining which days have already finished.
70
90
  *
71
91
  * By default fitToTimingRange is true.
72
92
  */
73
93
  export declare function dateCellTimingCompletedTimeRange(timing: DateCellTiming, config?: DateCellTimingCompleteTimeRangeConfig): DateCellRangeWithRange;
74
94
  /**
75
- * Returns the latest completed index for a DateCellTiming.
95
+ * Returns the latest completed day index for a {@link DateCellTiming}.
76
96
  *
77
- * Returns -1 if no days have been completed.
78
- *
79
- * @param timing
80
- * @param now
97
+ * Returns -1 if no days have been completed yet.
81
98
  */
82
99
  export declare function dateCellTimingLatestCompletedIndex(timing: DateCellTiming, now?: Date): IndexNumber;
83
100
  /**
84
- * IndexRange used with DateCells.
101
+ * {@link IndexRange} used with DateCells.
85
102
  *
86
- * It has an exclusive max range. It is similar to a DateCellRange.
103
+ * Unlike {@link DateCellRange} (which uses inclusive `to`), this uses an exclusive `maxIndex`,
104
+ * making it compatible with standard index-range iteration patterns.
87
105
  */
88
106
  export type DateCellIndexRange = IndexRange;
107
+ /**
108
+ * Converts a {@link DateCellRange} (inclusive `to`) to a {@link DateCellIndexRange} (exclusive `maxIndex`).
109
+ */
89
110
  export declare function dateCellRangeToDateCellIndexRange(range: DateCellRange): DateCellIndexRange;
111
+ /**
112
+ * Converts a {@link DateCellIndexRange} (exclusive `maxIndex`) back to a {@link DateCellRangeWithRange} (inclusive `to`).
113
+ */
90
114
  export declare function dateCellIndexRangeToDateCellRange(range: DateCellIndexRange): DateCellRangeWithRange;
91
115
  /**
92
- * Generates a DateCellIndexRange based on the input timing.
116
+ * Generates a {@link DateCellIndexRange} based on the input timing.
93
117
  *
94
- * An arbitrary limit can also be applied.
95
- *
96
- * @param timing
97
- * @param limit
98
- * @param fitToTimingRange
118
+ * An arbitrary limit can also be applied. When `fitToTimingRange` is true (default),
119
+ * the limit is intersected with the timing's own range; otherwise the limit is used as-is.
99
120
  */
100
121
  export declare function dateCellIndexRange(timing: DateCellTiming, limit?: DateCellTimingRangeInput, fitToTimingRange?: boolean): DateCellIndexRange;
101
122
  /**
102
- * Convenience function for calling expandDateCells() with the input DateCellCollection.
123
+ * Expands a {@link DateCellCollection} into an array of {@link DateCellDurationSpan} values
124
+ * by combining its timing and blocks.
103
125
  *
104
- * @param collection
105
- * @returns
126
+ * Shorthand for calling {@link expandDateCellTiming} with `collection.timing` and `collection.blocks`.
106
127
  */
107
128
  export declare function expandDateCellCollection<B extends DateCell = DateCell>(collection: DateCellCollection<B>): DateCellDurationSpan<B>[];
108
129
  /**
109
- * Convenience function for calling dateCellTimingExpansionFactory() then passing the blocks.
130
+ * Expands the given blocks into {@link DateCellDurationSpan} values using the provided timing.
110
131
  *
111
- * @param blocks
112
- * @param timing
113
- * @returns
132
+ * Shorthand for creating a {@link dateCellTimingExpansionFactory} and immediately invoking it.
114
133
  */
115
134
  export declare function expandDateCellTiming<B extends DateCell = DateCell>(timing: DateCellTiming, blocks: B[]): DateCellDurationSpan<B>[];
135
+ /**
136
+ * Input for a {@link DateCellTimingExpansionFactory}. Accepts either an array of blocks directly
137
+ * or a reference object containing a `blocks` array.
138
+ */
116
139
  export type DateCellTimingExpansionFactoryInput<B extends DateCell | DateCellRange = DateCell> = DateCellArrayRef<B> | DateCellArray<B>;
117
140
  /**
118
- * Used to convert the input DateCellTimingExpansionFactoryInput into an array of DateCellDurationSpan values
141
+ * Factory function that converts {@link DateCellTimingExpansionFactoryInput} into an array of
142
+ * {@link DateCellDurationSpan} values by computing the concrete startsAt date and duration
143
+ * for each block relative to the configured timing.
119
144
  */
120
145
  export type DateCellTimingExpansionFactory<B extends DateCell | DateCellRange = DateCell> = (input: DateCellTimingExpansionFactoryInput<B>) => DateCellDurationSpan<B>[];
146
+ /**
147
+ * Configuration for creating a {@link DateCellTimingExpansionFactory}.
148
+ *
149
+ * Provides control over range limiting, filtering, and output size limits to efficiently
150
+ * expand date cell blocks into concrete duration spans.
151
+ */
121
152
  export interface DateCellTimingExpansionFactoryConfig<B extends DateCell | DateCellRange = DateCell> {
122
153
  /**
123
154
  * Timing to use in the configuration.
@@ -148,13 +179,40 @@ export interface DateCellTimingExpansionFactoryConfig<B extends DateCell | DateC
148
179
  maxDateCellsToReturn?: number;
149
180
  }
150
181
  /**
151
- * Creates a DateCellTimingExpansionFactory
182
+ * Creates a {@link DateCellTimingExpansionFactory} that expands date cell blocks into
183
+ * {@link DateCellDurationSpan} values with concrete start times and durations.
152
184
  *
153
- * @param config
154
- * @returns
185
+ * Blocks with a range (`i` to `to`) are expanded into individual single-index entries.
186
+ * Filtering is applied both at the block level and at the computed duration span level,
187
+ * and evaluation can be capped for performance with large datasets.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
192
+ * const expand = dateCellTimingExpansionFactory({ timing });
193
+ *
194
+ * const blocks: DateCell[] = [{ i: 0 }, { i: 1 }, { i: 2 }];
195
+ * const spans = expand(blocks);
196
+ * // Each span has { i, startsAt, duration } with the concrete start time for that day
197
+ *
198
+ * // With range blocks:
199
+ * const rangeBlocks = [{ i: 0, to: 2 }];
200
+ * const expandedSpans = expand(rangeBlocks);
201
+ * // Produces 3 spans, one for each index 0, 1, 2
202
+ * ```
155
203
  */
156
204
  export declare function dateCellTimingExpansionFactory<B extends DateCell | DateCellRange = DateCell>(config: DateCellTimingExpansionFactoryConfig): DateCellTimingExpansionFactory<B>;
205
+ /**
206
+ * Configuration subset for {@link dateCellDayTimingInfoFactory}, providing the timing
207
+ * and optional range limit.
208
+ */
157
209
  export type DateCellDayTimingInfoFactoryConfig = Pick<DateCellTimingExpansionFactoryConfig, 'timing' | 'rangeLimit'>;
210
+ /**
211
+ * Detailed timing information for a specific day relative to a {@link DateCellTiming} schedule.
212
+ *
213
+ * Provides the computed index, progress state (in-progress, completed, upcoming),
214
+ * and the concrete start/end times for the day's timing window.
215
+ */
158
216
  export interface DateCellDayTimingInfo {
159
217
  /**
160
218
  * Input date or calculated date if provided a dayIndex.
@@ -220,91 +278,188 @@ export interface DateCellDayTimingInfo {
220
278
  readonly now: Date;
221
279
  }
222
280
  /**
223
- * Generates DateCellDayTimingInfo about the input date relative to the input timing and range limit.
281
+ * Factory that generates {@link DateCellDayTimingInfo} for any date or day index relative to
282
+ * the configured timing schedule.
224
283
  *
225
- * The date may not exist within the range, but will still compute values using the input date and timing configuration.
284
+ * Computes progress state even for dates outside the timing's range, which is useful
285
+ * for UI elements that need to show timing context beyond the active schedule.
226
286
  *
227
- * Can optionally specify a now that is used for checking the inProgress functionality.
287
+ * The optional `now` parameter controls the reference time for in-progress calculations.
228
288
  */
229
289
  export type DateCellDayTimingInfoFactory = ((date: DateOrDateCellIndex, now?: Date) => DateCellDayTimingInfo) & {
230
290
  readonly _indexFactory: DateCellTimingRelativeIndexFactory;
231
291
  readonly _startsAtFactory: DateCellTimingStartsAtDateFactory;
232
292
  };
293
+ /**
294
+ * Creates a {@link DateCellDayTimingInfoFactory} that computes detailed timing information
295
+ * (progress state, start/end times, range membership) for any given date or day index.
296
+ *
297
+ * The factory handles timezone normalization internally and accounts for edge cases
298
+ * where a timing window spans midnight into the next day.
299
+ *
300
+ * @example
301
+ * ```ts
302
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
303
+ * const infoFactory = dateCellDayTimingInfoFactory({ timing });
304
+ *
305
+ * // Get info for day index 2
306
+ * const info = infoFactory(2, new Date());
307
+ * console.log(info.isInProgress); // whether day 2's window is currently active
308
+ * console.log(info.startsAtOnDay); // concrete start time for day 2
309
+ * console.log(info.isInRange); // whether index 2 is within the timing's range
310
+ *
311
+ * // Get info for a specific date
312
+ * const dateInfo = infoFactory(someDate);
313
+ * console.log(dateInfo.dayIndex); // which day index this date falls on
314
+ * ```
315
+ */
233
316
  export declare function dateCellDayTimingInfoFactory(config: DateCellDayTimingInfoFactoryConfig): DateCellDayTimingInfoFactory;
234
317
  /**
235
- * DateCellTimingRelativeIndexFactory input. Can be a Date, DateCellIndex, or ISO8601DayString
318
+ * Accepted input for {@link DateCellTimingRelativeIndexFactory}. Can be a Date (in system timezone),
319
+ * a numeric DateCellIndex (passed through as-is), or an ISO8601DayString (parsed as UTC).
236
320
  */
237
321
  export type DateCellTimingRelativeIndexFactoryInput = DateOrDateCellIndex | ISO8601DayString;
238
322
  /**
239
- * Returns the DateCellIndex of the input date relative to the configured Date.
323
+ * Factory function that computes the {@link DateCellIndex} of any input date relative to
324
+ * the configured timing's start date.
240
325
  *
241
- * Input dates should be in system time zone and not normalized to a different timezone.
326
+ * If a numeric index is passed, it is returned as-is. Dates are normalized through
327
+ * the timing's timezone before computing the day offset.
328
+ *
329
+ * Exposes `_timing` and `_normalInstance` for downstream factories that need access
330
+ * to the original timing configuration and timezone normalization.
242
331
  */
243
332
  export type DateCellTimingRelativeIndexFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateCellTimingRelativeIndexFactoryInput) => DateCellIndex) & {
244
333
  readonly _timing: T;
245
334
  readonly _normalInstance: DateTimezoneUtcNormalInstance;
246
335
  };
247
336
  /**
248
- * Returns true if the input is a DateCellTimingRelativeIndexFactory.
337
+ * Type guard that returns true if the input is a {@link DateCellTimingRelativeIndexFactory}.
249
338
  *
250
- * @param input
251
- * @returns
339
+ * Checks for the presence of `_timing` and `_normalInstance` properties on a function.
252
340
  */
253
341
  export declare function isDateCellTimingRelativeIndexFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: unknown): input is DateCellTimingRelativeIndexFactory<T>;
254
342
  /**
255
- * Creates a DateCellTimingRelativeIndexFactory from the input.
343
+ * Creates a {@link DateCellTimingRelativeIndexFactory} that converts dates, ISO8601 day strings,
344
+ * or indexes into a zero-based day index relative to the timing's start date.
345
+ *
346
+ * If an existing factory is passed, it is returned as-is (idempotent). The factory normalizes
347
+ * all date inputs through UTC to handle timezone offsets correctly, computing the floor
348
+ * of the hour difference divided by 24 to determine the day offset.
349
+ *
350
+ * @example
351
+ * ```ts
352
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
353
+ * const indexFactory = dateCellTimingRelativeIndexFactory(timing);
354
+ *
355
+ * // Numeric indexes pass through unchanged
356
+ * indexFactory(3); // 3
256
357
  *
257
- * @param input
258
- * @returns
358
+ * // Dates are converted to their day offset from timing start
359
+ * indexFactory(addDays(startsAt, 2)); // 2
360
+ *
361
+ * // ISO8601 day strings are also supported
362
+ * indexFactory('2024-01-15'); // day offset from timing start
363
+ *
364
+ * // Access the underlying timing and normalizer
365
+ * indexFactory._timing; // the original timing
366
+ * indexFactory._normalInstance; // timezone normalizer
367
+ * ```
259
368
  */
260
369
  export declare function dateCellTimingRelativeIndexFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingRelativeIndexFactory<T>;
261
370
  /**
262
- * Function that wraps a DateCellTimingRelativeIndexFactory and converts multuple Date/DateCellIndex/DateCellRange values into an array of DateCellIndex values.
371
+ * Batch-conversion variant of {@link DateCellTimingRelativeIndexFactory} that accepts
372
+ * multiple Date, DateCellIndex, DateRange, or DateCellRange values and flattens them
373
+ * into an array of {@link DateCellIndex} values.
374
+ *
375
+ * Ranges are expanded into all contained indexes.
263
376
  */
264
377
  export type DateCellTimingRelativeIndexArrayFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: ArrayOrValue<DateOrDateRangeOrDateCellIndexOrDateCellRange>) => DateCellIndex[]) & {
265
378
  readonly _indexFactory: DateCellTimingRelativeIndexFactory<T>;
266
379
  };
267
380
  /**
268
- * Creates a DateCellTimingRelativeIndexArrayFactory from the input DateCellTimingRelativeIndexFactory.
381
+ * Creates a {@link DateCellTimingRelativeIndexArrayFactory} that converts mixed arrays of
382
+ * dates, date ranges, and cell ranges into a flat array of day indexes.
269
383
  *
270
- * @param indexFactory
384
+ * Date ranges and cell ranges are expanded to include every index within the range.
271
385
  */
272
386
  export declare function dateCellTimingRelativeIndexArrayFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(indexFactory: DateCellTimingRelativeIndexFactory<T>): DateCellTimingRelativeIndexArrayFactory<T>;
273
387
  /**
274
- * Gets the relative index of the input date compared to the input timing.
388
+ * Convenience function that returns the zero-based day index for a date (or index)
389
+ * relative to the given timing's start.
390
+ *
391
+ * Defaults to the current date/time if no date is provided.
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * const timing: DateCellTimingStartsAt = { startsAt, timezone: 'America/Denver' };
275
396
  *
276
- * @param timing
277
- * @param date
397
+ * // Get today's index relative to the timing
398
+ * const todayIndex = getRelativeIndexForDateCellTiming(timing);
399
+ *
400
+ * // Get the index for a specific date
401
+ * const index = getRelativeIndexForDateCellTiming(timing, someDate);
402
+ * ```
278
403
  */
279
404
  export declare function getRelativeIndexForDateCellTiming(timing: DateCellTimingStartsAt, date?: DateOrDateCellIndex): DateCellIndex;
280
405
  /**
281
- * Similar to the DateCellTimingRelativeIndexFactory, but returns a date instead of an index for the input.
406
+ * Inverse of {@link DateCellTimingRelativeIndexFactory}. Given a day index, returns a Date
407
+ * with the current time-of-day ("now") placed on the calendar date corresponding to that index.
282
408
  *
283
- * Returns a date with the hours and minutes for "now" for the given date returned if an index is input.
409
+ * If a Date is passed instead of an index, it is returned as-is.
284
410
  */
285
411
  export type DateCellTimingDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateOrDateCellIndex, now?: Date) => Date) & {
286
412
  readonly _timing: T;
287
413
  };
288
414
  /**
289
- * Creates a DateCellTimingDateFactory.
415
+ * Creates a {@link DateCellTimingDateFactory} that maps day indexes to calendar dates
416
+ * while preserving the current time-of-day.
417
+ *
418
+ * This is useful when you need the actual Date for a given index (e.g., for display or
419
+ * date arithmetic) but want to retain the hours/minutes of "now" rather than using
420
+ * the timing's startsAt time.
421
+ *
422
+ * @example
423
+ * ```ts
424
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
425
+ * const dateFactory = dateCellTimingDateFactory(timing);
426
+ *
427
+ * // Pass through dates unchanged
428
+ * dateFactory(someDate); // returns someDate
290
429
  *
291
- * @param timing
292
- * @returns
430
+ * // Convert index 3 to a date with current time-of-day
431
+ * const dateForDay3 = dateFactory(3);
432
+ *
433
+ * // Convert index 3 to a date with a specific reference time
434
+ * const dateForDay3AtNoon = dateFactory(3, noonDate);
435
+ * ```
293
436
  */
294
437
  export declare function dateCellTimingDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(timing: T): DateCellTimingDateFactory<T>;
295
438
  /**
296
- * Returns the last index of a DateCellTiming.
439
+ * Returns the last (maximum) day index for a {@link DateCellTiming} schedule.
440
+ *
441
+ * This is the index corresponding to the timing's `end` date, representing the final
442
+ * day in the schedule.
297
443
  *
298
- * @param timing
299
- * @returns
444
+ * @example
445
+ * ```ts
446
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
447
+ * const lastIndex = dateCellTimingEndIndex(timing); // 4 (zero-based, 5 days)
448
+ * ```
300
449
  */
301
450
  export declare function dateCellTimingEndIndex(input: DateCellTiming | DateCellTimingRelativeIndexFactory<DateCellTiming>): IndexNumber;
302
451
  /**
303
- * Returns the start time of the input date or index.
452
+ * Factory function that returns the calendar start-of-day date for a given day index or date input.
453
+ *
454
+ * Unlike {@link DateCellTimingStartsAtDateFactory}, this returns the start of the day (midnight-equivalent
455
+ * in the timing's timezone) rather than the event's startsAt time.
304
456
  */
305
457
  export type DateCellTimingStartDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateCellTimingRelativeIndexFactoryInput) => Date) & {
306
458
  readonly _indexFactory: DateCellTimingRelativeIndexFactory<T>;
307
459
  };
460
+ /**
461
+ * Configuration that uses the system timezone and skips timezone assertion enforcement.
462
+ */
308
463
  export type DateCellTimingUseSystemAndIgnoreEnforcement = DateTimezoneConversionConfigUseSystemTimezone & {
309
464
  /**
310
465
  * Skips the assertion that the timezone matches. This defaults to true if not provided.
@@ -312,45 +467,77 @@ export type DateCellTimingUseSystemAndIgnoreEnforcement = DateTimezoneConversion
312
467
  assertTimingMatchesTimezone: false;
313
468
  };
314
469
  /**
315
- * Creates a DateCellTimingDateFactory.
470
+ * Creates a {@link DateCellTimingStartDateFactory} that computes the calendar start-of-day date
471
+ * for any day index relative to the timing's start.
316
472
  *
317
- * @param timing
318
- * @returns
473
+ * The returned date represents the beginning of the day in the timing's timezone context.
319
474
  */
320
475
  export declare function dateCellTimingStartDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingStartDateFactory<T>;
321
476
  /**
322
- * Returns the startsAt time of the input date or index.
477
+ * Factory function that returns the concrete `startsAt` time (the event's actual start time
478
+ * within the day) for a given day index or date input.
479
+ *
480
+ * This differs from {@link DateCellTimingStartDateFactory} in that it returns the event time
481
+ * (e.g., 2:00 PM) rather than the calendar day boundary.
323
482
  */
324
483
  export type DateCellTimingStartsAtDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateCellTimingRelativeIndexFactoryInput) => Date) & {
325
484
  readonly _indexFactory: DateCellTimingRelativeIndexFactory<T>;
326
485
  };
327
486
  /**
328
- * Creates a DateCellTimingStartsAtDateFactory.
487
+ * Creates a {@link DateCellTimingStartsAtDateFactory} that computes the concrete event start time
488
+ * for any day index relative to the timing's schedule.
489
+ *
490
+ * The returned date reflects the actual `startsAt` time-of-day offset to the correct calendar date
491
+ * for the requested index, with proper timezone normalization.
492
+ *
493
+ * @example
494
+ * ```ts
495
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
496
+ * const startsAtFactory = dateCellTimingStartsAtDateFactory(timing);
497
+ *
498
+ * // Get the exact start time for day 3
499
+ * const day3Start = startsAtFactory(3);
500
+ * // Returns a Date with the same time-of-day as startsAt but on day 3's calendar date
329
501
  *
330
- * @param timing
331
- * @returns
502
+ * // Also works with dates
503
+ * const startForDate = startsAtFactory(someDate);
504
+ * ```
332
505
  */
333
506
  export declare function dateCellTimingStartsAtDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingStartsAtDateFactory<T>;
334
507
  /**
335
- * Returns the startsAt time of the input date or index.
508
+ * Factory function that returns the end time (startsAt + duration) for a given day index or date input.
509
+ *
510
+ * Combines {@link DateCellTimingStartsAtDateFactory} with the timing's duration to compute
511
+ * when the event window closes on any given day.
336
512
  */
337
513
  export type DateCellTimingEndDateFactory<T extends DateCellTiming = DateCellTiming> = ((input: DateCellTimingRelativeIndexFactoryInput) => Date) & {
338
514
  readonly _startsAtDateFactory: DateCellTimingStartsAtDateFactory<T>;
339
515
  };
340
516
  /**
341
- * Creates a DateCellTimingStartsAtDateFactory.
517
+ * Creates a {@link DateCellTimingEndDateFactory} that computes the end time
518
+ * (startsAt + duration) for any day index relative to the timing's schedule.
519
+ *
520
+ * @example
521
+ * ```ts
522
+ * const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
523
+ * const endFactory = dateCellTimingEndDateFactory(timing);
342
524
  *
343
- * @param timing
344
- * @returns
525
+ * // Get the end time for day 2 (startsAt time + 60 minutes on day 2)
526
+ * const day2End = endFactory(2);
527
+ * ```
345
528
  */
346
529
  export declare function dateCellTimingEndDateFactory<T extends DateCellTiming = DateCellTiming>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingEndDateFactory<T>;
347
530
  /**
348
- * Returns the date of the input index.
349
- *
350
- * @param timing
351
- * @param date
531
+ * Convenience function that returns the calendar date for a given day index or date
532
+ * relative to the timing. Shorthand for creating a {@link dateCellTimingDateFactory} and invoking it.
352
533
  */
353
534
  export declare function getRelativeDateForDateCellTiming(timing: DateCellTimingStartsAt, input: DateOrDateCellIndex): Date;
535
+ /**
536
+ * Configuration for {@link updateDateCellTimingWithDateCellTimingEvent}.
537
+ *
538
+ * Controls which aspects of a timing (start day, start time, end day, duration)
539
+ * are replaced by values from a {@link DateCellTimingEvent}.
540
+ */
354
541
  export interface UpdateDateCellTimingWithDateCellTimingEventInput {
355
542
  /**
356
543
  * Target timing to update.
@@ -390,22 +577,46 @@ export interface UpdateDateCellTimingWithDateCellTimingEventInput {
390
577
  readonly replaceDuration?: boolean;
391
578
  }
392
579
  /**
393
- * Creates a new DateCellTiming from the input configuration.
580
+ * Produces a new {@link FullDateCellTiming} by selectively replacing parts of an existing timing
581
+ * with values from a {@link DateCellTimingEvent}.
582
+ *
583
+ * This is the primary mechanism for updating a timing schedule in response to user edits.
584
+ * The `replaceStartDay`, `replaceStartsAt`, `endOnEvent`, and `replaceDuration` flags
585
+ * independently control which aspects of the timing are modified, and can be combined.
394
586
  *
395
- * @param dateCellTimingStartEndRange
396
- * @param event
397
- * @param timezone
398
- * @returns
587
+ * When both `replaceStartDay` and `replaceStartsAt` are true, the event's startsAt is used directly.
588
+ * When only `replaceStartDay` is true, the day changes but the time-of-day is preserved.
589
+ * When only `replaceStartsAt` is true, the time-of-day changes but the calendar date is preserved.
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * const result = updateDateCellTimingWithDateCellTimingEvent({
594
+ * timing: existingTiming,
595
+ * event: { startsAt: newStartTime, duration: 90 },
596
+ * replaceStartsAt: true,
597
+ * replaceDuration: true
598
+ * });
599
+ * // result has the same start day and end day, but new time-of-day and 90-minute duration
600
+ * ```
399
601
  */
400
602
  export declare function updateDateCellTimingWithDateCellTimingEvent(input: UpdateDateCellTimingWithDateCellTimingEventInput): FullDateCellTiming;
401
603
  /**
402
- * Input for a IsDateWithinDateCellRangeFunction
604
+ * Union of input types accepted by {@link IsDateWithinDateCellRangeFunction}.
605
+ * Supports raw dates, indexes, date ranges, and cell ranges for flexible containment checks.
403
606
  */
404
607
  export type IsDateWithinDateCellRangeInput = DateOrDateCellIndex | DateRangeStart | DateRange | DateCell | DateCellRange;
405
608
  /**
406
- * Function that returns true if the input range is equal or falls within the configured DateCellRange.
609
+ * Predicate function that returns true if the input date, index, or range falls entirely
610
+ * within the configured reference range.
407
611
  */
408
612
  export type IsDateWithinDateCellRangeFunction = (input: IsDateWithinDateCellRangeInput) => boolean;
613
+ /**
614
+ * Configuration for {@link isDateWithinDateCellRangeFunction}.
615
+ *
616
+ * The `startsAt` provides timezone context for converting dates to indexes.
617
+ * If omitted and the range is a single Date, the system timezone is used;
618
+ * otherwise an error is thrown since date-to-index conversion requires timezone info.
619
+ */
409
620
  export interface IsDateWithinDateCellRangeConfig {
410
621
  /**
411
622
  * Optional DateCellTimingStartsAt to make the indexes relative to when converting date values.
@@ -418,4 +629,26 @@ export interface IsDateWithinDateCellRangeConfig {
418
629
  */
419
630
  range: IsDateWithinDateCellRangeInput;
420
631
  }
632
+ /**
633
+ * Creates a predicate that checks whether a date, index, or range falls within
634
+ * the configured reference range.
635
+ *
636
+ * Converts all date-based inputs to cell indexes using the configured (or inferred) timezone
637
+ * before performing the containment check.
638
+ *
639
+ * @throws Error if `startsAt` is not provided and cannot be inferred from the range input
640
+ * (e.g., when a DateRange without a single-date range is used without explicit startsAt).
641
+ *
642
+ * @example
643
+ * ```ts
644
+ * const isInRange = isDateWithinDateCellRangeFunction({
645
+ * startsAt: timing,
646
+ * range: { i: 2, to: 5 }
647
+ * });
648
+ *
649
+ * isInRange(3); // true - index 3 is within [2, 5]
650
+ * isInRange(6); // false - index 6 is outside [2, 5]
651
+ * isInRange(someDate); // converts date to index, then checks containment
652
+ * ```
653
+ */
421
654
  export declare function isDateWithinDateCellRangeFunction(config: IsDateWithinDateCellRangeConfig): IsDateWithinDateCellRangeFunction;