@dereekb/date 10.0.11 → 10.0.13

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
@@ -5117,6 +5117,88 @@ function expandUniqueDateCellsFunction(config) {
5117
5117
  };
5118
5118
  }
5119
5119
 
5120
+ /**
5121
+ * Creates a DateCellRangeOfTimingFactory.
5122
+ *
5123
+ * @param config
5124
+ * @returns
5125
+ */
5126
+ function dateCellRangeOfTimingFactory(config) {
5127
+ const {
5128
+ timing,
5129
+ fitToTimingRange = true,
5130
+ limitToCompletedIndexes: onlyIncludeIfComplete = false,
5131
+ now: inputNowGetter
5132
+ } = config;
5133
+ const nowGetter = util.asGetter(inputNowGetter !== null && inputNowGetter !== void 0 ? inputNowGetter : () => new Date());
5134
+ const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5135
+ const minIndex = fitToTimingRange ? 0 : Number.MIN_SAFE_INTEGER;
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
+ }
5172
+ return input => {
5173
+ const {
5174
+ i: start,
5175
+ to: end
5176
+ } = input;
5177
+ const startIndex = indexFactory(start !== null && start !== void 0 ? start : 0);
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
5182
+ return {
5183
+ i,
5184
+ to
5185
+ };
5186
+ };
5187
+ }
5188
+ /**
5189
+ * Creates a DateCellRange from the input.
5190
+ *
5191
+ * Convenience function for calling dateCellRangeOfTimingFactory() then passing the input.
5192
+ *
5193
+ * @param config
5194
+ * @param input
5195
+ * @returns
5196
+ */
5197
+ function dateCellRangeOfTiming(config, input) {
5198
+ return dateCellRangeOfTimingFactory(isDateCellTiming(config) ? {
5199
+ timing: config
5200
+ } : config)(input);
5201
+ }
5120
5202
  function dateCellRangeToDateCellIndexRange(range) {
5121
5203
  var _a;
5122
5204
  return {
@@ -5154,7 +5236,7 @@ function dateCellIndexRange(timing, limit, fitToTimingRange = true) {
5154
5236
  const limitMin = indexFactory(start);
5155
5237
  const limitMax = indexFactory(end) + 1;
5156
5238
  if (fitToTimingRange) {
5157
- minIndex = Math.min(limitMin, maxIndex);
5239
+ minIndex = Math.max(limitMin, minIndex);
5158
5240
  maxIndex = Math.min(limitMax, maxIndex);
5159
5241
  } else {
5160
5242
  minIndex = limitMin;
@@ -5276,12 +5358,12 @@ function dateCellDayTimingInfoFactory(config) {
5276
5358
  indexRange,
5277
5359
  inclusiveMaxIndex: false
5278
5360
  });
5279
- const dayIndexFactory = dateCellTimingRelativeIndexFactory(timing);
5361
+ const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5280
5362
  const dayFactory = dateCellTimingDateFactory(timing);
5281
- const startsAtFactory = dateCellTimingStartsAtDateFactory(dayIndexFactory);
5282
- return (input, inputNow) => {
5363
+ const startsAtFactory = dateCellTimingStartsAtDateFactory(indexFactory);
5364
+ const fn = (input, inputNow) => {
5283
5365
  const date = typeof input === 'number' ? dayFactory(input) : input;
5284
- const dayIndex = dayIndexFactory(input);
5366
+ const dayIndex = indexFactory(input);
5285
5367
  const isInRange = checkIsInRange(dayIndex);
5286
5368
  const now = inputNow !== null && inputNow !== void 0 ? inputNow : date;
5287
5369
  const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
@@ -5305,9 +5387,13 @@ function dateCellDayTimingInfoFactory(config) {
5305
5387
  startsAtOnDay,
5306
5388
  endsAtOnDay,
5307
5389
  nextIndexInRange,
5308
- isComplete
5390
+ isComplete,
5391
+ _indexRange: indexRange
5309
5392
  };
5310
5393
  };
5394
+ fn._indexFactory = indexFactory;
5395
+ fn._startsAtFactory = startsAtFactory;
5396
+ return fn;
5311
5397
  }
5312
5398
  /**
5313
5399
  * Returns true if the input is a DateCellTimingRelativeIndexFactory.
@@ -8984,6 +9070,8 @@ exports.dateCellRangeBlocksCount = dateCellRangeBlocksCount;
8984
9070
  exports.dateCellRangeBlocksCountInfo = dateCellRangeBlocksCountInfo;
8985
9071
  exports.dateCellRangeHasRange = dateCellRangeHasRange;
8986
9072
  exports.dateCellRangeIncludedByRangeFunction = dateCellRangeIncludedByRangeFunction;
9073
+ exports.dateCellRangeOfTiming = dateCellRangeOfTiming;
9074
+ exports.dateCellRangeOfTimingFactory = dateCellRangeOfTimingFactory;
8987
9075
  exports.dateCellRangeOverlapsRange = dateCellRangeOverlapsRange;
8988
9076
  exports.dateCellRangeOverlapsRangeFunction = dateCellRangeOverlapsRangeFunction;
8989
9077
  exports.dateCellRangeToDateCellIndexRange = dateCellRangeToDateCellIndexRange;
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';
@@ -5615,6 +5615,104 @@ function expandUniqueDateCellsFunction(config) {
5615
5615
  };
5616
5616
  }
5617
5617
 
5618
+ /**
5619
+ * Input for dateCellRange
5620
+ */
5621
+
5622
+ /**
5623
+ * DateCellRangeOfTimingFactory input
5624
+ */
5625
+
5626
+ /**
5627
+ * Creates a DateCellRange from the input.
5628
+ */
5629
+
5630
+ /**
5631
+ * Creates a DateCellRangeOfTimingFactory.
5632
+ *
5633
+ * @param config
5634
+ * @returns
5635
+ */
5636
+ function dateCellRangeOfTimingFactory(config) {
5637
+ const {
5638
+ timing,
5639
+ fitToTimingRange = true,
5640
+ limitToCompletedIndexes: onlyIncludeIfComplete = false,
5641
+ now: inputNowGetter
5642
+ } = config;
5643
+ const nowGetter = asGetter(inputNowGetter != null ? inputNowGetter : () => new Date());
5644
+ const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5645
+ const minIndex = fitToTimingRange ? 0 : Number.MIN_SAFE_INTEGER;
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
+ }
5683
+ return input => {
5684
+ const {
5685
+ i: start,
5686
+ to: end
5687
+ } = input;
5688
+ const startIndex = indexFactory(start != null ? start : 0);
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
+
5694
+ return {
5695
+ i,
5696
+ to
5697
+ };
5698
+ };
5699
+ }
5700
+
5701
+ /**
5702
+ * Creates a DateCellRange from the input.
5703
+ *
5704
+ * Convenience function for calling dateCellRangeOfTimingFactory() then passing the input.
5705
+ *
5706
+ * @param config
5707
+ * @param input
5708
+ * @returns
5709
+ */
5710
+ function dateCellRangeOfTiming(config, input) {
5711
+ return dateCellRangeOfTimingFactory(isDateCellTiming(config) ? {
5712
+ timing: config
5713
+ } : config)(input);
5714
+ }
5715
+
5618
5716
  /**
5619
5717
  * IndexRange used with DateCells.
5620
5718
  *
@@ -5661,7 +5759,7 @@ function dateCellIndexRange(timing, limit, fitToTimingRange = true) {
5661
5759
  const limitMin = indexFactory(start);
5662
5760
  const limitMax = indexFactory(end) + 1;
5663
5761
  if (fitToTimingRange) {
5664
- minIndex = Math.min(limitMin, maxIndex);
5762
+ minIndex = Math.max(limitMin, minIndex);
5665
5763
  maxIndex = Math.min(limitMax, maxIndex);
5666
5764
  } else {
5667
5765
  minIndex = limitMin;
@@ -5801,12 +5899,12 @@ function dateCellDayTimingInfoFactory(config) {
5801
5899
  indexRange,
5802
5900
  inclusiveMaxIndex: false
5803
5901
  });
5804
- const dayIndexFactory = dateCellTimingRelativeIndexFactory(timing);
5902
+ const indexFactory = dateCellTimingRelativeIndexFactory(timing);
5805
5903
  const dayFactory = dateCellTimingDateFactory(timing);
5806
- const startsAtFactory = dateCellTimingStartsAtDateFactory(dayIndexFactory);
5807
- return (input, inputNow) => {
5904
+ const startsAtFactory = dateCellTimingStartsAtDateFactory(indexFactory);
5905
+ const fn = (input, inputNow) => {
5808
5906
  const date = typeof input === 'number' ? dayFactory(input) : input;
5809
- const dayIndex = dayIndexFactory(input);
5907
+ const dayIndex = indexFactory(input);
5810
5908
  const isInRange = checkIsInRange(dayIndex);
5811
5909
  const now = inputNow != null ? inputNow : date;
5812
5910
  const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
@@ -5831,9 +5929,13 @@ function dateCellDayTimingInfoFactory(config) {
5831
5929
  startsAtOnDay,
5832
5930
  endsAtOnDay,
5833
5931
  nextIndexInRange,
5834
- isComplete
5932
+ isComplete,
5933
+ _indexRange: indexRange
5835
5934
  };
5836
5935
  };
5936
+ fn._indexFactory = indexFactory;
5937
+ fn._startsAtFactory = startsAtFactory;
5938
+ return fn;
5837
5939
  }
5838
5940
 
5839
5941
  /**
@@ -9963,4 +10065,4 @@ class ModelRecurrenceInfoUtility {
9963
10065
  }
9964
10066
  }
9965
10067
 
9966
- 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, 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 };
10068
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/date",
3
- "version": "10.0.11",
3
+ "version": "10.0.13",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -1,8 +1,69 @@
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';
5
5
  import { type DateTimezoneConversionConfigUseSystemTimezone, type DateTimezoneUtcNormalInstance } from './date.timezone';
6
+ /**
7
+ * Input for dateCellRange
8
+ */
9
+ export interface DateCallIndexRangeFromDatesFactoryConfig {
10
+ /**
11
+ * Timing to use relative to the input.
12
+ */
13
+ readonly timing: DateCellTiming;
14
+ /**
15
+ * Whether or not to fit the returned range to the timing's range.
16
+ *
17
+ * Defaults to true.
18
+ */
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>;
32
+ }
33
+ /**
34
+ * DateCellRangeOfTimingFactory input
35
+ */
36
+ export interface DateCellRangeOfTimingInput {
37
+ /**
38
+ * Start date or index
39
+ */
40
+ readonly i?: Maybe<DateOrDateCellIndex>;
41
+ /**
42
+ * End date or index
43
+ */
44
+ readonly to?: Maybe<DateOrDateCellIndex>;
45
+ }
46
+ /**
47
+ * Creates a DateCellRange from the input.
48
+ */
49
+ export type DateCellRangeOfTimingFactory = (input: DateCellRangeOfTimingInput) => DateCellRange;
50
+ /**
51
+ * Creates a DateCellRangeOfTimingFactory.
52
+ *
53
+ * @param config
54
+ * @returns
55
+ */
56
+ export declare function dateCellRangeOfTimingFactory(config: DateCallIndexRangeFromDatesFactoryConfig): DateCellRangeOfTimingFactory;
57
+ /**
58
+ * Creates a DateCellRange from the input.
59
+ *
60
+ * Convenience function for calling dateCellRangeOfTimingFactory() then passing the input.
61
+ *
62
+ * @param config
63
+ * @param input
64
+ * @returns
65
+ */
66
+ export declare function dateCellRangeOfTiming(config: DateCellTiming | DateCallIndexRangeFromDatesFactoryConfig, input: DateCellRangeOfTimingInput): DateCellRange;
6
67
  /**
7
68
  * IndexRange used with DateCells.
8
69
  *
@@ -143,7 +204,10 @@ export interface DateCellDayTimingInfo {
143
204
  *
144
205
  * Can optionally specify a now that is used for checking the inProgress functionality.
145
206
  */
146
- export type DateCellDayTimingInfoFactory = (date: DateOrDateCellIndex, now?: Date) => DateCellDayTimingInfo;
207
+ export type DateCellDayTimingInfoFactory = ((date: DateOrDateCellIndex, now?: Date) => DateCellDayTimingInfo) & {
208
+ readonly _indexFactory: DateCellTimingRelativeIndexFactory;
209
+ readonly _startsAtFactory: DateCellTimingStartsAtDateFactory;
210
+ };
147
211
  export declare function dateCellDayTimingInfoFactory(config: DateCellDayTimingInfoFactoryConfig): DateCellDayTimingInfoFactory;
148
212
  /**
149
213
  * DateCellTimingRelativeIndexFactory input. Can be a Date, DateCellIndex, or ISO8601DayString