@dereekb/date 9.24.47 → 9.25.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 (77) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +2 -2
  3. package/src/lib/date/date.block.d.ts +373 -16
  4. package/src/lib/date/date.block.day.d.ts +1 -0
  5. package/src/lib/date/date.block.day.js +1 -0
  6. package/src/lib/date/date.block.day.js.map +1 -1
  7. package/src/lib/date/date.block.js +236 -24
  8. package/src/lib/date/date.block.js.map +1 -1
  9. package/src/lib/date/{date.validator.d.ts → date.block.validator.d.ts} +6 -0
  10. package/src/lib/date/{date.validator.js → date.block.validator.js} +7 -1
  11. package/src/lib/date/date.block.validator.js.map +1 -0
  12. package/src/lib/date/date.block.week.d.ts +24 -0
  13. package/src/lib/date/date.block.week.js +12 -0
  14. package/src/lib/date/date.block.week.js.map +1 -1
  15. package/src/lib/date/date.cell.d.ts +357 -0
  16. package/src/lib/date/date.cell.factory.d.ts +337 -0
  17. package/src/lib/date/date.cell.factory.js +479 -0
  18. package/src/lib/date/date.cell.factory.js.map +1 -0
  19. package/src/lib/date/date.cell.filter.d.ts +18 -0
  20. package/src/lib/date/date.cell.filter.js +65 -0
  21. package/src/lib/date/date.cell.filter.js.map +1 -0
  22. package/src/lib/date/date.cell.index.d.ts +375 -0
  23. package/src/lib/date/date.cell.index.js +731 -0
  24. package/src/lib/date/date.cell.index.js.map +1 -0
  25. package/src/lib/date/date.cell.js +518 -0
  26. package/src/lib/date/date.cell.js.map +1 -0
  27. package/src/lib/date/date.cell.schedule.d.ts +409 -0
  28. package/src/lib/date/date.cell.schedule.day.d.ts +9 -0
  29. package/src/lib/date/date.cell.schedule.day.js +15 -0
  30. package/src/lib/date/date.cell.schedule.day.js.map +1 -0
  31. package/src/lib/date/date.cell.schedule.js +667 -0
  32. package/src/lib/date/date.cell.schedule.js.map +1 -0
  33. package/src/lib/date/date.cell.validator.d.ts +14 -0
  34. package/src/lib/date/date.cell.validator.js +67 -0
  35. package/src/lib/date/date.cell.validator.js.map +1 -0
  36. package/src/lib/date/date.cell.week.d.ts +31 -0
  37. package/src/lib/date/date.cell.week.js +40 -0
  38. package/src/lib/date/date.cell.week.js.map +1 -0
  39. package/src/lib/date/date.d.ts +18 -0
  40. package/src/lib/date/date.duration.d.ts +2 -1
  41. package/src/lib/date/date.duration.js +6 -1
  42. package/src/lib/date/date.duration.js.map +1 -1
  43. package/src/lib/date/date.format.js +2 -1
  44. package/src/lib/date/date.format.js.map +1 -1
  45. package/src/lib/date/date.js +29 -1
  46. package/src/lib/date/date.js.map +1 -1
  47. package/src/lib/date/date.range.d.ts +4 -2
  48. package/src/lib/date/date.range.js +6 -4
  49. package/src/lib/date/date.range.js.map +1 -1
  50. package/src/lib/date/date.range.timezone.d.ts +27 -6
  51. package/src/lib/date/date.range.timezone.js +21 -7
  52. package/src/lib/date/date.range.timezone.js.map +1 -1
  53. package/src/lib/date/date.schedule.d.ts +99 -0
  54. package/src/lib/date/date.schedule.js +63 -0
  55. package/src/lib/date/date.schedule.js.map +1 -1
  56. package/src/lib/date/date.time.js +3 -3
  57. package/src/lib/date/date.time.js.map +1 -1
  58. package/src/lib/date/date.timezone.d.ts +98 -3
  59. package/src/lib/date/date.timezone.js +191 -24
  60. package/src/lib/date/date.timezone.js.map +1 -1
  61. package/src/lib/date/date.week.js +2 -0
  62. package/src/lib/date/date.week.js.map +1 -1
  63. package/src/lib/date/index.d.ts +8 -1
  64. package/src/lib/date/index.js +8 -1
  65. package/src/lib/date/index.js.map +1 -1
  66. package/src/lib/expires/expires.js +1 -1
  67. package/src/lib/expires/expires.js.map +1 -1
  68. package/src/lib/timezone/index.d.ts +1 -0
  69. package/src/lib/timezone/index.js +1 -0
  70. package/src/lib/timezone/index.js.map +1 -1
  71. package/src/lib/timezone/timezone.d.ts +7 -0
  72. package/src/lib/timezone/timezone.js +14 -2
  73. package/src/lib/timezone/timezone.js.map +1 -1
  74. package/src/lib/timezone/timezone.validator.d.ts +6 -0
  75. package/src/lib/timezone/timezone.validator.js +26 -0
  76. package/src/lib/timezone/timezone.validator.js.map +1 -0
  77. package/src/lib/date/date.validator.js.map +0 -1
