@dereekb/date 10.0.12 → 10.0.14

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
@@ -5126,20 +5126,59 @@ function expandUniqueDateCellsFunction(config) {
5126
5126
  function dateCellRangeOfTimingFactory(config) {
5127
5127
  const {
5128
5128
  timing,
5129
- fitToTimingRange = true
5129
+ fitToTimingRange = true,
5130
+ limitToCompletedIndexes: onlyIncludeIfComplete = false,
5131
+ now: inputNowGetter
5130
5132
  } = config;
5133
+ const nowGetter = util.asGetter(inputNowGetter !== null && inputNowGetter !== void 0 ? inputNowGetter : () => new Date());
5131
5134
  const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5132
5135
  const minIndex = fitToTimingRange ? 0 : Number.MIN_SAFE_INTEGER;
5133
5136
  const maxIndex = fitToTimingRange ? indexFactory(indexFactory._timing.end) : Number.MAX_SAFE_INTEGER;
5137
+ let getCurrentMaxIndex;
5138
+ if (onlyIncludeIfComplete) {
5139
+ const timingInfoFactory = dateCellDayTimingInfoFactory({
5140
+ timing
5141
+ });
5142
+ const endAtFactory = dateCellTimingEndDateFactory(timing);
5143
+ let nextExpectedIndexChangeAt;
5144
+ let currentMaxDay;
5145
+ function refreshCurrentInfo() {
5146
+ const now = nowGetter();
5147
+ const currentInfo = timingInfoFactory(now, now);
5148
+ if (fitToTimingRange && currentInfo.isComplete) {
5149
+ // if the timing is complete relative to now, then update to prevent any further updates since the max will not change anymore
5150
+ currentMaxDay = indexFactory(indexFactory._timing.end);
5151
+ getCurrentMaxIndex = () => currentMaxDay;
5152
+ } else {
5153
+ const latestCompletedIndex = currentInfo.isInProgress ? currentInfo.currentIndex - 1 : currentInfo.currentIndex;
5154
+ // calculate the next max change. It occurs whenever the current index ends
5155
+ nextExpectedIndexChangeAt = endAtFactory(latestCompletedIndex + 1);
5156
+ currentMaxDay = fitToTimingRange ? Math.max(latestCompletedIndex, -1) : latestCompletedIndex; // the currentIndex day is not yet complete.
5157
+ }
5158
+ }
5159
+
5160
+ refreshCurrentInfo();
5161
+ getCurrentMaxIndex = () => {
5162
+ const now = nowGetter();
5163
+ if (!dateFns.isBefore(now, nextExpectedIndexChangeAt)) {
5164
+ // refresh since we're expecting the index change
5165
+ refreshCurrentInfo();
5166
+ }
5167
+ return currentMaxDay;
5168
+ };
5169
+ } else {
5170
+ getCurrentMaxIndex = () => maxIndex;
5171
+ }
5134
5172
  return input => {
5135
5173
  const {
5136
5174
  i: start,
5137
5175
  to: end
5138
- } = input;
5176
+ } = input !== null && input !== void 0 ? input : {};
5139
5177
  const startIndex = indexFactory(start !== null && start !== void 0 ? start : 0);
5140
- const endIndex = indexFactory(end !== null && end !== void 0 ? end : new Date());
5141
- const i = Math.max(minIndex, startIndex);
5142
- const to = Math.min(maxIndex, endIndex);
5178
+ const endIndex = indexFactory(end !== null && end !== void 0 ? end : nowGetter());
5179
+ const maxIndex = getCurrentMaxIndex();
5180
+ const to = Math.min(maxIndex, endIndex); // calculate to first to get the max value
5181
+ const i = Math.min(Math.max(minIndex, startIndex), to); // i should never be greater than to
5143
5182
  return {
5144
5183
  i,
5145
5184
  to
@@ -5160,6 +5199,20 @@ function dateCellRangeOfTiming(config, input) {
5160
5199
  timing: config
5161
5200
  } : config)(input);
5162
5201
  }
5202
+ /**
5203
+ * Convenience function for dateCellRangeOfTiming() that returns the latest completed index.
5204
+ *
5205
+ * By default fitToTimingRange is true.
5206
+ */
5207
+ function dateCellTimingCompletedTimeRange(timing, config) {
5208
+ var _a;
5209
+ return dateCellRangeOfTiming({
5210
+ timing,
5211
+ now: config === null || config === void 0 ? void 0 : config.now,
5212
+ fitToTimingRange: (_a = config === null || config === void 0 ? void 0 : config.fitToTimingRange) !== null && _a !== void 0 ? _a : true,
5213
+ limitToCompletedIndexes: true
5214
+ });
5215
+ }
5163
5216
  function dateCellRangeToDateCellIndexRange(range) {
5164
5217
  var _a;
5165
5218
  return {
@@ -5319,12 +5372,12 @@ function dateCellDayTimingInfoFactory(config) {
5319
5372
  indexRange,
5320
5373
  inclusiveMaxIndex: false
5321
5374
  });
5322
- const dayIndexFactory = dateCellTimingRelativeIndexFactory(timing);
5375
+ const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5323
5376
  const dayFactory = dateCellTimingDateFactory(timing);
5324
- const startsAtFactory = dateCellTimingStartsAtDateFactory(dayIndexFactory);
5325
- return (input, inputNow) => {
5377
+ const startsAtFactory = dateCellTimingStartsAtDateFactory(indexFactory);
5378
+ const fn = (input, inputNow) => {
5326
5379
  const date = typeof input === 'number' ? dayFactory(input) : input;
5327
- const dayIndex = dayIndexFactory(input);
5380
+ const dayIndex = indexFactory(input);
5328
5381
  const isInRange = checkIsInRange(dayIndex);
5329
5382
  const now = inputNow !== null && inputNow !== void 0 ? inputNow : date;
5330
5383
  const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
@@ -5348,9 +5401,13 @@ function dateCellDayTimingInfoFactory(config) {
5348
5401
  startsAtOnDay,
5349
5402
  endsAtOnDay,
5350
5403
  nextIndexInRange,
5351
- isComplete
5404
+ isComplete,
5405
+ _indexRange: indexRange
5352
5406
  };
5353
5407
  };
5408
+ fn._indexFactory = indexFactory;
5409
+ fn._startsAtFactory = startsAtFactory;
5410
+ return fn;
5354
5411
  }
5355
5412
  /**
5356
5413
  * Returns true if the input is a DateCellTimingRelativeIndexFactory.
@@ -9044,6 +9101,7 @@ exports.dateCellScheduleDayCodesFromEnabledDays = dateCellScheduleDayCodesFromEn
9044
9101
  exports.dateCellScheduleDayCodesSetFromDaysOfWeek = dateCellScheduleDayCodesSetFromDaysOfWeek;
9045
9102
  exports.dateCellScheduleEncodedWeek = dateCellScheduleEncodedWeek;
9046
9103
  exports.dateCellTiming = dateCellTiming;
9104
+ exports.dateCellTimingCompletedTimeRange = dateCellTimingCompletedTimeRange;
9047
9105
  exports.dateCellTimingDateFactory = dateCellTimingDateFactory;
9048
9106
  exports.dateCellTimingDateRange = dateCellTimingDateRange;
9049
9107
  exports.dateCellTimingEndDateFactory = dateCellTimingEndDateFactory;
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MS_IN_HOUR, MS_IN_MINUTE, MINUTES_IN_DAY, isISO8601DateString, filterMaybeValues, asArray, dayOfWeek, sortNumbersAscendingFunction, SORT_VALUE_LESS_THAN, SORT_VALUE_GREATER_THAN, SORT_VALUE_EQUAL, copyArray, compareFnOrder, groupValues, daysOfWeekArray, MS_IN_DAY, minutesToFractionalHours, UTC_TIMEZONE_STRING, isSameNonNullValue, isConsideredUtcTimezoneString, parseISO8601DayStringToUTCDate, cachedGetter, replaceStringsFunction, sortAscendingIndexNumberRefFunction, range, addToSet, sumOfIntegersBetween, makeValuesGroupMap, lastValue, pushArrayItemsIntoArray, indexRangeCheckFunction, mergeFilterFunctions, isDate as isDate$2, HOURS_IN_DAY, getNextDay, enabledDaysFromDaysOfWeek, daysOfWeekFromEnabledDays, firstValueFromIterable, forEachInIterable, iterablesAreSetEquivalent, invertFilter, mapIdentityFunction, repeatString, HashSet, DATE_NOW_VALUE, roundNumberUpToStep, protectedFactory, MS_IN_SECOND, TimeAM, isLogicalDateStringCode as isLogicalDateStringCode$1, dateFromLogicalDate as dateFromLogicalDate$1, flattenArray, splitJoinRemainder } from '@dereekb/util';
1
+ import { MS_IN_HOUR, MS_IN_MINUTE, MINUTES_IN_DAY, isISO8601DateString, filterMaybeValues, asArray, dayOfWeek, sortNumbersAscendingFunction, SORT_VALUE_LESS_THAN, SORT_VALUE_GREATER_THAN, SORT_VALUE_EQUAL, copyArray, compareFnOrder, groupValues, daysOfWeekArray, MS_IN_DAY, minutesToFractionalHours, UTC_TIMEZONE_STRING, isSameNonNullValue, isConsideredUtcTimezoneString, parseISO8601DayStringToUTCDate, cachedGetter, replaceStringsFunction, sortAscendingIndexNumberRefFunction, range, addToSet, sumOfIntegersBetween, makeValuesGroupMap, lastValue, pushArrayItemsIntoArray, asGetter, indexRangeCheckFunction, mergeFilterFunctions, isDate as isDate$2, HOURS_IN_DAY, getNextDay, enabledDaysFromDaysOfWeek, daysOfWeekFromEnabledDays, firstValueFromIterable, forEachInIterable, iterablesAreSetEquivalent, invertFilter, mapIdentityFunction, repeatString, HashSet, DATE_NOW_VALUE, roundNumberUpToStep, protectedFactory, MS_IN_SECOND, TimeAM, isLogicalDateStringCode as isLogicalDateStringCode$1, dateFromLogicalDate as dateFromLogicalDate$1, flattenArray, splitJoinRemainder } from '@dereekb/util';
2
2
  import { isDate as isDate$1, startOfMinute, isValid, parseISO, min as min$5, max as max$2, isAfter as isAfter$1, isEqual, isSameDay, isPast, addDays, set as set$1, differenceInDays, startOfMonth, endOfWeek, startOfWeek, endOfMonth, addHours, addMinutes, isBefore, addMilliseconds, startOfDay, addMonths, addWeeks, endOfDay, endOfHour, startOfHour, endOfMinute, minutesToHours, getMinutes, getSeconds, getMilliseconds, differenceInMilliseconds, differenceInHours, getWeek, getYear, setWeek, getDay, formatDistanceStrict, formatDistance, format, differenceInMinutes, formatDistanceToNow, parse, addSeconds } from 'date-fns';
3
3
  import { Expose, Type, Exclude } from 'class-transformer';
4
4
  import { IsDate, IsEnum, IsOptional, IsNumber, Min, registerDecorator, IsString, Matches, IsArray, IsBoolean } from 'class-validator';
@@ -5636,20 +5636,61 @@ function expandUniqueDateCellsFunction(config) {
5636
5636
  function dateCellRangeOfTimingFactory(config) {
5637
5637
  const {
5638
5638
  timing,
5639
- fitToTimingRange = true
5639
+ fitToTimingRange = true,
5640
+ limitToCompletedIndexes: onlyIncludeIfComplete = false,
5641
+ now: inputNowGetter
5640
5642
  } = config;
5643
+ const nowGetter = asGetter(inputNowGetter != null ? inputNowGetter : () => new Date());
5641
5644
  const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5642
5645
  const minIndex = fitToTimingRange ? 0 : Number.MIN_SAFE_INTEGER;
5643
5646
  const maxIndex = fitToTimingRange ? indexFactory(indexFactory._timing.end) : Number.MAX_SAFE_INTEGER;
5647
+ let getCurrentMaxIndex;
5648
+ if (onlyIncludeIfComplete) {
5649
+ const timingInfoFactory = dateCellDayTimingInfoFactory({
5650
+ timing
5651
+ });
5652
+ const endAtFactory = dateCellTimingEndDateFactory(timing);
5653
+ let nextExpectedIndexChangeAt;
5654
+ let currentMaxDay;
5655
+ function refreshCurrentInfo() {
5656
+ const now = nowGetter();
5657
+ const currentInfo = timingInfoFactory(now, now);
5658
+ if (fitToTimingRange && currentInfo.isComplete) {
5659
+ // if the timing is complete relative to now, then update to prevent any further updates since the max will not change anymore
5660
+ currentMaxDay = indexFactory(indexFactory._timing.end);
5661
+ getCurrentMaxIndex = () => currentMaxDay;
5662
+ } else {
5663
+ const latestCompletedIndex = currentInfo.isInProgress ? currentInfo.currentIndex - 1 : currentInfo.currentIndex;
5664
+
5665
+ // calculate the next max change. It occurs whenever the current index ends
5666
+ nextExpectedIndexChangeAt = endAtFactory(latestCompletedIndex + 1);
5667
+ currentMaxDay = fitToTimingRange ? Math.max(latestCompletedIndex, -1) : latestCompletedIndex; // the currentIndex day is not yet complete.
5668
+ }
5669
+ }
5670
+
5671
+ refreshCurrentInfo();
5672
+ getCurrentMaxIndex = () => {
5673
+ const now = nowGetter();
5674
+ if (!isBefore(now, nextExpectedIndexChangeAt)) {
5675
+ // refresh since we're expecting the index change
5676
+ refreshCurrentInfo();
5677
+ }
5678
+ return currentMaxDay;
5679
+ };
5680
+ } else {
5681
+ getCurrentMaxIndex = () => maxIndex;
5682
+ }
5644
5683
  return input => {
5645
5684
  const {
5646
5685
  i: start,
5647
5686
  to: end
5648
- } = input;
5687
+ } = input != null ? input : {};
5649
5688
  const startIndex = indexFactory(start != null ? start : 0);
5650
- const endIndex = indexFactory(end != null ? end : new Date());
5651
- const i = Math.max(minIndex, startIndex);
5652
- const to = Math.min(maxIndex, endIndex);
5689
+ const endIndex = indexFactory(end != null ? end : nowGetter());
5690
+ const maxIndex = getCurrentMaxIndex();
5691
+ const to = Math.min(maxIndex, endIndex); // calculate to first to get the max value
5692
+ const i = Math.min(Math.max(minIndex, startIndex), to); // i should never be greater than to
5693
+
5653
5694
  return {
5654
5695
  i,
5655
5696
  to
@@ -5671,6 +5712,21 @@ function dateCellRangeOfTiming(config, input) {
5671
5712
  timing: config
5672
5713
  } : config)(input);
5673
5714
  }
5715
+ /**
5716
+ * Convenience function for dateCellRangeOfTiming() that returns the latest completed index.
5717
+ *
5718
+ * By default fitToTimingRange is true.
5719
+ */
5720
+ function dateCellTimingCompletedTimeRange(timing, config) {
5721
+ var _config$fitToTimingRa;
5722
+ return dateCellRangeOfTiming({
5723
+ timing,
5724
+ now: config == null ? void 0 : config.now,
5725
+ fitToTimingRange: (_config$fitToTimingRa = config == null ? void 0 : config.fitToTimingRange) != null ? _config$fitToTimingRa : true,
5726
+ // default to true
5727
+ limitToCompletedIndexes: true
5728
+ });
5729
+ }
5674
5730
 
5675
5731
  /**
5676
5732
  * IndexRange used with DateCells.
@@ -5858,12 +5914,12 @@ function dateCellDayTimingInfoFactory(config) {
5858
5914
  indexRange,
5859
5915
  inclusiveMaxIndex: false
5860
5916
  });
5861
- const dayIndexFactory = dateCellTimingRelativeIndexFactory(timing);
5917
+ const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5862
5918
  const dayFactory = dateCellTimingDateFactory(timing);
5863
- const startsAtFactory = dateCellTimingStartsAtDateFactory(dayIndexFactory);
5864
- return (input, inputNow) => {
5919
+ const startsAtFactory = dateCellTimingStartsAtDateFactory(indexFactory);
5920
+ const fn = (input, inputNow) => {
5865
5921
  const date = typeof input === 'number' ? dayFactory(input) : input;
5866
- const dayIndex = dayIndexFactory(input);
5922
+ const dayIndex = indexFactory(input);
5867
5923
  const isInRange = checkIsInRange(dayIndex);
5868
5924
  const now = inputNow != null ? inputNow : date;
5869
5925
  const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
@@ -5888,9 +5944,13 @@ function dateCellDayTimingInfoFactory(config) {
5888
5944
  startsAtOnDay,
5889
5945
  endsAtOnDay,
5890
5946
  nextIndexInRange,
5891
- isComplete
5947
+ isComplete,
5948
+ _indexRange: indexRange
5892
5949
  };
5893
5950
  };
5951
+ fn._indexFactory = indexFactory;
5952
+ fn._startsAtFactory = startsAtFactory;
5953
+ return fn;
5894
5954
  }
5895
5955
 
5896
5956
  /**
@@ -10020,4 +10080,4 @@ class ModelRecurrenceInfoUtility {
10020
10080
  }
10021
10081
  }
10022
10082
 
10023
- 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, calendarDate, calendarDateFactory, calendarDateForDateDurationSpan, changeDateCellScheduleDateRangeToTimezone, changeDateCellScheduleDateRangeToTimezoneFunction, clampDateFunction, clampDateRangeFunction, clampDateRangeToDateRange, clampDateToDateRange, copyDateCellScheduleDateFilterConfig, copyHoursAndMinutesFromDate, copyHoursAndMinutesFromDateToToday, copyHoursAndMinutesFromDateWithTimezoneNormal, copyHoursAndMinutesFromNow, copyHoursAndMinutesFromNowWithTimezoneNormal, 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, dateCellTimingDateFactory, dateCellTimingDateRange, dateCellTimingEndDateFactory, dateCellTimingEndIndex, dateCellTimingEventRange, dateCellTimingExpansionFactory, dateCellTimingFinalStartsAtEvent, dateCellTimingFromDateCellTimingStartsAtEndRange, 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, 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, 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, isSameFullDateCellScheduleDateRange, isSameFullDateCellTiming, 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, 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 };
10083
+ 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, calendarDate, calendarDateFactory, calendarDateForDateDurationSpan, changeDateCellScheduleDateRangeToTimezone, changeDateCellScheduleDateRangeToTimezoneFunction, clampDateFunction, clampDateRangeFunction, clampDateRangeToDateRange, clampDateToDateRange, copyDateCellScheduleDateFilterConfig, copyHoursAndMinutesFromDate, copyHoursAndMinutesFromDateToToday, copyHoursAndMinutesFromDateWithTimezoneNormal, copyHoursAndMinutesFromNow, copyHoursAndMinutesFromNowWithTimezoneNormal, 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, 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, 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, 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, isSameFullDateCellScheduleDateRange, isSameFullDateCellTiming, 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, 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.0.12",
3
+ "version": "10.0.14",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { type Maybe, type ArrayOrValue, type FilterFunction, type IndexRange, type ISO8601DayString, type IndexNumber } from '@dereekb/util';
1
+ import { type Maybe, type ArrayOrValue, type FilterFunction, type IndexRange, type ISO8601DayString, type IndexNumber, type GetterOrValue } from '@dereekb/util';
2
2
  import { type DateCell, type DateCellIndex, type DateOrDateCellIndex, type DateCellTiming, type DateCellArrayRef, type DateCellArray, type DateCellTimingRangeInput, type DateCellCollection, type DateCellDurationSpan, type DateCellTimingStartsAt, type DateCellTimingEvent, type DateCellTimingStartsAtEndRange, type FullDateCellTiming } from './date.cell';
3
3
  import { type DateCellRange, type DateCellRangeWithRange, type DateOrDateRangeOrDateCellIndexOrDateCellRange } from './date.cell.index';
4
4
  import { type DateRange, type DateRangeStart } from './date.range';
@@ -17,6 +17,18 @@ export interface DateCallIndexRangeFromDatesFactoryConfig {
17
17
  * Defaults to true.
18
18
  */
19
19
  readonly fitToTimingRange?: boolean;
20
+ /**
21
+ * Only include the index if the timing is marked as complete for that index.
22
+ *
23
+ * If no indexes have been completed, the returned value range will be -1 to -1.
24
+ *
25
+ * Defaults to false.
26
+ */
27
+ readonly limitToCompletedIndexes?: boolean;
28
+ /**
29
+ * (Optional) now date/getter used to influence the limitToCompletedIndexes calculations.
30
+ */
31
+ readonly now?: GetterOrValue<Date>;
20
32
  }
21
33
  /**
22
34
  * DateCellRangeOfTimingFactory input
@@ -25,16 +37,16 @@ export interface DateCellRangeOfTimingInput {
25
37
  /**
26
38
  * Start date or index
27
39
  */
28
- readonly i?: DateOrDateCellIndex;
40
+ readonly i?: Maybe<DateOrDateCellIndex>;
29
41
  /**
30
42
  * End date or index
31
43
  */
32
- readonly to?: DateOrDateCellIndex;
44
+ readonly to?: Maybe<DateOrDateCellIndex>;
33
45
  }
