@dereekb/date 10.1.4 → 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,
@@ -5934,11 +5946,11 @@ function dateCellTimingDateFactory(timing) {
5934
5946
  } = dateCellTimingStartPair(timing);
5935
5947
  const utcStartDate = normalInstance.baseDateToTargetDate(start);
5936
5948
  const startUtcHours = start.getUTCHours();
5937
- const factory = input => {
5949
+ const factory = (input, inputNow) => {
5938
5950
  if (util.isDate(input)) {
5939
5951
  return input;
5940
5952
  } else {
5941
- const now = new Date();
5953
+ const now = inputNow !== null && inputNow !== void 0 ? inputNow : new Date();
5942
5954
  const nowHours = now.getUTCHours();
5943
5955
  const utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
5944
5956
  // if the current hours are less than the UTC offset hours, then bump one extra day forward to be sure we're in the correct day.
@@ -7089,7 +7101,7 @@ function dateCellScheduleDateFilter(config) {
7089
7101
  const startsAtInSystem = normalInstance.systemDateToTargetDate(startsAt); // convert to the system date
7090
7102
  const firstDateDay = dateFns.getDay(startsAtInSystem);
7091
7103
  const dayForIndex = dateCellDayOfWeekFactory(firstDateDay);
7092
- const dateIndexForDate = dateCellTimingRelativeIndexFactory({
7104
+ const _dateCellTimingRelativeIndexFactory = dateCellTimingRelativeIndexFactory({
7093
7105
  startsAt,
7094
7106
  timezone
7095
7107
  });
@@ -7106,22 +7118,59 @@ function dateCellScheduleDateFilter(config) {
7106
7118
  end = expectedFinalStartsAt;
7107
7119
  }
7108
7120
  const indexFloor = setStartAsMinDate ? 0 : Number.MIN_SAFE_INTEGER;
7109
- const minAllowedIndex = (minMaxDateRange === null || minMaxDateRange === void 0 ? void 0 : minMaxDateRange.start) != null ? Math.max(indexFloor, dateIndexForDate(minMaxDateRange.start)) : indexFloor; // start date should be the min inde
7110
- const maxAllowedIndex = end != null ? dateIndexForDate(end) : (minMaxDateRange === null || minMaxDateRange === void 0 ? void 0 : minMaxDateRange.end) != null ? dateIndexForDate(minMaxDateRange.end) : Number.MAX_SAFE_INTEGER; // max "to" value
7121
+ const minAllowedIndex = (minMaxDateRange === null || minMaxDateRange === void 0 ? void 0 : minMaxDateRange.start) != null ? Math.max(indexFloor, _dateCellTimingRelativeIndexFactory(minMaxDateRange.start)) : indexFloor; // start date should be the min inde
7122
+ const maxAllowedIndex = end != null ? _dateCellTimingRelativeIndexFactory(end) : (minMaxDateRange === null || minMaxDateRange === void 0 ? void 0 : minMaxDateRange.end) != null ? _dateCellTimingRelativeIndexFactory(minMaxDateRange.end) : Number.MAX_SAFE_INTEGER; // max "to" value
7111
7123
  const includedIndexes = new Set(config.d);
7112
7124
  const excludedIndexes = new Set(config.ex);
7113
- return input => {
7125
+ const fn = input => {
7114
7126
  let i;
7115
7127
  let day;
7116
7128
  if (typeof input === 'number') {
7117
7129
  i = input;
7118
7130
  } else {
7119
- i = dateIndexForDate(input);
7131
+ i = _dateCellTimingRelativeIndexFactory(input);
7120
7132
  }
7121
7133
  day = dayForIndex(i);
7122
7134
  const result = i >= minAllowedIndex && i <= maxAllowedIndex && allowedDays.has(day) && !excludedIndexes.has(i) || includedIndexes.has(i);
7123
7135
  return result;
7124
7136
  };
7137
+ fn._dateCellTimingRelativeIndexFactory = _dateCellTimingRelativeIndexFactory;
7138
+ return fn;
7139
+ }
7140
+ /**
7141
+ * Passes a number of day values until it reaches an open day on a schedule. There's a maximum distance it searches in a direction before returning null.
7142
+ *
7143
+ * @param date
7144
+ * @param filter
7145
+ * @param maxDistance
7146
+ */
7147
+ function findNextDateInDateCellScheduleFilter(config) {
7148
+ const {
7149
+ date,
7150
+ filter,
7151
+ direction,
7152
+ maxDistance,
7153
+ excludeInputDate
7154
+ } = config;
7155
+ const {
7156
+ _dateCellTimingRelativeIndexFactory
7157
+ } = filter;
7158
+ const firstDateIndex = _dateCellTimingRelativeIndexFactory(date);
7159
+ const offsetDelta = direction === 'past' ? -1 : 1;
7160
+ let nextDatePair;
7161
+ for (let offset = excludeInputDate ? 1 : 0; offset < maxDistance; offset += 1) {
7162
+ const i = firstDateIndex + offset * offsetDelta;
7163
+ if (filter(i)) {
7164
+ const dateFactory = dateCellTimingDateFactory(_dateCellTimingRelativeIndexFactory._timing);
7165
+ nextDatePair = {
7166
+ i,
7167
+ date: dateFactory(i, isDate(date) ? date : undefined) // pass back the "now" time
7168
+ };
7169
+
7170
+ break;
7171
+ }
7172
+ }
7173
+ return nextDatePair;
7125
7174
  }
7126
7175
  /**
7127
7176
  * Creates a DateCellScheduleDateCellTimingFilter.
@@ -7653,7 +7702,7 @@ class DateTimeMinuteInstance {
7653
7702
  this._date = (dateOverride == undefined ? config.date : dateOverride) || new Date();
7654
7703
  this._step = (_a = config.step) !== null && _a !== void 0 ? _a : 1;
7655
7704
  this._limit = new LimitDateTimeInstance(config);
7656
- this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : () => true;
7705
+ this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
7657
7706
  }
7658
7707
  get date() {
7659
7708
  return this._date;
@@ -7721,7 +7770,7 @@ class DateTimeMinuteInstance {
7721
7770
  inPast = dateFns.isBefore(date, now);
7722
7771
  }
7723
7772
  // Schedule
7724
- isInSchedule = this._dateFilter(date);
7773
+ isInSchedule = this._dateFilter ? this._dateFilter(date) : true; // default
7725
7774
  return {
7726
7775
  isBeforeMaximum,
7727
7776
  isAfterMinimum,
@@ -7741,9 +7790,70 @@ class DateTimeMinuteInstance {
7741
7790
  }
7742
7791
  return date;
7743
7792
  }
7744
- clamp(date = this.date) {
7793
+ clamp(date = this.date, maxClampDistance) {
7794
+ return this.clampToSchedule(this.clampToLimit(date), maxClampDistance);
7795
+ }
7796
+ clampToLimit(date = this.date) {
7745
7797
  return this._limit.clamp(date);
7746
7798
  }
7799
+ clampToSchedule(date = this.date, maxClampDistance = 370) {
7800
+ let nextAvailableDate;
7801
+ if (this._dateFilter != null) {
7802
+ const maxLimitedDateRange = this._limit.dateRange();
7803
+ if (this._dateFilter(date)) {
7804
+ nextAvailableDate = date;
7805
+ } else {
7806
+ const maxPastDistance = Math.min(maxClampDistance, maxLimitedDateRange.start ? Math.abs(dateFns.differenceInDays(date, maxLimitedDateRange.start)) : maxClampDistance); // max future
7807
+ const maxFutureDistance = Math.min(maxClampDistance, maxLimitedDateRange.end ? Math.abs(dateFns.differenceInDays(date, maxLimitedDateRange.end)) : maxClampDistance); // max future
7808
+ const nextFutureDate = findNextDateInDateCellScheduleFilter({
7809
+ date,
7810
+ filter: this._dateFilter,
7811
+ direction: 'future',
7812
+ maxDistance: maxFutureDistance,
7813
+ excludeInputDate: true
7814
+ });
7815
+ if (nextFutureDate != null) {
7816
+ nextAvailableDate = nextFutureDate.date;
7817
+ } else {
7818
+ // check the past date clamp
7819
+ const previousPastDate = findNextDateInDateCellScheduleFilter({
7820
+ date,
7821
+ filter: this._dateFilter,
7822
+ direction: 'past',
7823
+ maxDistance: maxPastDistance,
7824
+ excludeInputDate: true
7825
+ });
7826
+ if (previousPastDate != null) {
7827
+ nextAvailableDate = previousPastDate.date;
7828
+ }
7829
+ }
7830
+ // set a default from the given input if applicable
7831
+ if (nextAvailableDate == null) {
7832
+ nextAvailableDate = this.clampToLimit(date);
7833
+ }
7834
+ }
7835
+ }
7836
+ return nextAvailableDate !== null && nextAvailableDate !== void 0 ? nextAvailableDate : date;
7837
+ }
7838
+ findNextAvailableDayInSchedule(date, direction, maxDistance = 370) {
7839
+ let nextAvailableDate;
7840
+ if (this._dateFilter) {
7841
+ const result = findNextDateInDateCellScheduleFilter({
7842
+ date,
7843
+ filter: this._dateFilter,
7844
+ direction,
7845
+ maxDistance: maxDistance,
7846
+ excludeInputDate: true
7847
+ });
7848
+ if (result != null) {
7849
+ nextAvailableDate = result.date;
7850
+ }
7851
+ }
7852
+ return nextAvailableDate;
7853
+ }
7854
+ isInSchedule(date) {
7855
+ return this._dateFilter ? this._dateFilter(date) : true;
7856
+ }
7747
7857
  _takeBoundedDate(date = this.date) {
7748
7858
  return this._takeMaximumBoundedDate(this._takeMinimumBoundedDate(date));
7749
7859
  }
@@ -9373,6 +9483,7 @@ exports.expandUniqueDateCellsFunction = expandUniqueDateCellsFunction;
9373
9483
  exports.filterDateCellsInDateCellRange = filterDateCellsInDateCellRange;
9374
9484
  exports.findMaxDate = findMaxDate;
9375
9485
  exports.findMinDate = findMinDate;
9486
+ exports.findNextDateInDateCellScheduleFilter = findNextDateInDateCellScheduleFilter;
9376
9487
  exports.fitDateRangeToDayPeriod = fitDateRangeToDayPeriod;
9377
9488
  exports.fitDateRangeToDayPeriodFunction = fitDateRangeToDayPeriodFunction;
9378
9489
  exports.fitUTCDateRangeToDayPeriod = fitUTCDateRangeToDayPeriod;
package/index.esm.js CHANGED
@@ -4533,6 +4533,10 @@ function isValidDateCellIndex(input) {
4533
4533
  * Input type that is either a Date or a DateCellIndex.
4534
4534
  */
4535
4535
 
4536
+ /**
4537
+ * A date and the relative date index.
4538
+ */
4539
+
4536
4540
  /**
4537
4541
  * A duration-span block.
4538
4542
  */
@@ -6406,9 +6410,22 @@ function dateCellDayTimingInfoFactory(config) {
6406
6410
  const endsAtOnDay = addMinutes(startsAtOnDay, duration);
6407
6411
  const potentiallyInProgress = !isAfter$1(startsAtOnDay, now); // is potentially in progress if the now is equal-to or after the start time.
6408
6412
 
6409
- const isInProgress = potentiallyInProgress && !isAfter$1(now, endsAtOnDay);
6410
- const hasOccuredToday = potentiallyInProgress && !isInProgress;
6411
- 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
+ }
6412
6429
  const nextIndex = currentIndex + 1;
6413
6430
  const nextIndexInRange = checkIsInRange(nextIndex) ? nextIndex : undefined;
6414
6431
  const isComplete = currentIndex >= 0 && !nextIndexInRange && (!isInRange || hasOccuredToday);
@@ -6420,6 +6437,7 @@ function dateCellDayTimingInfoFactory(config) {
6420
6437
  nextIndex,
6421
6438
  hasOccuredToday,
6422
6439
  isInProgress,
6440
+ isInProgressForDayIndex,
6423
6441
  isInRange,
6424
6442
  startsAtOnDay,
6425
6443
  endsAtOnDay,
@@ -6561,11 +6579,11 @@ function dateCellTimingDateFactory(timing) {
6561
6579
  } = dateCellTimingStartPair(timing);
6562
6580
  const utcStartDate = normalInstance.baseDateToTargetDate(start);
6563
6581
  const startUtcHours = start.getUTCHours();
6564
- const factory = input => {
6582
+ const factory = (input, inputNow) => {
6565
6583
  if (isDate$2(input)) {
6566
6584
  return input;
6567
6585
  } else {
6568
- const now = new Date();
6586
+ const now = inputNow != null ? inputNow : new Date();
6569
6587
  const nowHours = now.getUTCHours();
6570
6588
  const utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
6571
6589
 
@@ -7947,7 +7965,7 @@ function dateCellScheduleDateFilter(config) {
7947
7965
  const startsAtInSystem = normalInstance.systemDateToTargetDate(startsAt); // convert to the system date
7948
7966
  const firstDateDay = getDay(startsAtInSystem);
7949
7967
  const dayForIndex = dateCellDayOfWeekFactory(firstDateDay);
7950
- const dateIndexForDate = dateCellTimingRelativeIndexFactory({
7968
+ const _dateCellTimingRelativeIndexFactory = dateCellTimingRelativeIndexFactory({
7951
7969
  startsAt,
7952
7970
  timezone
7953
7971
  });
@@ -7964,23 +7982,60 @@ function dateCellScheduleDateFilter(config) {
7964
7982
  end = expectedFinalStartsAt;
7965
7983
  }
7966
7984
  const indexFloor = setStartAsMinDate ? 0 : Number.MIN_SAFE_INTEGER;
7967
- const minAllowedIndex = (minMaxDateRange == null ? void 0 : minMaxDateRange.start) != null ? Math.max(indexFloor, dateIndexForDate(minMaxDateRange.start)) : indexFloor; // start date should be the min inde
7968
- const maxAllowedIndex = end != null ? dateIndexForDate(end) : (minMaxDateRange == null ? void 0 : minMaxDateRange.end) != null ? dateIndexForDate(minMaxDateRange.end) : Number.MAX_SAFE_INTEGER; // max "to" value
7985
+ const minAllowedIndex = (minMaxDateRange == null ? void 0 : minMaxDateRange.start) != null ? Math.max(indexFloor, _dateCellTimingRelativeIndexFactory(minMaxDateRange.start)) : indexFloor; // start date should be the min inde
7986
+ const maxAllowedIndex = end != null ? _dateCellTimingRelativeIndexFactory(end) : (minMaxDateRange == null ? void 0 : minMaxDateRange.end) != null ? _dateCellTimingRelativeIndexFactory(minMaxDateRange.end) : Number.MAX_SAFE_INTEGER; // max "to" value
7969
7987
 
7970
7988
  const includedIndexes = new Set(config.d);
7971
7989
  const excludedIndexes = new Set(config.ex);
7972
- return input => {
7990
+ const fn = input => {
7973
7991
  let i;
7974
7992
  let day;
7975
7993
  if (typeof input === 'number') {
7976
7994
  i = input;
7977
7995
  } else {
7978
- i = dateIndexForDate(input);
7996
+ i = _dateCellTimingRelativeIndexFactory(input);
7979
7997
  }
7980
7998
  day = dayForIndex(i);
7981
7999
  const result = i >= minAllowedIndex && i <= maxAllowedIndex && allowedDays.has(day) && !excludedIndexes.has(i) || includedIndexes.has(i);
7982
8000
  return result;
7983
8001
  };
8002
+ fn._dateCellTimingRelativeIndexFactory = _dateCellTimingRelativeIndexFactory;
8003
+ return fn;
8004
+ }
8005
+ /**
8006
+ * Passes a number of day values until it reaches an open day on a schedule. There's a maximum distance it searches in a direction before returning null.
8007
+ *
8008
+ * @param date
8009
+ * @param filter
8010
+ * @param maxDistance
8011
+ */
8012
+ function findNextDateInDateCellScheduleFilter(config) {
8013
+ const {
8014
+ date,
8015
+ filter,
8016
+ direction,
8017
+ maxDistance,
8018
+ excludeInputDate
8019
+ } = config;
8020
+ const {
8021
+ _dateCellTimingRelativeIndexFactory
8022
+ } = filter;
8023
+ const firstDateIndex = _dateCellTimingRelativeIndexFactory(date);
8024
+ const offsetDelta = direction === 'past' ? -1 : 1;
8025
+ let nextDatePair;
8026
+ for (let offset = excludeInputDate ? 1 : 0; offset < maxDistance; offset += 1) {
8027
+ const i = firstDateIndex + offset * offsetDelta;
8028
+ if (filter(i)) {
8029
+ const dateFactory = dateCellTimingDateFactory(_dateCellTimingRelativeIndexFactory._timing);
8030
+ nextDatePair = {
8031
+ i,
8032
+ date: dateFactory(i, isDate(date) ? date : undefined) // pass back the "now" time
8033
+ };
8034
+
8035
+ break;
8036
+ }
8037
+ }
8038
+ return nextDatePair;
7984
8039
  }
7985
8040
 
7986
8041
  // MARK: DateCellScheduleDateCellTimingFilter
@@ -8567,7 +8622,7 @@ class DateTimeMinuteInstance {
8567
8622
  this._date = (dateOverride == undefined ? config.date : dateOverride) || new Date();
8568
8623
  this._step = (_config$step = config.step) != null ? _config$step : 1;
8569
8624
  this._limit = new LimitDateTimeInstance(config);
8570
- this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : () => true;
8625
+ this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
8571
8626
  }
8572
8627
  get date() {
8573
8628
  return this._date;
@@ -8640,7 +8695,8 @@ class DateTimeMinuteInstance {
8640
8695
  }
8641
8696
 
8642
8697
  // Schedule
8643
- isInSchedule = this._dateFilter(date);
8698
+ isInSchedule = this._dateFilter ? this._dateFilter(date) : true; // default
8699
+
8644
8700
  return {
8645
8701
  isBeforeMaximum,
8646
8702
  isAfterMinimum,
@@ -8660,9 +8716,73 @@ class DateTimeMinuteInstance {
8660
8716
  }
8661
8717
  return date;
8662
8718
  }
8663
- clamp(date = this.date) {
8719
+ clamp(date = this.date, maxClampDistance) {
8720
+ return this.clampToSchedule(this.clampToLimit(date), maxClampDistance);
8721
+ }
8722
+ clampToLimit(date = this.date) {
8664
8723
  return this._limit.clamp(date);
8665
8724
  }
8725
+ clampToSchedule(date = this.date, maxClampDistance = 370) {
8726
+ var _nextAvailableDate;
8727
+ let nextAvailableDate;
8728
+ if (this._dateFilter != null) {
8729
+ const maxLimitedDateRange = this._limit.dateRange();
8730
+ if (this._dateFilter(date)) {
8731
+ nextAvailableDate = date;
8732
+ } else {
8733
+ const maxPastDistance = Math.min(maxClampDistance, maxLimitedDateRange.start ? Math.abs(differenceInDays(date, maxLimitedDateRange.start)) : maxClampDistance); // max future
8734
+ const maxFutureDistance = Math.min(maxClampDistance, maxLimitedDateRange.end ? Math.abs(differenceInDays(date, maxLimitedDateRange.end)) : maxClampDistance); // max future
8735
+
8736
+ const nextFutureDate = findNextDateInDateCellScheduleFilter({
8737
+ date,
8738
+ filter: this._dateFilter,
8739
+ direction: 'future',
8740
+ maxDistance: maxFutureDistance,
8741
+ excludeInputDate: true
8742
+ });
8743
+ if (nextFutureDate != null) {
8744
+ nextAvailableDate = nextFutureDate.date;
8745
+ } else {
8746
+ // check the past date clamp
8747
+ const previousPastDate = findNextDateInDateCellScheduleFilter({
8748
+ date,
8749
+ filter: this._dateFilter,
8750
+ direction: 'past',
8751
+ maxDistance: maxPastDistance,
8752
+ excludeInputDate: true
8753
+ });
8754
+ if (previousPastDate != null) {
8755
+ nextAvailableDate = previousPastDate.date;
8756
+ }
8757
+ }
8758
+
8759
+ // set a default from the given input if applicable
8760
+ if (nextAvailableDate == null) {
8761
+ nextAvailableDate = this.clampToLimit(date);
8762
+ }
8763
+ }
8764
+ }
8765
+ return (_nextAvailableDate = nextAvailableDate) != null ? _nextAvailableDate : date;
8766
+ }
8767
+ findNextAvailableDayInSchedule(date, direction, maxDistance = 370) {
8768
+ let nextAvailableDate;
8769
+ if (this._dateFilter) {
8770
+ const result = findNextDateInDateCellScheduleFilter({
8771
+ date,
8772
+ filter: this._dateFilter,
8773
+ direction,
8774
+ maxDistance: maxDistance,
8775
+ excludeInputDate: true
8776
+ });
8777
+ if (result != null) {
8778
+ nextAvailableDate = result.date;
8779
+ }
8780
+ }
8781
+ return nextAvailableDate;
8782
+ }
8783
+ isInSchedule(date) {
8784
+ return this._dateFilter ? this._dateFilter(date) : true;
8785
+ }
8666
8786
  _takeBoundedDate(date = this.date) {
8667
8787
  return this._takeMaximumBoundedDate(this._takeMinimumBoundedDate(date));
8668
8788
  }
@@ -10308,4 +10428,4 @@ class ModelRecurrenceInfoUtility {
10308
10428
  }
10309
10429
  }
10310
10430
 
10311
- export { AnyIterResult, CalendarDate, CalendarDateType, DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX, DATE_TODAY_END_VALUE, DATE_TODAY_START_VALUE, DATE_WEEK_END_VALUE, DATE_WEEK_START_VALUE, DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE, DEFAULT_FULL_DATE_SCHEDULE_RANGE_DURATION, DEFAULT_ITERATE_DAYS_IN_DATE_RANGE_MAX_ITERATIONS, DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED, DateCell, DateCellRange, DateCellSchedule, DateCellScheduleDayCode, DateCellTiming, DateDurationSpan, DateRRule, DateRRuleInstance, DateRRuleParseUtility, DateRRuleUtility, DateRange, DateRangeParams, DateRangeType, DateSet, DateTimeMinuteInstance, DateTimeUtilityInstance, DateTimezoneUtcNormalInstance, IsKnownTimezone, IsValidDateCellRange, IsValidDateCellRangeSeries, IsValidDateCellTiming, IterateDaysInDateRangeFunctionBailError, LastIterResult, LimitDateTimeInstance, MAX_FUTURE_DATE, ModelRecurrenceInfo, ModelRecurrenceInfoUtility, NextIterResult, RRuleStringSplitter, SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE, UNKNOWN_YEAR_WEEK_CODE, UTC_DATE_TIMEZONE_UTC_NORMAL_INSTANCE, allIndexesInDateCellRange, allIndexesInDateCellRanges, allKnownTimezoneStrings, allTimezoneInfos, allTimezoneStrings, anyHaveExpired, atleastOneNotExpired, baseDateToTargetDate, calculateAllConversions, calculateExpectedDateCellTimingDuration, calculateExpectedDateCellTimingDurationPair, calculateTimezoneOffset, calendarDate, calendarDateFactory, calendarDateForDateDurationSpan, changeDateCellScheduleDateRangeToTimezone, changeDateCellScheduleDateRangeToTimezoneFunction, clampDateFunction, clampDateRangeFunction, clampDateRangeToDateRange, clampDateToDateRange, copyDateCellScheduleDateFilterConfig, copyHoursAndMinutesFromDate, copyHoursAndMinutesFromDateToToday, copyHoursAndMinutesFromDateWithTimezoneNormal, copyHoursAndMinutesFromNow, copyHoursAndMinutesFromNowWithTimezoneNormal, copyHoursAndMinutesFromUTCDate, copyHoursAndMinutesToDate, copyHoursAndMinutesToToday, dateCell, dateCellDayOfWeekFactory, dateCellDayTimingInfoFactory, dateCellDurationSpanHasEndedFilterFunction, dateCellDurationSpanHasNotEndedFilterFunction, dateCellDurationSpanHasNotStartedFilterFunction, dateCellDurationSpanHasStartedFilterFunction, dateCellEndIndex, dateCellIndexRange, dateCellIndexRangeToDateCellRange, dateCellIndexYearWeekCodeFactory, dateCellIndexYearWeekCodeGroupFactory, dateCellIndexsForDateCellScheduleDayCodes, dateCellRange, dateCellRangeBlocksCount, dateCellRangeBlocksCountInfo, dateCellRangeHasRange, dateCellRangeIncludedByRangeFunction, dateCellRangeOfTiming, dateCellRangeOfTimingFactory, dateCellRangeOverlapsRange, dateCellRangeOverlapsRangeFunction, dateCellRangeToDateCellIndexRange, dateCellRangeWithRange, dateCellRangeWithRangeFromIndex, dateCellRangesFullyCoverDateCellRangeFunction, dateCellScheduleDateCellTimingFilter, dateCellScheduleDateFilter, dateCellScheduleDateRange, dateCellScheduleDayCodeFactory, dateCellScheduleDayCodesAreSetsEquivalent, dateCellScheduleDayCodesFromEnabledDays, dateCellScheduleDayCodesSetFromDaysOfWeek, dateCellScheduleEncodedWeek, dateCellTiming, dateCellTimingCompletedTimeRange, dateCellTimingDateFactory, dateCellTimingDateRange, dateCellTimingEndDateFactory, dateCellTimingEndIndex, dateCellTimingEventRange, dateCellTimingExpansionFactory, dateCellTimingFinalStartsAtEvent, dateCellTimingFromDateCellTimingStartsAtEndRange, dateCellTimingLatestCompletedIndex, dateCellTimingRelativeIndexArrayFactory, dateCellTimingRelativeIndexFactory, dateCellTimingStart, dateCellTimingStartDateFactory, dateCellTimingStartPair, dateCellTimingStartsAtDateFactory, dateCellTimingStartsAtForStartOfDay, dateCellTimingTimezoneNormalInstance, dateDurationSpanEndDate, dateFromDateOrTimeNumber, dateFromLogicalDate, dateInterval, dateMonthDayStringFormat, dateOrDateRangeToDateRange, dateOrDayStringRangeToDateRange, dateOrDayStringRangeToISO8601DayStringRange, dateRange, dateRangeDaysCount, dateRangeOverlapsDateRange, dateRangeOverlapsDateRangeFunction, dateRangeRelativeState, dateRelativeStateForDateCellRangeComparedToIndex, dateShortDateAndTimeStringFormat, dateShortDateStringFormat, dateTimeInstance, dateTimeInstanceUtc, dateTimeMinuteDecisionFunction, dateTimeMinuteWholeDayDecisionFunction, dateTimeStringFormat, dateTimezoneUtcNormal, daysToMinutes, durationSpanDateRelativeState, durationSpanToDateRange, earliestDate, enabledDaysFromDateCellScheduleDayCodes, endItreateDaysInDateRangeEarly, expandDateCellCollection, expandDateCellRange, expandDateCellSchedule, expandDateCellScheduleDayCodes, expandDateCellScheduleDayCodesToDayCodesSet, expandDateCellScheduleDayCodesToDayOfWeekSet, expandDateCellScheduleFactory, expandDateCellScheduleRange, expandDateCellScheduleRangeToDateCellRanges, expandDateCellTiming, expandDaysForDateRange, expandDaysForDateRangeFunction, expandUniqueDateCellsFunction, filterDateCellsInDateCellRange, findMaxDate, findMinDate, fitDateRangeToDayPeriod, fitDateRangeToDayPeriodFunction, fitUTCDateRangeToDayPeriod, forEachDayInDateRange, formatDateDistance, formatDateRange, formatDateRangeDistance, formatDateRangeDistanceFunction, formatDateRangeFunction, formatStartedEndedDistanceString, formatToDateString, formatToDayRangeString, formatToDayTimeRangeString, formatToISO8601DateString, formatToISO8601DayString, formatToISO8601DayStringForSystem, formatToISO8601DayStringForUTC, formatToMonthDayString, formatToShortDateAndTimeString, formatToShortDateString, formatToTimeAndDurationString, formatToTimeRangeString, formatToTimeString, fractionalHoursInDurationSpan, fullDateCellScheduleRange, fullDateCellTiming, fullDateCellTimingTimezonePair, fullWeekDateCellScheduleDayCodes, getCurrentSystemOffsetInHours, getCurrentSystemOffsetInMinutes, getCurrentSystemOffsetInMs, getDateCellTimingFirstEventDateRange, getDateCellTimingHoursInEvent, getDaysOfWeekInDateRange, getExpiration, getGreatestDateCellIndexInDateCellRanges, getLeastAndGreatestDateCellIndexInDateCellRanges, getLeastDateCellIndexInDateCellRanges, getNextDateCellTimingIndex, getRelativeDateForDateCellTiming, getRelativeIndexForDateCellTiming, getTimeAM, getTimezoneAbbreviation, getTimezoneLongName, groupDateRangesByDateRelativeState, groupToDateCellRanges, groupUniqueDateCells, guessCurrentTimezone, hasExpired, hoursToMs, inverseDateTimezoneUtcNormalInstanceTransformType, isAfter, isDate, isDateCellRange, isDateCellSchedule, isDateCellScheduleDateRange, isDateCellScheduleEncodedWeek, isDateCellScheduleStartOfDayDateRange, isDateCellTiming, isDateCellTimingRelativeIndexFactory, isDateCellWithinDateCellRange, isDateCellWithinDateCellRangeFunction, isDateInDateRange, isDateInDateRangeFunction, isDateRange, isDateRangeInDateRange, isDateRangeInDateRangeFunction, isDateRangeStart, isDateWithinDateCellRangeFunction, isEmptyDateCellScheduleEncodedWeek, isFullDateCellScheduleDateRange, isFullDateCellTiming, isFullDateRange, isInfiniteDateRange, isKnownTimezone, isLogicalDateStringCode, isMaxFutureDate, isPartialDateRange, isSameDate, isSameDateCellSchedule, isSameDateCellScheduleDateRange, isSameDateCellScheduleEventRange, isSameDateCellTiming, isSameDateCellTimingEventStartsAtEndRange, isSameDateDay, isSameDateDayRange, isSameDateHoursAndMinutes, isSameDateRange, isSameDateTimezoneConversionConfig, isSameDurationSpan, isSameFullDateCellScheduleDateRange, isSameFullDateCellTiming, isStartOfDayForSystem, isStartOfDayInUTC, isValidDateCellIndex, isValidDateCellRange, isValidDateCellRangeSeries, isValidDateCellTiming, isValidDateCellTimingInfo, isValidDateCellTimingStartDate, isValidDateFromTimestringResult, isValidDateTimezoneConversionConfig, isValidFullDateCellTiming, isValidFullDateCellTimingInfo, iterateDaysInDateRange, iterateDaysInDateRangeFunction, latestDate, latestMinute, limitDateTime, limitDateTimeInstance, logicalDateStringCodeDateFactory, makeDateQueryForDateItemRangeFilter, makeDateQueryForDateStartsEndsFilter, makeDateQueryForOccuringFilter, makeDaysAndTimeFiltersFunction, makeMongoDBLikeDateQueryBuilder, maxFutureDate, mergeMongoDBLikeRangeFilters, minutesToMs, modifyDateCellToFitRange, modifyDateCellsToFitRange, modifyDateCellsToFitRangeFunction, msToMinutes, msToSeconds, nowInterval, parseISO8601DayStringToDate, parseJsDateString, parseReadableTimeString, rawDateCellScheduleDayCodes, readDaysOfWeek, readDaysOfWeekNames, readableTimeStringToDate, reduceDatesFunction, requireCurrentTimezone, roundDateTimeDown, roundDateTimeDownToSteps, roundDownToHour, roundDownToMinute, roundToMinuteSteps, safeFormatToISO8601DateString, safeToJsDate, searchTimezoneInfos, shiftDateCellTimingToSystemTimezone, shiftDateCellTimingToTimezone, shiftDateCellTimingToTimezoneFunction, shiftDateCellTimingToUTCTimezone, simplifyDateCellScheduleDayCodes, skipAfterExpiration, skipExpired, skipUntilExpiration, skipUntilTimeElapsedAfterLastEmission, sortByDateFunction, sortByISO8601DateStringFunction, sortByISO8601DateStrings, sortDateCellRangeAndSizeFunction, sortDateCellRanges, sortDateRangeStartAscendingCompareFunction, startOfDayInTimezoneDayStringFactory, startOfDayInTimezoneFromISO8601DayString, startOfWeekForYearWeekCode, systemBaseDateToNormalDate, systemBaseDateToNormalDateOffset, systemDateTimezoneUtcNormal, systemExperiencesDaylightSavings, systemNormalDateToBaseDate, systemNormalDateToBaseDateOffset, takeAfterTimeElapsedSinceLastEmission, takeNextUpcomingTime, targetDateToBaseDate, timeHasExpired, timezoneInfoForSystem, timezoneStringToSearchableString, timezoneStringToTimezoneInfo, toExpiration, toExpires, toISO8601DayString, toISO8601DayStringForSystem, toISO8601DayStringForUTC, toISODateString, toJsDate, toJsDayDate, toLocalReadableTimeString, toReadableTimeString, transformDateInTimezoneNormalFunction, transformDateRangeDatesFunction, transformDateRangeInTimezoneNormalFunction, transformDateRangeToTimezoneFunction, transformDateRangeWithStartOfDay, unixTimeNumberForNow, unixTimeNumberFromDate, unixTimeNumberFromDateOrTimeNumber, unixTimeNumberToDate, updateDateCellTimingToSystemTimezone, updateDateCellTimingToTimezone, updateDateCellTimingToTimezoneFunction, updateDateCellTimingToUTCTimezone, updateDateCellTimingWithDateCellTimingEvent, utcDayForDate, weekdayDateCellScheduleDayCodes, weekendDateCellScheduleDayCodes, yearWeekCode, yearWeekCodeDateFactory, yearWeekCodeDateTimezoneInstance, yearWeekCodeFactory, yearWeekCodeForCalendarMonth, yearWeekCodeForCalendarMonthFactory, yearWeekCodeForDateRange, yearWeekCodeForDateRangeFactory, yearWeekCodeForDateRangeInTimezone, yearWeekCodeFromDate, yearWeekCodeFromPair, yearWeekCodeGroupFactory, yearWeekCodeIndex, yearWeekCodePair, yearWeekCodePairFromDate };
10431
+ export { AnyIterResult, CalendarDate, CalendarDateType, DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX, DATE_TODAY_END_VALUE, DATE_TODAY_START_VALUE, DATE_WEEK_END_VALUE, DATE_WEEK_START_VALUE, DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE, DEFAULT_FULL_DATE_SCHEDULE_RANGE_DURATION, DEFAULT_ITERATE_DAYS_IN_DATE_RANGE_MAX_ITERATIONS, DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED, DateCell, DateCellRange, DateCellSchedule, DateCellScheduleDayCode, DateCellTiming, DateDurationSpan, DateRRule, DateRRuleInstance, DateRRuleParseUtility, DateRRuleUtility, DateRange, DateRangeParams, DateRangeType, DateSet, DateTimeMinuteInstance, DateTimeUtilityInstance, DateTimezoneUtcNormalInstance, IsKnownTimezone, IsValidDateCellRange, IsValidDateCellRangeSeries, IsValidDateCellTiming, IterateDaysInDateRangeFunctionBailError, LastIterResult, LimitDateTimeInstance, MAX_FUTURE_DATE, ModelRecurrenceInfo, ModelRecurrenceInfoUtility, NextIterResult, RRuleStringSplitter, SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE, UNKNOWN_YEAR_WEEK_CODE, UTC_DATE_TIMEZONE_UTC_NORMAL_INSTANCE, allIndexesInDateCellRange, allIndexesInDateCellRanges, allKnownTimezoneStrings, allTimezoneInfos, allTimezoneStrings, anyHaveExpired, atleastOneNotExpired, baseDateToTargetDate, calculateAllConversions, calculateExpectedDateCellTimingDuration, calculateExpectedDateCellTimingDurationPair, calculateTimezoneOffset, calendarDate, calendarDateFactory, calendarDateForDateDurationSpan, changeDateCellScheduleDateRangeToTimezone, changeDateCellScheduleDateRangeToTimezoneFunction, clampDateFunction, clampDateRangeFunction, clampDateRangeToDateRange, clampDateToDateRange, copyDateCellScheduleDateFilterConfig, copyHoursAndMinutesFromDate, copyHoursAndMinutesFromDateToToday, copyHoursAndMinutesFromDateWithTimezoneNormal, copyHoursAndMinutesFromNow, copyHoursAndMinutesFromNowWithTimezoneNormal, copyHoursAndMinutesFromUTCDate, copyHoursAndMinutesToDate, copyHoursAndMinutesToToday, dateCell, dateCellDayOfWeekFactory, dateCellDayTimingInfoFactory, dateCellDurationSpanHasEndedFilterFunction, dateCellDurationSpanHasNotEndedFilterFunction, dateCellDurationSpanHasNotStartedFilterFunction, dateCellDurationSpanHasStartedFilterFunction, dateCellEndIndex, dateCellIndexRange, dateCellIndexRangeToDateCellRange, dateCellIndexYearWeekCodeFactory, dateCellIndexYearWeekCodeGroupFactory, dateCellIndexsForDateCellScheduleDayCodes, dateCellRange, dateCellRangeBlocksCount, dateCellRangeBlocksCountInfo, dateCellRangeHasRange, dateCellRangeIncludedByRangeFunction, dateCellRangeOfTiming, dateCellRangeOfTimingFactory, dateCellRangeOverlapsRange, dateCellRangeOverlapsRangeFunction, dateCellRangeToDateCellIndexRange, dateCellRangeWithRange, dateCellRangeWithRangeFromIndex, dateCellRangesFullyCoverDateCellRangeFunction, dateCellScheduleDateCellTimingFilter, dateCellScheduleDateFilter, dateCellScheduleDateRange, dateCellScheduleDayCodeFactory, dateCellScheduleDayCodesAreSetsEquivalent, dateCellScheduleDayCodesFromEnabledDays, dateCellScheduleDayCodesSetFromDaysOfWeek, dateCellScheduleEncodedWeek, dateCellTiming, dateCellTimingCompletedTimeRange, dateCellTimingDateFactory, dateCellTimingDateRange, dateCellTimingEndDateFactory, dateCellTimingEndIndex, dateCellTimingEventRange, dateCellTimingExpansionFactory, dateCellTimingFinalStartsAtEvent, dateCellTimingFromDateCellTimingStartsAtEndRange, dateCellTimingLatestCompletedIndex, dateCellTimingRelativeIndexArrayFactory, dateCellTimingRelativeIndexFactory, dateCellTimingStart, dateCellTimingStartDateFactory, dateCellTimingStartPair, dateCellTimingStartsAtDateFactory, dateCellTimingStartsAtForStartOfDay, dateCellTimingTimezoneNormalInstance, dateDurationSpanEndDate, dateFromDateOrTimeNumber, dateFromLogicalDate, dateInterval, dateMonthDayStringFormat, dateOrDateRangeToDateRange, dateOrDayStringRangeToDateRange, dateOrDayStringRangeToISO8601DayStringRange, dateRange, dateRangeDaysCount, dateRangeOverlapsDateRange, dateRangeOverlapsDateRangeFunction, dateRangeRelativeState, dateRelativeStateForDateCellRangeComparedToIndex, dateShortDateAndTimeStringFormat, dateShortDateStringFormat, dateTimeInstance, dateTimeInstanceUtc, dateTimeMinuteDecisionFunction, dateTimeMinuteWholeDayDecisionFunction, dateTimeStringFormat, dateTimezoneUtcNormal, daysToMinutes, durationSpanDateRelativeState, durationSpanToDateRange, earliestDate, enabledDaysFromDateCellScheduleDayCodes, endItreateDaysInDateRangeEarly, expandDateCellCollection, expandDateCellRange, expandDateCellSchedule, expandDateCellScheduleDayCodes, expandDateCellScheduleDayCodesToDayCodesSet, expandDateCellScheduleDayCodesToDayOfWeekSet, expandDateCellScheduleFactory, expandDateCellScheduleRange, expandDateCellScheduleRangeToDateCellRanges, expandDateCellTiming, expandDaysForDateRange, expandDaysForDateRangeFunction, expandUniqueDateCellsFunction, filterDateCellsInDateCellRange, findMaxDate, findMinDate, findNextDateInDateCellScheduleFilter, fitDateRangeToDayPeriod, fitDateRangeToDayPeriodFunction, fitUTCDateRangeToDayPeriod, forEachDayInDateRange, formatDateDistance, formatDateRange, formatDateRangeDistance, formatDateRangeDistanceFunction, formatDateRangeFunction, formatStartedEndedDistanceString, formatToDateString, formatToDayRangeString, formatToDayTimeRangeString, formatToISO8601DateString, formatToISO8601DayString, formatToISO8601DayStringForSystem, formatToISO8601DayStringForUTC, formatToMonthDayString, formatToShortDateAndTimeString, formatToShortDateString, formatToTimeAndDurationString, formatToTimeRangeString, formatToTimeString, fractionalHoursInDurationSpan, fullDateCellScheduleRange, fullDateCellTiming, fullDateCellTimingTimezonePair, fullWeekDateCellScheduleDayCodes, getCurrentSystemOffsetInHours, getCurrentSystemOffsetInMinutes, getCurrentSystemOffsetInMs, getDateCellTimingFirstEventDateRange, getDateCellTimingHoursInEvent, getDaysOfWeekInDateRange, getExpiration, getGreatestDateCellIndexInDateCellRanges, getLeastAndGreatestDateCellIndexInDateCellRanges, getLeastDateCellIndexInDateCellRanges, getNextDateCellTimingIndex, getRelativeDateForDateCellTiming, getRelativeIndexForDateCellTiming, getTimeAM, getTimezoneAbbreviation, getTimezoneLongName, groupDateRangesByDateRelativeState, groupToDateCellRanges, groupUniqueDateCells, guessCurrentTimezone, hasExpired, hoursToMs, inverseDateTimezoneUtcNormalInstanceTransformType, isAfter, isDate, isDateCellRange, isDateCellSchedule, isDateCellScheduleDateRange, isDateCellScheduleEncodedWeek, isDateCellScheduleStartOfDayDateRange, isDateCellTiming, isDateCellTimingRelativeIndexFactory, isDateCellWithinDateCellRange, isDateCellWithinDateCellRangeFunction, isDateInDateRange, isDateInDateRangeFunction, isDateRange, isDateRangeInDateRange, isDateRangeInDateRangeFunction, isDateRangeStart, isDateWithinDateCellRangeFunction, isEmptyDateCellScheduleEncodedWeek, isFullDateCellScheduleDateRange, isFullDateCellTiming, isFullDateRange, isInfiniteDateRange, isKnownTimezone, isLogicalDateStringCode, isMaxFutureDate, isPartialDateRange, isSameDate, isSameDateCellSchedule, isSameDateCellScheduleDateRange, isSameDateCellScheduleEventRange, isSameDateCellTiming, isSameDateCellTimingEventStartsAtEndRange, isSameDateDay, isSameDateDayRange, isSameDateHoursAndMinutes, isSameDateRange, isSameDateTimezoneConversionConfig, isSameDurationSpan, isSameFullDateCellScheduleDateRange, isSameFullDateCellTiming, isStartOfDayForSystem, isStartOfDayInUTC, isValidDateCellIndex, isValidDateCellRange, isValidDateCellRangeSeries, isValidDateCellTiming, isValidDateCellTimingInfo, isValidDateCellTimingStartDate, isValidDateFromTimestringResult, isValidDateTimezoneConversionConfig, isValidFullDateCellTiming, isValidFullDateCellTimingInfo, iterateDaysInDateRange, iterateDaysInDateRangeFunction, latestDate, latestMinute, limitDateTime, limitDateTimeInstance, logicalDateStringCodeDateFactory, makeDateQueryForDateItemRangeFilter, makeDateQueryForDateStartsEndsFilter, makeDateQueryForOccuringFilter, makeDaysAndTimeFiltersFunction, makeMongoDBLikeDateQueryBuilder, maxFutureDate, mergeMongoDBLikeRangeFilters, minutesToMs, modifyDateCellToFitRange, modifyDateCellsToFitRange, modifyDateCellsToFitRangeFunction, msToMinutes, msToSeconds, nowInterval, parseISO8601DayStringToDate, parseJsDateString, parseReadableTimeString, rawDateCellScheduleDayCodes, readDaysOfWeek, readDaysOfWeekNames, readableTimeStringToDate, reduceDatesFunction, requireCurrentTimezone, roundDateTimeDown, roundDateTimeDownToSteps, roundDownToHour, roundDownToMinute, roundToMinuteSteps, safeFormatToISO8601DateString, safeToJsDate, searchTimezoneInfos, shiftDateCellTimingToSystemTimezone, shiftDateCellTimingToTimezone, shiftDateCellTimingToTimezoneFunction, shiftDateCellTimingToUTCTimezone, simplifyDateCellScheduleDayCodes, skipAfterExpiration, skipExpired, skipUntilExpiration, skipUntilTimeElapsedAfterLastEmission, sortByDateFunction, sortByISO8601DateStringFunction, sortByISO8601DateStrings, sortDateCellRangeAndSizeFunction, sortDateCellRanges, sortDateRangeStartAscendingCompareFunction, startOfDayInTimezoneDayStringFactory, startOfDayInTimezoneFromISO8601DayString, startOfWeekForYearWeekCode, systemBaseDateToNormalDate, systemBaseDateToNormalDateOffset, systemDateTimezoneUtcNormal, systemExperiencesDaylightSavings, systemNormalDateToBaseDate, systemNormalDateToBaseDateOffset, takeAfterTimeElapsedSinceLastEmission, takeNextUpcomingTime, targetDateToBaseDate, timeHasExpired, timezoneInfoForSystem, timezoneStringToSearchableString, timezoneStringToTimezoneInfo, toExpiration, toExpires, toISO8601DayString, toISO8601DayStringForSystem, toISO8601DayStringForUTC, toISODateString, toJsDate, toJsDayDate, toLocalReadableTimeString, toReadableTimeString, transformDateInTimezoneNormalFunction, transformDateRangeDatesFunction, transformDateRangeInTimezoneNormalFunction, transformDateRangeToTimezoneFunction, transformDateRangeWithStartOfDay, unixTimeNumberForNow, unixTimeNumberFromDate, unixTimeNumberFromDateOrTimeNumber, unixTimeNumberToDate, updateDateCellTimingToSystemTimezone, updateDateCellTimingToTimezone, updateDateCellTimingToTimezoneFunction, updateDateCellTimingToUTCTimezone, updateDateCellTimingWithDateCellTimingEvent, utcDayForDate, weekdayDateCellScheduleDayCodes, weekendDateCellScheduleDayCodes, yearWeekCode, yearWeekCodeDateFactory, yearWeekCodeDateTimezoneInstance, yearWeekCodeFactory, yearWeekCodeForCalendarMonth, yearWeekCodeForCalendarMonthFactory, yearWeekCodeForDateRange, yearWeekCodeForDateRangeFactory, yearWeekCodeForDateRangeInTimezone, yearWeekCodeFromDate, yearWeekCodeFromPair, yearWeekCodeGroupFactory, yearWeekCodeIndex, yearWeekCodePair, yearWeekCodePairFromDate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/date",
3
- "version": "10.1.4",
3
+ "version": "10.1.6",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -20,6 +20,12 @@ export declare function isValidDateCellIndex(input: DateCellIndex): boolean;
20
20
  * Input type that is either a Date or a DateCellIndex.
21
21
  */
22
22
  export type DateOrDateCellIndex = Date | DateCellIndex;
23
+ /**
24
+ * A date and the relative date index.
25
+ */
26
+ export interface DateCellIndexDatePair extends Readonly<IndexRef> {
27
+ readonly date: Date;
28
+ }
23
29
  /**
24
30
  * A duration-span block.
25
31
  */
@@ -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.
@@ -276,7 +282,7 @@ export declare function getRelativeIndexForDateCellTiming(timing: DateCellTiming
276
282
  *
277
283
  * Returns a date with the hours and minutes for "now" for the given date returned if an index is input.
278
284
  */
279
- export type DateCellTimingDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateOrDateCellIndex) => Date) & {
285
+ export type DateCellTimingDateFactory<T extends DateCellTimingStartsAt = DateCellTimingStartsAt> = ((input: DateOrDateCellIndex, now?: Date) => Date) & {
280
286
  readonly _timing: T;
281
287
  };
282
288
  /**
@@ -1,7 +1,7 @@
1
1
  import { type DateRange } from '@dereekb/date';
2
- import { type StringOrder, type Maybe, type DayOfWeek, type DecisionFunction, type FilterFunction, type IndexRange, type EnabledDays, type ArrayOrValue, type TimezoneStringRef } from '@dereekb/util';
3
- import { type DateCell, type DateCellDurationSpan, type DateCellIndex, type DateCellTiming, type DateCellTimingDateRange, type DateCellTimingStartsAtEndRange, type FullDateCellTiming, type DateCellTimingEventStartsAt, type DateCellTimingTimezoneInput } from './date.cell';
4
- import { type DateCellTimingRelativeIndexFactoryInput, type DateCellTimingExpansionFactory } from './date.cell.factory';
2
+ import { type StringOrder, type Maybe, type DayOfWeek, type DecisionFunction, type FilterFunction, type IndexRange, type EnabledDays, type ArrayOrValue, type TimezoneStringRef, type Days, type DateRelativeDirection } from '@dereekb/util';
3
+ import { type DateCell, type DateCellDurationSpan, type DateCellIndex, type DateCellTiming, type DateCellTimingDateRange, type DateCellTimingStartsAtEndRange, type FullDateCellTiming, type DateCellTimingEventStartsAt, type DateCellTimingTimezoneInput, type DateCellIndexDatePair } from './date.cell';
4
+ import { type DateCellTimingRelativeIndexFactoryInput, type DateCellTimingExpansionFactory, type DateCellTimingRelativeIndexFactory } from './date.cell.factory';
5
5
  import { type DateCellRangeOrDateRange, type DateCellRangeWithRange } from './date.cell.index';
6
6
  import { type DateTimezoneUtcNormalInstance } from './date.timezone';
7
7
  import { type YearWeekCodeConfig } from './date.week';
@@ -309,7 +309,9 @@ export type DateCellScheduleDateFilterInput = DateCellTimingRelativeIndexFactory
309
309
  /**
310
310
  * Returns true if the date falls within the schedule.
311
311
  */
312
- export type DateCellScheduleDateFilter = DecisionFunction<DateCellScheduleDateFilterInput>;
312
+ export type DateCellScheduleDateFilter = DecisionFunction<DateCellScheduleDateFilterInput> & {
313
+ readonly _dateCellTimingRelativeIndexFactory: DateCellTimingRelativeIndexFactory;
314
+ };
313
315
  /**
314
316
  * dateCellScheduleDateFilter() configuration.
315
317
  */
@@ -317,11 +319,11 @@ export interface DateCellScheduleDateFilterConfig extends DateCellSchedule, Part
317
319
  /**
318
320
  * The min/max date range for the filter.
319
321
  */
320
- minMaxDateRange?: Maybe<Partial<DateCellRangeOrDateRange>>;
322
+ readonly minMaxDateRange?: Maybe<Partial<DateCellRangeOrDateRange>>;
321
323
  /**
322
324
  * Whether or not to restrict the start as the min date if a min date is not set in minMaxDateRange. True by default.
323
325
  */
324
- setStartAsMinDate?: boolean;
326
+ readonly setStartAsMinDate?: boolean;
325
327
  }
326
328
  export declare function copyDateCellScheduleDateFilterConfig(inputFilter: DateCellScheduleDateFilterConfig): DateCellScheduleDateFilterConfig;
327
329
  /**
@@ -331,6 +333,24 @@ export declare function copyDateCellScheduleDateFilterConfig(inputFilter: DateCe
331
333
  * @returns
332
334
  */
333
335
  export declare function dateCellScheduleDateFilter(config: DateCellScheduleDateFilterConfig): DateCellScheduleDateFilter;
336
+ export interface FindNextDateInDateCellScheduleFilterInput {
337
+ readonly date: DateCellScheduleDateFilterInput;
338
+ readonly filter: DateCellScheduleDateFilter;
339
+ readonly direction: DateRelativeDirection;
340
+ readonly maxDistance: Days;
341
+ /**
342
+ * Whether or not to exclude the input date. False by default.
343
+ */
344
+ readonly excludeInputDate?: boolean;
345
+ }
346
+ /**
347
+ * Passes a number of day values until it reaches an open day on a schedule. There's a maximum distance it searches in a direction before returning null.
348
+ *
349
+ * @param date
350
+ * @param filter
351
+ * @param maxDistance
352
+ */
353
+ export declare function findNextDateInDateCellScheduleFilter(config: FindNextDateInDateCellScheduleFilterInput): Maybe<DateCellIndexDatePair>;
334
354
  export type DateCellScheduleDateCellTimingFilter<B extends DateCell = DateCell> = DecisionFunction<B>;
335
355
  /**
336
356
  * Configuration for dateCellScheduleDateCellTimingFilter()
@@ -355,11 +375,11 @@ export interface DateCellScheduleDateCellTimingFilterConfig {
355
375
  */
356
376
  now?: Date;
357
377
  /**
358
- * (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.
359
379
  */
360
380
  onlyBlocksThatHaveStarted?: boolean;
361
381
  /**
362
- * (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.
363
383
  */
364
384
  onlyBlocksThatHaveEnded?: boolean;
365
385
  /**
@@ -1,33 +1,33 @@
1
- import { type Minutes, type DecisionFunction } from '@dereekb/util';
1
+ import { type Minutes, type DecisionFunction, type DateRelativeDirection, type Days, type Maybe } from '@dereekb/util';
2
2
  import { type StepRoundDateTimeDown } from './date.round';
3
- import { type DateCellScheduleDateFilterConfig } from './date.cell.schedule';
3
+ import { type DateCellScheduleDateFilterConfig, type DateCellScheduleDateFilterInput } from './date.cell.schedule';
4
4
  import { type LimitDateTimeConfig } from './date.time.limit';
5
5
  export interface DateTimeMinuteConfig extends LimitDateTimeConfig {
6
6
  /**
7
7
  * Default date to consider.
8
8
  */
9
- date?: Date;
9
+ readonly date?: Date;
10
10
  /**
11
11
  * Number of minutes each "step" is.
12
12
  */
13
- step?: Minutes;
13
+ readonly step?: Minutes;
14
14
  /**
15
15
  * Additional behavior
16
16
  */
17
- behavior?: {
17
+ readonly behavior?: {
18
18
  /**
19
19
  * Whether or not to set the date to the min if the steps go above it.
20
20
  */
21
- capToMinLimit?: boolean;
21
+ readonly capToMinLimit?: boolean;
22
22
  /**
23
23
  * Whether or not to set the date to the max if the steps go above it.
24
24
  */
25
- capToMaxLimit?: boolean;
25
+ readonly capToMaxLimit?: boolean;
26
26
  };
27
27
  /**
28
28
  * Schedule to filter the days to.
29
29
  */
30
- schedule?: DateCellScheduleDateFilterConfig;
30
+ readonly schedule?: DateCellScheduleDateFilterConfig;
31
31
  }
32
32
  /**
33
33
  * Current state of the date in the instance.
@@ -36,30 +36,30 @@ export interface DateTimeMinuteDateStatus {
36
36
  /**
37
37
  * If the date is at the minimum value.
38
38
  */
39
- isAfterMinimum: boolean;
39
+ readonly isAfterMinimum: boolean;
40
40
  /**
41
41
  * If thte date is at the maximum value.
42
42
  */
43
- isBeforeMaximum: boolean;
43
+ readonly isBeforeMaximum: boolean;
44
44
  /**
45
45
  * If the date is in the future.
46
46
  */
47
- inFuture: boolean;
47
+ readonly inFuture: boolean;
48
48
  /**
49
49
  * If the date is in the future at the minimum number of future minutes requested.
50
50
  */
51
- inFutureMinutes: boolean;
51
+ readonly inFutureMinutes: boolean;
52
52
  /**
53
53
  * If the date is in the past.
54
54
  */
55
- inPast: boolean;
55
+ readonly inPast: boolean;
56
56
  /**
57
57
  * If the date is on a schedule day.
58
58
  */
59
- isInSchedule: boolean;
59
+ readonly isInSchedule: boolean;
60
60
  }
61
61
  export interface RoundDateTimeMinute extends StepRoundDateTimeDown {
62
- roundToBound?: boolean;
62
+ readonly roundToBound?: boolean;
63
63
  }
64
64
  /**
65
65
  * Instance for working with a single date/time.
@@ -93,7 +93,11 @@ export declare class DateTimeMinuteInstance {
93
93
  isValid(date?: Date): boolean;
94
94
  getStatus(date?: Date): DateTimeMinuteDateStatus;
95
95
  round(round: RoundDateTimeMinute): Date;
96
- clamp(date?: Date): Date;
96
+ clamp(date?: Date, maxClampDistance?: Days): Date;
97
+ clampToLimit(date?: Date): Date;
98
+ clampToSchedule(date?: Date, maxClampDistance?: Days): Date;
99
+ findNextAvailableDayInSchedule(date: DateCellScheduleDateFilterInput, direction: DateRelativeDirection, maxDistance?: Days): Maybe<Date>;
100
+ isInSchedule(date: DateCellScheduleDateFilterInput): boolean;
97
101
  protected _takeBoundedDate(date?: Date): Date;
98
102
  protected _takeMinimumBoundedDate(date?: Date): Date;
99
103
  protected _takeMaximumBoundedDate(date?: Date): Date;