@@ -0,0 +1,357 @@
1
+ import { IndexRef, Maybe, TimezoneString, Minutes, FractionalHour, TimezoneStringRef, ISO8601DayString } from '@dereekb/util';
2
+ import { DateRange, DateRangeDayDistanceInput } from './date.range';
3
+ import { DateDurationSpan } from './date.duration';
4
+ import { DateTimezoneUtcNormalFunctionInput, DateTimezoneUtcNormalInstance } from './date.timezone';
5
+ /**
6
+ * Index from 0 of which day this block represents.
7
+ */
8
+ export declare type DateCellIndex = number;
9
+ /**
10
+ * Returns true if the index is a non-negative integer.
11
+ *
12
+ * @param input
13
+ */
14
+ export declare function isValidDateCellIndex(input: DateCellIndex): boolean;
15
+ /**
16
+ * Input type that is either a Date or a DateCellIndex.
17
+ */
18
+ export declare type DateOrDateCellIndex = Date | DateCellIndex;
19
+ /**
20
+ * A duration-span block.
21
+ */
22
+ export interface DateCell extends IndexRef {
23
+ i: DateCellIndex;
24
+ }
25
+ export declare class DateCell {
26
+ i: DateCellIndex;
27
+ constructor(template?: DateCell);
28
+ }
29
+ /**
30
+ * Converts the input number or DateCell to a DateCell.
31
+ *
32
+ * @param dateCellOrIndex
33
+ * @returns
34
+ */
35
+ export declare function dateCell(dateCellOrIndex: DateCellIndex | DateCell): DateCell;
36
+ /**
37
+ * An array of DateCell-like values.
38
+ */
39
+ export declare type DateCellArray<B extends DateCell = DateCell> = B[];
40
+ /**
41
+ * Reference to a DateCellArray
42
+ */
43
+ export declare type DateCellArrayRef<B extends DateCell = DateCell> = {
44
+ blocks: DateCellArray<B>;
45
+ };
46
+ /**
47
+ * The DateCellTimingStartsAt and startsAt times and timezone.
48
+ *
49
+ * Used to derive the indexes for the days.
50
+ */
51
+ export declare type DateCellTimingStartsAt = Pick<DateCellTiming, 'startsAt' | 'timezone'>;
52
+ /**
53
+ * Input for dateCellTimingStartsAtForStartOfDay()
54
+ */
55
+ export interface DateCellTimingStartsAtForStartOfDayInput {
56
+ /**
57
+ * "Now" date in the system timezone normal.
58
+ */
59
+ readonly now?: Date | ISO8601DayString;
60
+ /**
61
+ * Timezone string
62
+ */
63
+ readonly timezone?: TimezoneString;
64
+ }
65
+ /**
66
+ * Creates a new DateCellTimingStartsAt for the given time and timezone.
67
+ *
68
+ * @param now
69
+ * @returns
70
+ */
71
+ export declare function dateCellTimingStartsAtForStartOfDay(input?: DateCellTimingStartsAtForStartOfDayInput): DateCellTimingStartsAt;
72
+ /**
73
+ * The DateCellTimingEnd and endsAt times and timezone.
74
+ */
75
+ export declare type DateCellTimingEnd = Pick<DateCellTiming, 'end'>;
76
+ /**
77
+ * Is combination of DateRange and DateDurationSpan. The DateRange captures a range of days that a DateCell takes up, and the DateDurationSpan
78
+ * captures the Dates at which the Job occurs at.
79
+ *
80
+ * NOTES:
81
+ * - The startsAt time is the time of the first event.
82
+ * - The end time is the ending date/time of the final end duration.
83
+ * - The timezone is required to properly handle daylight savings and timezone differences.
84
+ */
85
+ export interface DateCellTiming extends DateDurationSpan, TimezoneStringRef, Pick<DateRange, 'end'> {
86
+ }
87
+ /**
88
+ * Corresponds to the range of dates in a DateCellTiming.
89
+ *
90
+ * NOTES:
91
+ * - The start time is midnight in the given timezone of the first day of the range.
92
+ * - The end time is the ending date/time of the final end duration.
93
+ * - The timezone is required to properly handle daylight savings and timezone differences.
94
+ */
95
+ export interface DateCellTimingDateRange extends DateRange, TimezoneStringRef {
96
+ }
97
+ /**
98
+ * A DateCellTimingDateRange, but the start time is the startsAt time for the first event.
99
+ */
100
+ export declare type DateCellTimingEventRange = DateCellTimingDateRange;
101
+ export declare class DateCellTiming extends DateDurationSpan {
102
+ end: Date;
103
+ timezone: TimezoneString;
104
+ constructor(template?: DateCellTiming);
105
+ }
106
+ /**
107
+ * Reference to a DateCellTiming
108
+ */
109
+ export interface DateCellTimingRef {
110
+ timing: DateCellTiming;
111
+ }
112
+ /**
113
+ * An object that implements DateCellTimingRef and DateCellArrayRef
114
+ */
115
+ export interface DateCellCollection<B extends DateCell = DateCell> extends DateCellTimingRef, DateCellArrayRef<B> {
116
+ }
117
+ /**
118
+ * An expanded DateCell that implements DateDurationSpan and contains the DateCell values.
119
+ */
120
+ export declare type DateCellDurationSpan<B extends DateCell = DateCell> = DateDurationSpan & B;
121
+ /**
122
+ * The DateRange input for dateCellTiming()
123
+ */
124
+ export declare type DateCellTimingRangeInput = Pick<DateRangeDayDistanceInput, 'distance'> | DateRange | number;
125
+ /**
126
+ * Can use any timezone instance that has a timezone configured, or is using the
127
+ */
128
+ export declare type DateCellTimingTimezoneInput = Omit<DateTimezoneUtcNormalFunctionInput, 'number'>;
129
+ /**
130
+ * Creates a DateTimezoneUtcNormalInstance from the input. Asserts and gurantees that a timezone string is provided.
131
+ *
132
+ * If null/undefined is passed, returns a normal for the system time.
133
+ *
134
+ * @param timezoneInput
135
+ * @returns
136
+ */
137
+ export declare function dateCellTimingTimezoneNormalInstance(timezoneInput?: DateCellTimingTimezoneInput): DateTimezoneUtcNormalInstance;
138
+ /**
139
+ * A DateCellTiming that also implements DateCellTimingDateRange.
140
+ */
141
+ export interface FullDateCellTiming extends DateCellTiming, DateCellTimingDateRange {
142
+ }
143
+ /**
144
+ * The start date within a FullDateCellTiming.
145
+ */
146
+ export declare type FullDateCellTimingStart = Pick<FullDateCellTiming, 'start'>;
147
+ /**
148
+ * Creates a FullDateCellTiming from the input timing.
149
+ *
150
+ * @param timing
151
+ * @returns
152
+ */
153
+ export declare function fullDateCellTiming(timing: DateCellTiming): FullDateCellTiming;
154
+ export interface FullDateCellTimingTimezonePair {
155
+ readonly fullTiming: FullDateCellTiming;
156
+ readonly normalInstance: DateTimezoneUtcNormalInstance;
157
+ }
158
+ /**
159
+ * Creates a FullDateCellTimingTimezonePair from the input timing.
160
+ *
161
+ * @param timing
162
+ * @returns
163
+ */
164
+ export declare function fullDateCellTimingTimezonePair(timing: DateCellTiming): FullDateCellTimingTimezonePair;
165
+ /**
166
+ * Returns true if the start date has no minutes/seconds/milliseconds. It should be midnight for it's target timezone.
167
+ *
168
+ * @param date
169
+ * @returns
170
+ */
171
+ export declare function isValidDateCellTimingStartDate(date: Date): boolean;
172
+ /**
173
+ * Creates a valid DateCell timing from the DateDurationSpan and range input.
174
+ *
175
+ * The duration is first considered, then the date range is applied to it.
176
+ *
177
+ * If a number is passed as the input range, then the duration's startsAt date will be used and the input number used as the distance.
178
+ * The input range's date takes priority over the duration's startsAt start date, meaning the input date range will be adapted
179
+ * to fit the startsAt time.
180
+ *
181
+ * The input range date is used as the start and end date ranges, meaning they will be used as the expected date offset (have only hours, no minutes/seconds/milliseconds) and be validated as such.
182
+ * The end date is used just to determine the number of days, but a minimum of 1 day is always enforced as a DateCellTiming must contain atleast 1 day.
183
+ *
184
+ * The start date from the inputDate is considered to to have the offset noted in DateCell, and will be retained.
185
+ */
186
+ export declare function dateCellTiming(durationInput: DateDurationSpan, inputRange: DateCellTimingRangeInput, timezoneInput?: DateCellTimingTimezoneInput): FullDateCellTiming;
187
+ export interface DateCellTimingStartPair {
188
+ readonly start: Date;
189
+ readonly normalInstance: DateTimezoneUtcNormalInstance;
190
+ }
191
+ /**
192
+ * Convenience function of dateCellTimingStart() that also returns the DateTimezoneUtcNormalInstance.
193
+ *
194
+ * @param timing
195
+ * @returns
196
+ */
197
+ export declare function dateCellTimingStartPair(timing: DateCellTimingStartsAt): DateCellTimingStartPair;
198
+ /**
199
+ * Start date value for a DateCellTiming.
200
+ *
201
+ * This is the midnight date instance for the timezone.
202
+ */
203
+ export declare function dateCellTimingStart(timing: DateCellTimingStartsAt): Date;
204
+ /**
205
+ * The DateRange component and timezone for a DateCellTiming. The start date is a DateCellTimingStartsAt.
206
+ */
207
+ export declare type DateCellTimingStartsAtEndRange = Pick<DateCellTiming, 'startsAt' | 'end' | 'timezone'>;
208
+ /**
209
+ * The startsAt time of the event.
210
+ */
211
+ export declare type DateCellTimingEventStartsAt = Pick<DateCellTiming, 'startsAt'>;
212
+ /**
213
+ * A startsAt time and duration that represents a single event.
214
+ */
215
+ export declare type DateCellTimingEvent = Pick<DateCellTiming, 'startsAt' | 'duration'>;
216
+ /**
217
+ * Returns true if the two DateCellTimingStartsAtEndRange values are the same.
218
+ *
219
+ * @param a
220
+ * @param b
221
+ */
222
+ export declare function isSameDateCellTimingEventStartsAtEndRange(a: Maybe<DateCellTimingStartsAtEndRange>, b: Maybe<DateCellTimingStartsAtEndRange>): boolean;
223
+ /**
224
+ * Returns true if the two timings are equivalent.
225
+ *
226
+ * @param a
227
+ * @param b
228
+ */
229
+ export declare function isSameDateCellTiming(a: Maybe<DateCellTiming>, b: Maybe<DateCellTiming>): boolean;
230
+ /**
231
+ * Returns true if all variables in the input FullDateCellTimings are exact.
232
+ *
233
+ * In most cases this comparison is unnecessary, as the start date is derived from the startsAt time.
234
+ *
235
+ * @param a
236
+ * @param b
237
+ * @returns
238
+ */
239
+ export declare function isSameFullDateCellTiming(a: Maybe<FullDateCellTiming>, b: Maybe<FullDateCellTiming>): boolean;
240
+ /**
241
+ * Returns true if the input is a DateCellTiming.
242
+ *
243
+ * Does not check if it is a valid DateCellTiming.
244
+ *
245
+ * @param input
246
+ */
247
+ export declare function isDateCellTiming(input: unknown): input is DateCellTiming;
248
+ /**
249
+ * Returns true if the input is possibly a FullDateCellTiming.
250
+ *
251
+ * Does not check if it is a valid FullDateCellTiming.
252
+ *
253
+ * @param input
254
+ */
255
+ export declare function isFullDateCellTiming(input: unknown): input is FullDateCellTiming;
256
+ /**
257
+ * Creates a DateCellTimingDateRange from the input timing.
258
+ *
259
+ * @param timing
260
+ * @returns
261
+ */
262
+ export declare function dateCellTimingDateRange(timing: DateCellTimingStartsAtEndRange): DateCellTimingDateRange;
263
+ /**
264
+ * Returns the date range from the start of the first event to the end time of the last event.
265
+ *
266
+ * @param timing
267
+ * @returns
268
+ */
269
+ export declare function dateCellTimingEventRange(timing: Pick<DateCellTiming, 'startsAt' | 'end' | 'timezone'>): DateCellTimingEventRange;
270
+ /**
271
+ * Returns the total minutes between the start of the first event and the end of the last event.
272
+ *
273
+ * @param timing
274
+ * @returns
275
+ */
276
+ export declare function getDateCellTimingFirstEventDateRange(timing: DateCellTimingStartsAtEndRange): DateRange;
277
+ /**
278
+ * Returns the number of hours in a DateCellTiming's duration.
279
+ *
280
+ * @param timing
281
+ */
282
+ export declare function getDateCellTimingHoursInEvent(timing: Pick<DateCellTiming, 'duration'>): FractionalHour;
283
+ /**
284
+ * Returns a copy of the input timing adjusted for the input timezone and all FullDateCellTiming values updated to reflect the changes.
285
+ *
286
+ * @param timing
287
+ */
288
+ export declare type ChangeDateCellTimingToTimezoneFunction = (<T extends DateCellTimingStartsAtEndRange>(timing: T) => T & FullDateCellTiming) & {
289
+ readonly _normalInstance: DateTimezoneUtcNormalInstance;
290
+ };
291
+ /**
292
+ * Creates a ChangeDateCellTimingToTimezoneFunction from the input.
293
+ *
294
+ * @param input
295
+ * @returns
296
+ */
297
+ export declare function changeDateCellTimingToTimezoneFunction(timezoneInput: DateCellTimingTimezoneInput): ChangeDateCellTimingToTimezoneFunction;
298
+ /**
299
+ * Convenience function for calling changeDateCellTimingToTimezone() with the system timezone.
300
+ *
301
+ * @param timing
302
+ * @returns
303
+ */
304
+ export declare function changeDateCellTimingToSystemTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T): T;
305
+ /**
306
+ * Convenience function for calling changeDateCellTimingToTimezoneFunction() and passing the timing.
307
+ *
308
+ * @param timing
309
+ * @param timezone
310
+ * @returns
311
+ */
312
+ export declare function changeDateCellTimingToTimezone<T extends DateCellTimingStartsAtEndRange>(timing: T, timezone: DateCellTimingTimezoneInput): T;
313
+ export interface CalculateExpectedDateCellTimingDurationPair {
314
+ readonly duration: Minutes;
315
+ readonly expectedFinalStartsAt: Date;
316
+ }
317
+ /**
318
+ * Returns the expected duration from the input.
319
+ *
320
+ * @param timing
321
+ * @returns
322
+ */
323
+ export declare function calculateExpectedDateCellTimingDurationPair(timing: DateCellTimingStartsAtEndRange): CalculateExpectedDateCellTimingDurationPair;
324
+ export declare function calculateExpectedDateCellTimingDuration(timing: DateCellTimingStartsAtEndRange): Minutes;
325
+ /**
326
+ * Returns the final StartsAt time.
327
+ *
328
+ * @param timing
329
+ * @returns
330
+ */
331
+ export declare function dateCellTimingFinalStartsAtEvent(timing: DateCellTimingStartsAtEndRange): DateCellTimingEvent;
332
+ export interface IsValidDateCellTimingInfo {
333
+ readonly isValid: boolean;
334
+ readonly startsAtHasZeroSeconds: boolean;
335
+ readonly endIsAfterTheStartsAtTime: boolean;
336
+ readonly durationGreaterThanZero: boolean;
337
+ readonly durationLessThan24Hours: boolean;
338
+ readonly isExpectedValidEnd: boolean;
339
+ readonly normalInstance: DateTimezoneUtcNormalInstance;
340
+ }
341
+ export declare function isValidDateCellTimingInfo(timing: DateCellTiming): IsValidDateCellTimingInfo;
342
+ /**
343
+ * Convenience function for checking whether or not DateCellTiming is valid.
344
+ *
345
+ * @param timing
346
+ * @returns
347
+ */
348
+ export declare function isValidDateCellTiming(timing: DateCellTiming): boolean;
349
+ export interface IsValidFullDateCellTimingInfo extends IsValidDateCellTimingInfo {
350
+ readonly isStartRoundedToSeconds: boolean;
351
+ readonly startIsAtMidnight: boolean;
352
+ readonly startHasZeroSeconds: boolean;
353
+ readonly startsAtIsAfterStart: boolean;
354
+ readonly startsAtIsLessThan24HoursAfterStart: boolean;
355
+ }
356
+ export declare function isValidFullDateCellTimingInfo(timing: FullDateCellTiming): IsValidFullDateCellTimingInfo;
357
+ export declare function isValidFullDateCellTiming(timing: FullDateCellTiming): boolean;
@@ -0,0 +1,337 @@
1
+ import { Maybe, ArrayOrValue, FilterFunction, IndexRange, ISO8601DayString } from '@dereekb/util';
2
+ import { DateCell, DateCellIndex, DateOrDateCellIndex, DateCellTiming, DateCellArrayRef, DateCellArray, DateCellTimingRangeInput, DateCellCollection, DateCellDurationSpan, DateCellTimingStartsAt, DateCellTimingEvent, DateCellTimingStartsAtEndRange, FullDateCellTiming } from './date.cell';
3
+ import { DateCellRange, DateCellRangeWithRange, DateOrDateRangeOrDateCellIndexOrDateCellRange } from './date.cell.index';
4
+ import { DateRange, DateRangeStart } from './date.range';
5
+ import { DateTimezoneConversionConfigUseSystemTimezone, DateTimezoneUtcNormalInstance } from './date.timezone';
6
+ /**
7
+ * IndexRange used with DateCells.
8
+ *
9
+ * It has an exclusive max range. It is similar to a DateCellRange.
10
+ */
11
+ export declare type DateCellIndexRange = IndexRange;
12
+ export declare function dateCellRangeToDateCellIndexRange(range: DateCellRange): DateCellIndexRange;
13
+ export declare function dateCellIndexRangeToDateCellRange(range: DateCellIndexRange): DateCellRangeWithRange;
14
+ /**
15
+ * Generates a DateCellIndexRange based on the input timing.
16
+ *
17
+ * An arbitrary limit can also be applied.
18
+ *
19
+ * @param timing
20
+ * @param limit
21
+ * @param fitToTimingRange
22
+ */
23
+ export declare function dateCellIndexRange(timing: DateCellTiming, limit?: DateCellTimingRangeInput, fitToTimingRange?: boolean): DateCellIndexRange;
24
+ /**
25
+ * Convenience function for calling expandDateCells() with the input DateCellCollection.
26
+ *
27
+ * @param collection
28
+ * @returns
29
+ */
30
+ export declare function expandDateCellCollection<B extends DateCell = DateCell>(collection: DateCellCollection<B>): DateCellDurationSpan<B>[];
31
+ /**
32
+ * Convenience function for calling dateCellTimingExpansionFactory() then passing the blocks.
33
+ *
34
+ * @param blocks
35
+ * @param timing
36
+ * @returns
37
+ */
38
+ export declare function expandDateCellTiming<B extends DateCell = DateCell>(timing: DateCellTiming, blocks: B[]): DateCellDurationSpan<B>[];
39
+ export declare type DateCellTimingExpansionFactoryInput<B extends DateCell | DateCellRange = DateCell> = DateCellArrayRef<B> | DateCellArray<B>;
40
+ /**
41
+ * Used to convert the input DateCellTimingExpansionFactoryInput into an array of DateCellDurationSpan values
42
+ */
43
+ export declare type DateCellTimingExpansionFactory<B extends DateCell | DateCellRange = DateCell> = (input: DateCellTimingExpansionFactoryInput<B>) => DateCellDurationSpan<B>[];
44
+ export interface DateCellTimingExpansionFactoryConfig<B extends DateCell | DateCellRange = DateCell> {
45
+ /**
46
+ * Timing to use in the configuration.
47
+ */
48
+ timing: DateCellTiming;
49
+ /**
50
+ * Range to limit duration span output to.
51
+ *
52
+ * If not provided, uses the input timing's range.
53
+ * If false, the timing's range is ignored too, and only the DateCellIndex values are considered.
54
+ */
55
+ rangeLimit?: DateCellTimingRangeInput | false;
56
+ /**
57
+ * Additional filter function to filter potential blocks in/out.
58
+ */
59
+ filter?: FilterFunction<B>;
60
+ /**
61
+ * (Optional) Additional filter function based on the calcualted DateCellDurationSpan.
62
+ */
63
+ durationSpanFilter?: FilterFunction<DateCellDurationSpan<B>>;
64
+ /**
65
+ * (Optional) Max number of blocks to evaluate.
66
+ */
67
+ blocksEvaluationLimit?: number;
68
+ /**
69
+ * (Optional) Max number of DateCellDurationSpan values to return.
70
+ */
71
+ maxDateCellsToReturn?: number;
72
+ }
73
+ /**
74
+ * Creates a DateCellTimingExpansionFactory
75
+ *
76
+ * @param config
77
+ * @returns
78
+ */
79
+ export declare function dateCellTimingExpansionFactory<B extends DateCell | DateCellRange = DateCell>(config: DateCellTimingExpansionFactoryConfig): DateCellTimingExpansionFactory<B>;
80
+ export declare type DateCellDayTimingInfoFactoryConfig = Pick<DateCellTimingExpansionFactoryConfig, 'timing' | 'rangeLimit'>;
81
+ export interface DateCellDayTimingInfo {
82
+ /**
83
+ * Input date or calculated date if provided a dayIndex.
84
+ */
85
+ date: Date;
86
+ /**
87
+ * Index for the day for the input date.
88
+ */
89
+ dayIndex: DateCellIndex;
90
+ /**
91
+ * Index for the previous index/current index depending on the TimingInfo's daily execution.
92
+ *
93
+ * If the index is currently in progress given the timing, this will return the dayIndex.
94
+ */
95
+ currentIndex: DateCellIndex;
96
+ /**
97
+ * Index for the next execution. Does not check if it is in range.
98
+ *
99
+ * If the index is currently in progress given the timing, this will return the dayIndex + 1.
100
+ */
101
+ nextIndex: DateCellIndex;
102
+ /**
103
+ * Index for the next execution, if in the range, otherwise undefined.
104
+ *
105
+ * If the index is currently in progress given the timing, this will return the dayIndex + 1.
106
+ */
107
+ nextIndexInRange: Maybe<DateCellIndex>;
108
+ /**
109
+ * Whether or not there are any inProgress or upcoming executions.
110
+ *
111
+ * True if nextIndexInRange is undefined and isInProgress is false.
112
+ */
113
+ isComplete: boolean;
114
+ /**
115
+ * Whether or not today's timing has already occured in it's entirety.
116
+ */
117
+ hasOccuredToday: boolean;
118
+ /**
119
+ * Whether or not today's timing is currently in progress.
120
+ */
121
+ isInProgress: boolean;
122
+ /**
123
+ * Whether or not the block is within the configured range.
124
+ */
125
+ isInRange: boolean;
126
+ /**
127
+ * Time the timing starts on the input day.
128
+ */
129
+ startsAtOnDay: Date;
130
+ /**
131
+ * Time the timing ends on the input day.
132
+ */
133
+ endsAtOnDay: Date;
134
+ /**
135
+ * "now" value used for considering current progress.
136
+ */
137
+ now: Date;
138
+ }
139
+ /**
140
+ * Generates DateCellDayTimingInfo about the input date relative to the input timing and range limit.
141
+ *
142
+ * The date may not exist within the range, but will still compute values using the input date and timing configuration.
143
+ *
144
+ * Can optionally specify a now that is used for checking the inProgress functionality.
145
+ */
146
+ export declare type DateCellDayTimingInfoFactory = (date: DateOrDateCellIndex, now?: Date) => DateCellDayTimingInfo;
147
+ export declare function dateCellDayTimingInfoFactory(config: DateCellDayTimingInfoFactoryConfig): DateCellDayTimingInfoFactory;
148
+ /**
149
+ * DateCellTimingRelativeIndexFactory input. Can be a Date, DateCellIndex, or ISO8601DayString
150
+ */
151
+ export declare type DateCellTimingRelativeIndexFactoryInput = DateOrDateCellIndex | ISO8601DayString;
152
+ /**
153
+ * Returns the DateCellIndex of the input date relative to the configured Date.
154
+ *
155
+ * Input dates should be in system time zone and not normalized to a different timezone.
156
+ */
157
+ export declare type DateCellTimingRelativeIndexFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateCellTimingRelativeIndexFactoryInput) => DateCellIndex) & {
158
+ readonly _timing: T;
159
+ readonly _normalInstance: DateTimezoneUtcNormalInstance;
160
+ };
161
+ /**
162
+ * Returns true if the input is a DateCellTimingRelativeIndexFactory.
163
+ *
164
+ * @param input
165
+ * @returns
166
+ */
167
+ export declare function isDateCellTimingRelativeIndexFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: unknown): input is DateCellTimingRelativeIndexFactory<T>;
168
+ /**
169
+ * Creates a DateCellTimingRelativeIndexFactory from the input.
170
+ *
171
+ * @param input
172
+ * @returns
173
+ */
174
+ export declare function dateCellTimingRelativeIndexFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingRelativeIndexFactory<T>;
175
+ /**
176
+ * Function that wraps a DateCellTimingRelativeIndexFactory and converts multuple Date/DateCellIndex/DateCellRange values into an array of DateCellIndex values.
177
+ */
178
+ export declare type DateCellTimingRelativeIndexArrayFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: ArrayOrValue<DateOrDateRangeOrDateCellIndexOrDateCellRange>) => DateCellIndex[]) & {
179
+ readonly _indexFactory: DateCellTimingRelativeIndexFactory<T>;
180
+ };
181
+ /**
182
+ * Creates a DateCellTimingRelativeIndexArrayFactory from the input DateCellTimingRelativeIndexFactory.
183
+ *
184
+ * @param indexFactory
185
+ */
186
+ export declare function dateCellTimingRelativeIndexArrayFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(indexFactory: DateCellTimingRelativeIndexFactory<T>): DateCellTimingRelativeIndexArrayFactory<T>;
187
+ /**
188
+ * Gets the relative index of the input date compared to the input timing.
189
+ *
190
+ * @param timing
191
+ * @param date
192
+ */
193
+ export declare function getRelativeIndexForDateCellTiming(timing: DateCellTimingStartsAt, date?: DateOrDateCellIndex): DateCellIndex;
194
+ /**
195
+ * Similar to the DateCellTimingRelativeIndexFactory, but returns a date instead of an index for the input.
196
+ *
197
+ * Returns a date with the hours and minutes for "now" for the given date returned if an index is input.
198
+ */
199
+ export declare type DateCellTimingDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateOrDateCellIndex) => Date) & {
200
+ readonly _timing: T;
201
+ };
202
+ /**
203
+ * Creates a DateCellTimingDateFactory.
204
+ *
205
+ * @param timing
206
+ * @returns
207
+ */
208
+ export declare function dateCellTimingDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(timing: T): DateCellTimingDateFactory<T>;
209
+ /**
210
+ * Returns the start time of the input date or index.
211
+ */
212
+ export declare type DateCellTimingStartDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateCellTimingRelativeIndexFactoryInput) => Date) & {
213
+ readonly _indexFactory: DateCellTimingRelativeIndexFactory<T>;
214
+ };
215
+ export declare type DateCellTimingUseSystemAndIgnoreEnforcement = DateTimezoneConversionConfigUseSystemTimezone & {
216
+ /**
217
+ * Skips the assertion that the timezone matches. This defaults to true if not provided.
218
+ */
219
+ assertTimingMatchesTimezone: false;
220
+ };
221
+ /**
222
+ * Creates a DateCellTimingDateFactory.
223
+ *
224
+ * @param timing
225
+ * @returns
226
+ */
227
+ export declare function dateCellTimingStartDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingStartDateFactory<T>;
228
+ /**
229
+ * Returns the startsAt time of the input date or index.
230
+ */
231
+ export declare type DateCellTimingStartsAtDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateCellTimingRelativeIndexFactoryInput) => Date) & {
232
+ readonly _indexFactory: DateCellTimingRelativeIndexFactory<T>;
233
+ };
234
+ /**
235
+ * Creates a DateCellTimingStartsAtDateFactory.
236
+ *
237
+ * @param timing
238
+ * @returns
239
+ */
240
+ export declare function dateCellTimingStartsAtDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingStartsAtDateFactory<T>;
241
+ /**
242
+ * Returns the startsAt time of the input date or index.
243
+ */
244
+ export declare type DateCellTimingEndDateFactory<T extends DateCellTiming = DateCellTiming> = ((input: DateCellTimingRelativeIndexFactoryInput) => Date) & {
245
+ readonly _startsAtDateFactory: DateCellTimingStartsAtDateFactory<T>;
246
+ };
247
+ /**
248
+ * Creates a DateCellTimingStartsAtDateFactory.
249
+ *
250
+ * @param timing
251
+ * @returns
252
+ */
253
+ export declare function dateCellTimingEndDateFactory<T extends DateCellTiming = DateCellTiming>(input: T | DateCellTimingRelativeIndexFactory<T>): DateCellTimingEndDateFactory<T>;
254
+ /**
255
+ * Returns the date of the input index.
256
+ *
257
+ * @param timing
258
+ * @param date
259
+ */
260
+ export declare function getRelativeDateForDateCellTiming(timing: DateCellTimingStartsAt, input: DateOrDateCellIndex): Date;
261
+ /**
262
+ * Converts a DateCellTimingStartsAtEndRange to a DateCellTiming by calculating the difference in hours from the last startsAt timing and the end.
263
+ *
264
+ * @param dateCellTimingStartEndRange
265
+ * @param event
266
+ * @param timezone
267
+ * @returns
268
+ */
269
+ export declare function dateCellTimingFromDateCellTimingStartsAtEndRange(dateCellTimingStartsAtEndRange: DateCellTimingStartsAtEndRange): DateCellTiming;
270
+ export interface UpdateDateCellTimingWithDateCellTimingEventInput {
271
+ /**
272
+ * Target timing to update.
273
+ */
274
+ readonly timing: DateCellTimingStartsAtEndRange;
275
+ /**
276
+ * Event used to update the timing.
277
+ */
278
+ readonly event: DateCellTimingEvent;
279
+ /**
280
+ * Custom start date day to use instead of the event's start date.
281
+ *
282
+ * It is generated relative to the timing's current startsAt, and not the event's starts at, so index 0 is the first day of the Timing, not the event.
283
+ *
284
+ * Ignored if replaceStartDay is not true.
285
+ */
286
+ readonly startDayDate?: DateCellTimingRelativeIndexFactoryInput;
287
+ /**
288
+ * Replaces the start date but keeps the startsAt time as-is.
289
+ *
290
+ * Can be combined with replaceStartsAt.
291
+ */
292
+ readonly replaceStartDay?: boolean;
293
+ /**
294
+ * Replaces the startsAt time, but keeps the initial start date.
295
+ *
296
+ * Can be combined with replaceStartDay
297
+ */
298
+ readonly replaceStartsAt?: boolean;
299
+ /**
300
+ * Replaces the end day but keeps the same time.
301
+ */
302
+ readonly endOnEvent?: boolean;
303
+ /**
304
+ * Replaces the duration but keeps the end day intact.
305
+ */
306
+ readonly replaceDuration?: boolean;
307
+ }
308
+ /**
309
+ * Creates a new DateCellTiming from the input configuration.
310
+ *
311
+ * @param dateCellTimingStartEndRange
312
+ * @param event
313
+ * @param timezone
314
+ * @returns
315
+ */
316
+ export declare function updateDateCellTimingWithDateCellTimingEvent(input: UpdateDateCellTimingWithDateCellTimingEventInput): FullDateCellTiming;
317
+ /**
318
+ * Input for a IsDateWithinDateCellRangeFunction
319
+ */
320
+ export declare type IsDateWithinDateCellRangeInput = DateOrDateCellIndex | DateRangeStart | DateRange | DateCell | DateCellRange;
321
+ /**
322
+ * Function that returns true if the input range is equal or falls within the configured DateCellRange.
323
+ */
324
+ export declare type IsDateWithinDateCellRangeFunction = (input: IsDateWithinDateCellRangeInput) => boolean;
325
+ export interface IsDateWithinDateCellRangeConfig {
326
+ /**
327
+ * Optional DateCellTimingStartsAt to make the indexes relative to when converting date values.
328
+ *
329
+ * If not provided, defaults to the index in the range if a date is provided with the system timezone, or throws an exception if a date range is input.
330
+ */
331
+ startsAt?: DateCellTimingStartsAt;
332
+ /**
333
+ * Range to compare the input to.
334
+ */
335
+ range: IsDateWithinDateCellRangeInput;
336
+ }
337
+ export declare function isDateWithinDateCellRangeFunction(config: IsDateWithinDateCellRangeConfig): IsDateWithinDateCellRangeFunction;