34
46
  /**
35
47
  * Creates a DateCellRange from the input.
36
48
  */
37
- export type DateCellRangeOfTimingFactory = (input: DateCellRangeOfTimingInput) => DateCellRange;
49
+ export type DateCellRangeOfTimingFactory = (input?: Maybe<DateCellRangeOfTimingInput>) => DateCellRangeWithRange;
38
50
  /**
39
51
  * Creates a DateCellRangeOfTimingFactory.
40
52
  *
@@ -51,7 +63,14 @@ export declare function dateCellRangeOfTimingFactory(config: DateCallIndexRangeF
51
63
  * @param input
52
64
  * @returns
53
65
  */
54
- export declare function dateCellRangeOfTiming(config: DateCellTiming | DateCallIndexRangeFromDatesFactoryConfig, input: DateCellRangeOfTimingInput): DateCellRange;
66
+ export declare function dateCellRangeOfTiming(config: DateCellTiming | DateCallIndexRangeFromDatesFactoryConfig, input?: Maybe<DateCellRangeOfTimingInput>): DateCellRangeWithRange;
67
+ export type DateCellTimingCompleteTimeRangeConfig = Pick<DateCallIndexRangeFromDatesFactoryConfig, 'now' | 'fitToTimingRange'>;
68
+ /**
69
+ * Convenience function for dateCellRangeOfTiming() that returns the latest completed index.
70
+ *
71
+ * By default fitToTimingRange is true.
72
+ */
73
+ export declare function dateCellTimingCompletedTimeRange(timing: DateCellTiming, config?: DateCellTimingCompleteTimeRangeConfig): DateCellRangeWithRange;
55
74
  /**
56
75
  * IndexRange used with DateCells.
57
76
  *
@@ -192,7 +211,10 @@ export interface DateCellDayTimingInfo {
192
211
  *
193
212
  * Can optionally specify a now that is used for checking the inProgress functionality.
194
213
  */
195
- export type DateCellDayTimingInfoFactory = (date: DateOrDateCellIndex, now?: Date) => DateCellDayTimingInfo;
214
+ export type DateCellDayTimingInfoFactory = ((date: DateOrDateCellIndex, now?: Date) => DateCellDayTimingInfo) & {
215
+ readonly _indexFactory: DateCellTimingRelativeIndexFactory;
216
+ readonly _startsAtFactory: DateCellTimingStartsAtDateFactory;
217
+ };
196
218
  export declare function dateCellDayTimingInfoFactory(config: DateCellDayTimingInfoFactoryConfig): DateCellDayTimingInfoFactory;
197
219
  /**
198
220
  * DateCellTimingRelativeIndexFactory input. Can be a Date, DateCellIndex, or ISO8601DayString