@dereekb/date 10.1.5 → 10.1.6

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.
package/index.cjs.js CHANGED
@@ -5805,9 +5805,20 @@ function dateCellDayTimingInfoFactory(config) {
5805
5805
  const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
5806
5806
  const endsAtOnDay = dateFns.addMinutes(startsAtOnDay, duration);
5807
5807
  const potentiallyInProgress = !dateFns.isAfter(startsAtOnDay, now); // is potentially in progress if the now is equal-to or after the start time.
5808
- const isInProgress = potentiallyInProgress && !dateFns.isAfter(now, endsAtOnDay);
5809
- const hasOccuredToday = potentiallyInProgress && !isInProgress;
5810
- const currentIndex = isInProgress || hasOccuredToday ? dayIndex : dayIndex - 1; // If not in progress and hasn't occured today, current index is the previous index.
5808
+ const isInProgressForDayIndex = potentiallyInProgress && !dateFns.isAfter(now, endsAtOnDay);
5809
+ const hasOccuredToday = potentiallyInProgress && !isInProgressForDayIndex;
5810
+ const currentIndex = isInProgressForDayIndex || hasOccuredToday ? dayIndex : dayIndex - 1; // If not in progress and hasn't occured today, current index is the previous index.
5811
+ let isInProgress = false;
5812
+ if (isInProgressForDayIndex) {
5813
+ isInProgress = true;
5814
+ } else if (currentIndex < dayIndex) {
5815
+ const expectedStartForCurrentIndex = startsAtFactory(currentIndex);
5816
+ if (!dateFns.isBefore(now, expectedStartForCurrentIndex)) {
5817
+ // if now is after the expected start time, then check that the end time hasn't occured yet.
5818
+ const expectedEndTime = dateFns.addMinutes(expectedStartForCurrentIndex, duration);
5819
+ isInProgress = !dateFns.isAfter(now, expectedEndTime);
5820
+ }
5821
+ }
5811
5822
  const nextIndex = currentIndex + 1;
5812
5823
  const nextIndexInRange = checkIsInRange(nextIndex) ? nextIndex : undefined;
5813
5824
  const isComplete = currentIndex >= 0 && !nextIndexInRange && (!isInRange || hasOccuredToday);
@@ -5819,6 +5830,7 @@ function dateCellDayTimingInfoFactory(config) {
5819
5830
  nextIndex,
5820
5831
  hasOccuredToday,
5821
5832
  isInProgress,
5833
+ isInProgressForDayIndex,
5822
5834
  isInRange,
5823
5835
  startsAtOnDay,
5824
5836
  endsAtOnDay,
package/index.esm.js CHANGED
@@ -6410,9 +6410,22 @@ function dateCellDayTimingInfoFactory(config) {
6410
6410
  const endsAtOnDay = addMinutes(startsAtOnDay, duration);
6411
6411
  const potentiallyInProgress = !isAfter$1(startsAtOnDay, now); // is potentially in progress if the now is equal-to or after the start time.
6412
6412
 
6413
- const isInProgress = potentiallyInProgress && !isAfter$1(now, endsAtOnDay);
6414
- const hasOccuredToday = potentiallyInProgress && !isInProgress;
6415
- const currentIndex = isInProgress || hasOccuredToday ? dayIndex : dayIndex - 1; // If not in progress and hasn't occured today, current index is the previous index.
6413
+ const isInProgressForDayIndex = potentiallyInProgress && !isAfter$1(now, endsAtOnDay);
6414
+ const hasOccuredToday = potentiallyInProgress && !isInProgressForDayIndex;
6415
+ const currentIndex = isInProgressForDayIndex || hasOccuredToday ? dayIndex : dayIndex - 1; // If not in progress and hasn't occured today, current index is the previous index.
6416
+
6417
+ let isInProgress = false;
6418
+ if (isInProgressForDayIndex) {
6419
+ isInProgress = true;
6420
+ } else if (currentIndex < dayIndex) {
6421
+ const expectedStartForCurrentIndex = startsAtFactory(currentIndex);
6422
+ if (!isBefore(now, expectedStartForCurrentIndex)) {
6423
+ // if now is after the expected start time, then check that the end time hasn't occured yet.
6424
+
6425
+ const expectedEndTime = addMinutes(expectedStartForCurrentIndex, duration);
6426
+ isInProgress = !isAfter$1(now, expectedEndTime);
6427
+ }
6428
+ }
6416
6429
  const nextIndex = currentIndex + 1;
6417
6430
  const nextIndexInRange = checkIsInRange(nextIndex) ? nextIndex : undefined;
6418
6431
  const isComplete = currentIndex >= 0 && !nextIndexInRange && (!isInRange || hasOccuredToday);
@@ -6424,6 +6437,7 @@ function dateCellDayTimingInfoFactory(config) {
6424
6437
  nextIndex,
6425
6438
  hasOccuredToday,
6426
6439
  isInProgress,
6440
+ isInProgressForDayIndex,
6427
6441
  isInRange,
6428
6442
  startsAtOnDay,
6429
6443
  endsAtOnDay,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/date",
3
- "version": "10.1.5",
3
+ "version": "10.1.6",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -159,59 +159,65 @@ export interface DateCellDayTimingInfo {
159
159
  /**
160
160
  * Input date or calculated date if provided a dayIndex.
161
161
  */
162
- date: Date;
162
+ readonly date: Date;
163
163
  /**
164
164
  * Index for the day for the input date.
165
165
  */
166
- dayIndex: DateCellIndex;
166
+ readonly dayIndex: DateCellIndex;
167
167
  /**
168
168
  * Index for the previous index/current index depending on the TimingInfo's daily execution.
169
169
  *
170
170
  * If the index is currently in progress given the timing, this will return the dayIndex.
171
171
  */
172
- currentIndex: DateCellIndex;
172
+ readonly currentIndex: DateCellIndex;
173
173
  /**
174
174
  * Index for the next execution. Does not check if it is in range.
175
175
  *
176
176
  * If the index is currently in progress given the timing, this will return the dayIndex + 1.
177
177
  */
178
- nextIndex: DateCellIndex;
178
+ readonly nextIndex: DateCellIndex;
179
179
  /**
180
180
  * Index for the next execution, if in the range, otherwise undefined.
181
181
  *
182
182
  * If the index is currently in progress given the timing, this will return the dayIndex + 1.
183
183
  */
184
- nextIndexInRange: Maybe<DateCellIndex>;
184
+ readonly nextIndexInRange: Maybe<DateCellIndex>;
185
185
  /**
186
186
  * Whether or not there are any inProgress or upcoming executions.
187
187
  *
188
188
  * True if nextIndexInRange is undefined and isInProgress is false.
189
189
  */
190
- isComplete: boolean;
190
+ readonly isComplete: boolean;
191
191
  /**
192
192
  * Whether or not today's timing has already occured in it's entirety.
193
193
  */
194
- hasOccuredToday: boolean;
194
+ readonly hasOccuredToday: boolean;
195
195
  /**
196
- * Whether or not today's timing is currently in progress.
196
+ * Whether or not a timing is currently in progress.
197
+ *
198
+ * This can be true when isInProgressForDayIndex is false for cases where the timing starts at the previous day index and rolls on over into the next day.
199
+ */
200
+ readonly isInProgress: boolean;
201
+ /**
202
+ * Whether or not today's timing is currently in progress for the input dayIndex.
197
203
  */
198
- isInProgress: boolean;
204
+ readonly isInProgressForDayIndex: boolean;
199
205
  /**
200
206
  * Whether or not the block is within the configured range.
201
207
  */
202
- isInRange: boolean;
208
+ readonly isInRange: boolean;
203
209
  /**
204
210
  * Time the timing starts on the input day.
205
211
  */
206
- startsAtOnDay: Date;
212
+ readonly startsAtOnDay: Date;
207
213
  /**
208
214
  * Time the timing ends on the input day.
209
215
  */
210
- endsAtOnDay: Date;
216
+ readonly endsAtOnDay: Date;
211
217
  /**
212
218
  * "now" value used for considering current progress.
213
219
  */
214
- now: Date;
220
+ readonly now: Date;
215
221
  }
216
222
  /**
217
223
  * Generates DateCellDayTimingInfo about the input date relative to the input timing and range limit.
@@ -375,11 +375,11 @@ export interface DateCellScheduleDateCellTimingFilterConfig {
375
375
  */
376
376
  now?: Date;
377
377
  /**
378
- * (Optional) filters in blocks that have not yet started. Can be combined with the other filters.
378
+ * (Optional) filters in blocks that have started. Can be combined with the other filters.
379
379
  */
380
380
  onlyBlocksThatHaveStarted?: boolean;
381
381
  /**
382
- * (Optional) filters in blocks that have not yet ended. Can be combined with the other filters.
382
+ * (Optional) filters in blocks that have ended. Can be combined with the other filters.
383
383
  */
384
384
  onlyBlocksThatHaveEnded?: boolean;
385
385
  /**