@dereekb/date 13.6.17 → 13.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs.js +85 -102
  2. package/index.esm.js +85 -102
  3. package/package.json +5 -5
package/index.cjs.js CHANGED
@@ -2175,35 +2175,33 @@ function _type_of$6(obj) {
2175
2175
  var hasConversion = !config.noConversion;
2176
2176
  if (hasConversion) {
2177
2177
  this._getOffset = function getCurrentOffset(x, from, to) {
2178
- if (from === to) {
2179
- return 0;
2180
- } else {
2178
+ var result = 0;
2179
+ if (from !== to) {
2181
2180
  var target = "".concat(from, "-").concat(to);
2182
- var offset;
2183
2181
  switch(target){
2184
2182
  case 'target-base':
2185
- offset = -calculateOffset(x);
2183
+ result = -calculateOffset(x);
2186
2184
  break;
2187
2185
  case 'base-target':
2188
- offset = calculateOffset(x);
2186
+ result = calculateOffset(x);
2189
2187
  break;
2190
2188
  case 'target-system':
2191
- offset = calculateSystemNormalDifference(x);
2189
+ result = calculateSystemNormalDifference(x);
2192
2190
  break;
2193
2191
  case 'system-target':
2194
- offset = -calculateSystemNormalDifference(x);
2192
+ result = -calculateSystemNormalDifference(x);
2195
2193
  break;
2196
2194
  case 'base-system':
2197
- offset = getCurrentSystemOffsetInMs(x);
2195
+ result = getCurrentSystemOffsetInMs(x);
2198
2196
  break;
2199
2197
  case 'system-base':
2200
- offset = -getCurrentSystemOffsetInMs(x);
2198
+ result = -getCurrentSystemOffsetInMs(x);
2201
2199
  break;
2202
2200
  default:
2203
2201
  throw new Error('unexpected offset target "'.concat(target, '"'));
2204
2202
  }
2205
- return offset;
2206
2203
  }
2204
+ return result;
2207
2205
  };
2208
2206
  } else {
2209
2207
  this._getOffset = function() {
@@ -2252,8 +2250,9 @@ function _type_of$6(obj) {
2252
2250
  */ key: "safeMirroredConvertDate",
2253
2251
  value: function safeMirroredConvertDate(config) {
2254
2252
  var baseDate = config.baseDate, originalContextDate = config.originalContextDate, contextType = config.contextType, _config_safeConvert = config.safeConvert, safeConvert = _config_safeConvert === void 0 ? true : _config_safeConvert;
2253
+ var result;
2255
2254
  if (contextType === 'base') {
2256
- return {
2255
+ result = {
2257
2256
  date: baseDate,
2258
2257
  daylightSavingsOffset: 0
2259
2258
  };
@@ -2264,11 +2263,12 @@ function _type_of$6(obj) {
2264
2263
  // (cannot determine whether or not to apply the -5 or -6 offset after daylight savings ends)
2265
2264
  var daylightSavingsOffset = safeConvert ? dateFns.differenceInHours(originalContextDate, reverseConversion) : 0;
2266
2265
  var date = daylightSavingsOffset ? dateFns.addHours(reverseConversion, daylightSavingsOffset) : reverseConversion;
2267
- return {
2266
+ result = {
2268
2267
  date: date,
2269
2268
  daylightSavingsOffset: daylightSavingsOffset
2270
2269
  };
2271
2270
  }
2271
+ return result;
2272
2272
  }
2273
2273
  },
2274
2274
  {
@@ -2442,12 +2442,14 @@ function _type_of$6(obj) {
2442
2442
  * @returns the start of the day as a BaseDateAsUTC
2443
2443
  */ key: "startOfDayInBaseDate",
2444
2444
  value: function startOfDayInBaseDate(date) {
2445
+ var result;
2445
2446
  if (typeof date === 'string') {
2446
- return util.parseISO8601DayStringToUTCDate(date);
2447
+ result = util.parseISO8601DayStringToUTCDate(date);
2447
2448
  } else {
2448
2449
  var startOfDayForSystem = dateFns.startOfDay(date !== null && date !== void 0 ? date : new Date());
2449
- return this.baseDateToSystemDate(startOfDayForSystem);
2450
+ result = this.baseDateToSystemDate(startOfDayForSystem);
2450
2451
  }
2452
+ return result;
2451
2453
  }
2452
2454
  },
2453
2455
  {
@@ -2471,12 +2473,14 @@ function _type_of$6(obj) {
2471
2473
  * @returns the start of the day in the system timezone
2472
2474
  */ key: "startOfDayInSystemDate",
2473
2475
  value: function startOfDayInSystemDate(date) {
2476
+ var result;
2474
2477
  if (typeof date === 'string') {
2475
2478
  var utcDate = util.parseISO8601DayStringToUTCDate(date);
2476
- return this.systemDateToBaseDate(utcDate);
2479
+ result = this.systemDateToBaseDate(utcDate);
2477
2480
  } else {
2478
- return dateFns.startOfDay(date !== null && date !== void 0 ? date : new Date());
2481
+ result = dateFns.startOfDay(date !== null && date !== void 0 ? date : new Date());
2479
2482
  }
2483
+ return result;
2480
2484
  }
2481
2485
  },
2482
2486
  {
@@ -4284,12 +4288,13 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4284
4288
  * @returns true if the range has valid non-negative indexes and `to` (when defined) is greater than or equal to `i`
4285
4289
  */ function isValidDateCellRange(input) {
4286
4290
  var i = input.i, to = input.to;
4291
+ var result = true;
4287
4292
  if (!isValidDateCellIndex(i)) {
4288
- return false;
4293
+ result = false;
4289
4294
  } else if (to != null && (!isValidDateCellIndex(to) || to < i)) {
4290
- return false;
4295
+ result = false;
4291
4296
  }
4292
- return true;
4297
+ return result;
4293
4298
  }
4294
4299
  /**
4295
4300
  * Returns true if the input is a sorted DateCellRange array and there are no repeat indexes.
@@ -4309,12 +4314,14 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4309
4314
  return false;
4310
4315
  }
4311
4316
  var greatestIndex = -1;
4317
+ var result = true;
4312
4318
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4313
4319
  try {
4314
4320
  for(var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4315
4321
  var range = _step.value;
4316
4322
  if (range.i <= greatestIndex) {
4317
- return false;
4323
+ result = false;
4324
+ break;
4318
4325
  } else {
4319
4326
  var _range_to;
4320
4327
  var nextGreatestIndex = (_range_to = range.to) !== null && _range_to !== void 0 ? _range_to : range.i; // to is greater than or equal to i in a valid date block range.
@@ -4335,7 +4342,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4335
4342
  }
4336
4343
  }
4337
4344
  }
4338
- return true;
4345
+ return result;
4339
4346
  }
4340
4347
  /**
4341
4348
  * Returns the lowest index between all the input date block ranges. Returns 0 by default if there is no minimum or input blocks.
@@ -4441,11 +4448,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4441
4448
  * @param input - index, cell, or range to normalize
4442
4449
  * @returns a DateCellRangeWithRange with an explicit `to` value
4443
4450
  */ function dateCellRangeWithRange(input) {
4444
- if (typeof input === 'number') {
4445
- return dateCellRangeWithRangeFromIndex(input);
4446
- } else {
4447
- return dateCellRange(input.i, input.to);
4448
- }
4451
+ return typeof input === 'number' ? dateCellRangeWithRangeFromIndex(input) : dateCellRange(input.i, input.to);
4449
4452
  }
4450
4453
  /**
4451
4454
  * Creates a {@link DateCellRangeIncludedByRangeFunction} that checks whether a given range
@@ -4910,11 +4913,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4910
4913
  *
4911
4914
  * @returns true if the current block should be retained over the next block
4912
4915
  */ function shouldRetainCurrentOverNext() {
4913
- if (current.priority === next.priority) {
4914
- return retainOnOverlap === 'current';
4915
- } else {
4916
- return current.priority === retainOnOverlap;
4917
- }
4916
+ return current.priority === next.priority ? retainOnOverlap === 'current' : current.priority === retainOnOverlap;
4918
4917
  };
4919
4918
  var inputGroup = Array.isArray(input) ? groupUniqueDateCells(input) : input;
4920
4919
  var sorted = inputGroup.blocks.map(function(block) {
@@ -5557,35 +5556,35 @@ function _type_of$3(obj) {
5557
5556
  */ function dateCellTimingRelativeIndexFactory(input) {
5558
5557
  if (isDateCellTimingRelativeIndexFactory(input)) {
5559
5558
  return input;
5560
- } else {
5561
- var timing = input;
5562
- var _dateCellTimingStartPair = dateCellTimingStartPair(input), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
5563
- var startInUtc = normalInstance.baseDateToTargetDate(start); // takes the target date and puts in into UTC normal
5564
- var factory = function factory(input) {
5565
- var inputType = typeof input === "undefined" ? "undefined" : _type_of$3(input);
5566
- var diff;
5567
- if (inputType === 'number') {
5568
- return input;
5569
- } else if (inputType === 'string') {
5570
- var startOfDayInUtc = util.parseISO8601DayStringToUTCDate(input); // parse as UTC
5571
- diff = dateFns.differenceInHours(startOfDayInUtc, startInUtc, {
5572
- roundingMethod: 'floor'
5573
- }); // compare the UTC times. Round down.
5574
- // console.log({ startOfDayInUtc, diff, startInUtc });
5575
- } else {
5576
- var dateInUtc = normalInstance.baseDateToTargetDate(input); // convert to UTC normal
5577
- diff = dateFns.differenceInHours(dateInUtc, startInUtc, {
5578
- roundingMethod: 'floor'
5579
- }); // compare the difference in UTC times. Round down.
5580
- // console.log({ input, dateInUtc, diff, startInUtc, tz: normalInstance.configuredTimezoneString, systemTargetOffset: normalInstance.targetDateToSystemDateOffset(input as Date) / MS_IN_HOUR, targetBaseOffset: normalInstance.targetDateToBaseDateOffset(input as Date) / MS_IN_HOUR });
5581
- }
5582
- var daysOffset = Math.floor(diff / util.HOURS_IN_DAY); // total number of hours difference from the original UTC date
5583
- return daysOffset ? daysOffset : 0; // do not return -0
5584
- };
5585
- factory._timing = timing;
5586
- factory._normalInstance = normalInstance;
5587
- return factory;
5588
5559
  }
5560
+ var timing = input;
5561
+ var _dateCellTimingStartPair = dateCellTimingStartPair(input), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
5562
+ var startInUtc = normalInstance.baseDateToTargetDate(start); // takes the target date and puts in into UTC normal
5563
+ var factory = function factory(input) {
5564
+ var inputType = typeof input === "undefined" ? "undefined" : _type_of$3(input);
5565
+ if (inputType === 'number') {
5566
+ return input;
5567
+ }
5568
+ var diff;
5569
+ if (inputType === 'string') {
5570
+ var startOfDayInUtc = util.parseISO8601DayStringToUTCDate(input); // parse as UTC
5571
+ diff = dateFns.differenceInHours(startOfDayInUtc, startInUtc, {
5572
+ roundingMethod: 'floor'
5573
+ }); // compare the UTC times. Round down.
5574
+ // console.log({ startOfDayInUtc, diff, startInUtc });
5575
+ } else {
5576
+ var dateInUtc = normalInstance.baseDateToTargetDate(input); // convert to UTC normal
5577
+ diff = dateFns.differenceInHours(dateInUtc, startInUtc, {
5578
+ roundingMethod: 'floor'
5579
+ }); // compare the difference in UTC times. Round down.
5580
+ // console.log({ input, dateInUtc, diff, startInUtc, tz: normalInstance.configuredTimezoneString, systemTargetOffset: normalInstance.targetDateToSystemDateOffset(input as Date) / MS_IN_HOUR, targetBaseOffset: normalInstance.targetDateToBaseDateOffset(input as Date) / MS_IN_HOUR });
5581
+ }
5582
+ var daysOffset = Math.floor(diff / util.HOURS_IN_DAY); // total number of hours difference from the original UTC date
5583
+ return daysOffset ? daysOffset : 0; // do not return -0
5584
+ };
5585
+ factory._timing = timing;
5586
+ factory._normalInstance = normalInstance;
5587
+ return factory;
5589
5588
  }
5590
5589
  /**
5591
5590
  * Creates a {@link DateCellTimingRelativeIndexArrayFactory} that converts mixed arrays of
@@ -5676,17 +5675,16 @@ function _type_of$3(obj) {
5676
5675
  var factory = function factory(input, inputNow) {
5677
5676
  if (util.isDate(input)) {
5678
5677
  return input;
5679
- } else {
5680
- var now = inputNow !== null && inputNow !== void 0 ? inputNow : new Date();
5681
- var nowHours = now.getUTCHours();
5682
- var utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
5683
- // 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.
5684
- if (startUtcHours > nowHours) {
5685
- input += 1;
5686
- }
5687
- // add days to apply the correct offset to the target index
5688
- return dateFns.addHours(utcStartDateWithNowTime, input * util.HOURS_IN_DAY);
5689
5678
  }
5679
+ var now = inputNow !== null && inputNow !== void 0 ? inputNow : new Date();
5680
+ var nowHours = now.getUTCHours();
5681
+ var utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
5682
+ // 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.
5683
+ if (startUtcHours > nowHours) {
5684
+ input += 1;
5685
+ }
5686
+ // add days to apply the correct offset to the target index
5687
+ return dateFns.addHours(utcStartDateWithNowTime, input * util.HOURS_IN_DAY);
5690
5688
  };
5691
5689
  factory._timing = timing;
5692
5690
  return factory;
@@ -6986,12 +6984,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
6986
6984
  * @param b - second schedule to compare
6987
6985
  * @returns whether both schedules are equivalent
6988
6986
  */ function isSameDateCellSchedule(a, b) {
6989
- if (a && b) {
6990
- var _a_ex, _b_ex, _a_d, _b_d;
6991
- return a.w === b.w && util.iterablesAreSetEquivalent((_a_ex = a.ex) !== null && _a_ex !== void 0 ? _a_ex : [], (_b_ex = b.ex) !== null && _b_ex !== void 0 ? _b_ex : []) && util.iterablesAreSetEquivalent((_a_d = a.d) !== null && _a_d !== void 0 ? _a_d : [], (_b_d = b.d) !== null && _b_d !== void 0 ? _b_d : []);
6992
- } else {
6993
- return a == b;
6994
- }
6987
+ var _a_ex, _b_ex, _a_d, _b_d;
6988
+ return a && b ? a.w === b.w && util.iterablesAreSetEquivalent((_a_ex = a.ex) !== null && _a_ex !== void 0 ? _a_ex : [], (_b_ex = b.ex) !== null && _b_ex !== void 0 ? _b_ex : []) && util.iterablesAreSetEquivalent((_a_d = a.d) !== null && _a_d !== void 0 ? _a_d : [], (_b_d = b.d) !== null && _b_d !== void 0 ? _b_d : []) : a == b;
6995
6989
  }
6996
6990
  /**
6997
6991
  * Returns true if the input is possibly a DateCellScheduleDateRange (has schedule fields and valid start/end dates).
@@ -7027,11 +7021,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7027
7021
  * @param b - second schedule date range to compare
7028
7022
  * @returns whether both have identical date ranges and schedules
7029
7023
  */ function isSameDateCellScheduleDateRange(a, b) {
7030
- if (a && b) {
7031
- return isSameDateRange(a, b) && isSameDateCellSchedule(a, b);
7032
- } else {
7033
- return a == b;
7034
- }
7024
+ return a && b ? isSameDateRange(a, b) && isSameDateCellSchedule(a, b) : a == b;
7035
7025
  }
7036
7026
  /**
7037
7027
  * Creates a DateCellScheduleDateRange from the input, normalizing the start date to the start of day in the target timezone.
@@ -7114,11 +7104,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7114
7104
  * @param b - second event range to compare
7115
7105
  * @returns whether both event ranges are equivalent
7116
7106
  */ function isSameDateCellScheduleEventRange(a, b) {
7117
- if (a && b) {
7118
- return isSameDateCellScheduleDateRange(a, b) && isSameDateCellScheduleEventRange(a, b);
7119
- } else {
7120
- return a == b;
7121
- }
7107
+ return a && b ? isSameDateCellScheduleDateRange(a, b) && isSameDateCellScheduleEventRange(a, b) : a == b;
7122
7108
  }
7123
7109
  /**
7124
7110
  * Returns true if the input is possibly a FullDateCellScheduleRange (has schedule fields and full timing fields).
@@ -7141,11 +7127,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7141
7127
  * @param b - second full schedule range to compare
7142
7128
  * @returns whether both full schedule ranges are equivalent
7143
7129
  */ function isSameFullDateCellScheduleDateRange(a, b) {
7144
- if (a && b) {
7145
- return isSameDateCellScheduleDateRange(a, b) && isSameFullDateCellTiming(a, b);
7146
- } else {
7147
- return a == b;
7148
- }
7130
+ return a && b ? isSameDateCellScheduleDateRange(a, b) && isSameFullDateCellTiming(a, b) : a == b;
7149
7131
  }
7150
7132
  /**
7151
7133
  * If a duration is not set, this is the default used.
@@ -7293,6 +7275,9 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7293
7275
  /**
7294
7276
  * Converts a minMaxDateRange Date or index to a day index. For Date inputs, extracts the calendar day
7295
7277
  * from the system timezone as an ISO8601 day string to avoid cross-timezone day boundary issues.
7278
+ *
7279
+ * @param input - A Date or numeric day index to convert.
7280
+ * @returns The corresponding zero-based day cell index relative to the schedule start.
7296
7281
  */ function _minMaxDateRangeDateOrIndexToIndex(input) {
7297
7282
  var result;
7298
7283
  if (typeof input === 'number') {
@@ -7821,6 +7806,9 @@ function _object_spread_props$5(target, source) {
7821
7806
  */ var DURATION_COMPONENT_REGEX = /(\d+(?:\.\d+)?)\s*(w|wk|weeks?|d|days?|h|hr|hours?|m(?!s)|min|minutes?|s|sec|seconds?|ms|milliseconds?)/gi;
7822
7807
  /**
7823
7808
  * Maps parsed unit strings to their canonical TimeUnit value.
7809
+ *
7810
+ * @param unitStr - The raw unit string from a parsed duration component (e.g., 'hr', 'minutes', 'ms').
7811
+ * @returns The canonical {@link TimeUnit} corresponding to the input string.
7824
7812
  */ function normalizeUnitString(unitStr) {
7825
7813
  var lower = unitStr.toLowerCase();
7826
7814
  if (lower === 'ms' || lower === 'milliseconds' || lower === 'millisecond') {
@@ -9550,15 +9538,11 @@ function _object_spread_props$3(target, source) {
9550
9538
  */ function dateTimeMinuteWholeDayDecisionFunction(config) {
9551
9539
  var startAndEndOfDayMustBeValid = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
9552
9540
  var instance = new DateTimeMinuteInstance(config, null);
9553
- if (startAndEndOfDayMustBeValid) {
9554
- return function(date) {
9555
- return instance.isValid(dateFns.startOfDay(date)) && instance.isValid(dateFns.endOfDay(date));
9556
- };
9557
- } else {
9558
- return function(date) {
9559
- return instance.dateDayContainsValidDateValue(date);
9560
- };
9561
- }
9541
+ return startAndEndOfDayMustBeValid ? function(date) {
9542
+ return instance.isValid(dateFns.startOfDay(date)) && instance.isValid(dateFns.endOfDay(date));
9543
+ } : function(date) {
9544
+ return instance.dateDayContainsValidDateValue(date);
9545
+ };
9562
9546
  }
9563
9547
 
9564
9548
  function _class_call_check$4(instance, Constructor) {
@@ -9776,9 +9760,8 @@ function _object_spread_props$2(target, source) {
9776
9760
  return {
9777
9761
  valid: false
9778
9762
  };
9779
- } else {
9780
- input = input.trim();
9781
9763
  }
9764
+ input = input.trim();
9782
9765
  var systemParsedDateTime;
9783
9766
  var valid = false;
9784
9767
  function parseTimeString() {
package/index.esm.js CHANGED
@@ -2174,35 +2174,33 @@ function _type_of$6(obj) {
2174
2174
  var hasConversion = !config.noConversion;
2175
2175
  if (hasConversion) {
2176
2176
  this._getOffset = function getCurrentOffset(x, from, to) {
2177
- if (from === to) {
2178
- return 0;
2179
- } else {
2177
+ var result = 0;
2178
+ if (from !== to) {
2180
2179
  var target = "".concat(from, "-").concat(to);
2181
- var offset;
2182
2180
  switch(target){
2183
2181
  case 'target-base':
2184
- offset = -calculateOffset(x);
2182
+ result = -calculateOffset(x);
2185
2183
  break;
2186
2184
  case 'base-target':
2187
- offset = calculateOffset(x);
2185
+ result = calculateOffset(x);
2188
2186
  break;
2189
2187
  case 'target-system':
2190
- offset = calculateSystemNormalDifference(x);
2188
+ result = calculateSystemNormalDifference(x);
2191
2189
  break;
2192
2190
  case 'system-target':
2193
- offset = -calculateSystemNormalDifference(x);
2191
+ result = -calculateSystemNormalDifference(x);
2194
2192
  break;
2195
2193
  case 'base-system':
2196
- offset = getCurrentSystemOffsetInMs(x);
2194
+ result = getCurrentSystemOffsetInMs(x);
2197
2195
  break;
2198
2196
  case 'system-base':
2199
- offset = -getCurrentSystemOffsetInMs(x);
2197
+ result = -getCurrentSystemOffsetInMs(x);
2200
2198
  break;
2201
2199
  default:
2202
2200
  throw new Error('unexpected offset target "'.concat(target, '"'));
2203
2201
  }
2204
- return offset;
2205
2202
  }
2203
+ return result;
2206
2204
  };
2207
2205
  } else {
2208
2206
  this._getOffset = function() {
@@ -2251,8 +2249,9 @@ function _type_of$6(obj) {
2251
2249
  */ key: "safeMirroredConvertDate",
2252
2250
  value: function safeMirroredConvertDate(config) {
2253
2251
  var baseDate = config.baseDate, originalContextDate = config.originalContextDate, contextType = config.contextType, _config_safeConvert = config.safeConvert, safeConvert = _config_safeConvert === void 0 ? true : _config_safeConvert;
2252
+ var result;
2254
2253
  if (contextType === 'base') {
2255
- return {
2254
+ result = {
2256
2255
  date: baseDate,
2257
2256
  daylightSavingsOffset: 0
2258
2257
  };
@@ -2263,11 +2262,12 @@ function _type_of$6(obj) {
2263
2262
  // (cannot determine whether or not to apply the -5 or -6 offset after daylight savings ends)
2264
2263
  var daylightSavingsOffset = safeConvert ? differenceInHours(originalContextDate, reverseConversion) : 0;
2265
2264
  var date = daylightSavingsOffset ? addHours(reverseConversion, daylightSavingsOffset) : reverseConversion;
2266
- return {
2265
+ result = {
2267
2266
  date: date,
2268
2267
  daylightSavingsOffset: daylightSavingsOffset
2269
2268
  };
2270
2269
  }
2270
+ return result;
2271
2271
  }
2272
2272
  },
2273
2273
  {
@@ -2441,12 +2441,14 @@ function _type_of$6(obj) {
2441
2441
  * @returns the start of the day as a BaseDateAsUTC
2442
2442
  */ key: "startOfDayInBaseDate",
2443
2443
  value: function startOfDayInBaseDate(date) {
2444
+ var result;
2444
2445
  if (typeof date === 'string') {
2445
- return parseISO8601DayStringToUTCDate(date);
2446
+ result = parseISO8601DayStringToUTCDate(date);
2446
2447
  } else {
2447
2448
  var startOfDayForSystem = startOfDay(date !== null && date !== void 0 ? date : new Date());
2448
- return this.baseDateToSystemDate(startOfDayForSystem);
2449
+ result = this.baseDateToSystemDate(startOfDayForSystem);
2449
2450
  }
2451
+ return result;
2450
2452
  }
2451
2453
  },
2452
2454
  {
@@ -2470,12 +2472,14 @@ function _type_of$6(obj) {
2470
2472
  * @returns the start of the day in the system timezone
2471
2473
  */ key: "startOfDayInSystemDate",
2472
2474
  value: function startOfDayInSystemDate(date) {
2475
+ var result;
2473
2476
  if (typeof date === 'string') {
2474
2477
  var utcDate = parseISO8601DayStringToUTCDate(date);
2475
- return this.systemDateToBaseDate(utcDate);
2478
+ result = this.systemDateToBaseDate(utcDate);
2476
2479
  } else {
2477
- return startOfDay(date !== null && date !== void 0 ? date : new Date());
2480
+ result = startOfDay(date !== null && date !== void 0 ? date : new Date());
2478
2481
  }
2482
+ return result;
2479
2483
  }
2480
2484
  },
2481
2485
  {
@@ -4283,12 +4287,13 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4283
4287
  * @returns true if the range has valid non-negative indexes and `to` (when defined) is greater than or equal to `i`
4284
4288
  */ function isValidDateCellRange(input) {
4285
4289
  var i = input.i, to = input.to;
4290
+ var result = true;
4286
4291
  if (!isValidDateCellIndex(i)) {
4287
- return false;
4292
+ result = false;
4288
4293
  } else if (to != null && (!isValidDateCellIndex(to) || to < i)) {
4289
- return false;
4294
+ result = false;
4290
4295
  }
4291
- return true;
4296
+ return result;
4292
4297
  }
4293
4298
  /**
4294
4299
  * Returns true if the input is a sorted DateCellRange array and there are no repeat indexes.
@@ -4308,12 +4313,14 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4308
4313
  return false;
4309
4314
  }
4310
4315
  var greatestIndex = -1;
4316
+ var result = true;
4311
4317
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4312
4318
  try {
4313
4319
  for(var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4314
4320
  var range = _step.value;
4315
4321
  if (range.i <= greatestIndex) {
4316
- return false;
4322
+ result = false;
4323
+ break;
4317
4324
  } else {
4318
4325
  var _range_to;
4319
4326
  var nextGreatestIndex = (_range_to = range.to) !== null && _range_to !== void 0 ? _range_to : range.i; // to is greater than or equal to i in a valid date block range.
@@ -4334,7 +4341,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4334
4341
  }
4335
4342
  }
4336
4343
  }
4337
- return true;
4344
+ return result;
4338
4345
  }
4339
4346
  /**
4340
4347
  * Returns the lowest index between all the input date block ranges. Returns 0 by default if there is no minimum or input blocks.
@@ -4440,11 +4447,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4440
4447
  * @param input - index, cell, or range to normalize
4441
4448
  * @returns a DateCellRangeWithRange with an explicit `to` value
4442
4449
  */ function dateCellRangeWithRange(input) {
4443
- if (typeof input === 'number') {
4444
- return dateCellRangeWithRangeFromIndex(input);
4445
- } else {
4446
- return dateCellRange(input.i, input.to);
4447
- }
4450
+ return typeof input === 'number' ? dateCellRangeWithRangeFromIndex(input) : dateCellRange(input.i, input.to);
4448
4451
  }
4449
4452
  /**
4450
4453
  * Creates a {@link DateCellRangeIncludedByRangeFunction} that checks whether a given range
@@ -4909,11 +4912,7 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4909
4912
  *
4910
4913
  * @returns true if the current block should be retained over the next block
4911
4914
  */ function shouldRetainCurrentOverNext() {
4912
- if (current.priority === next.priority) {
4913
- return retainOnOverlap === 'current';
4914
- } else {
4915
- return current.priority === retainOnOverlap;
4916
- }
4915
+ return current.priority === next.priority ? retainOnOverlap === 'current' : current.priority === retainOnOverlap;
4917
4916
  };
4918
4917
  var inputGroup = Array.isArray(input) ? groupUniqueDateCells(input) : input;
4919
4918
  var sorted = inputGroup.blocks.map(function(block) {
@@ -5556,35 +5555,35 @@ function _type_of$3(obj) {
5556
5555
  */ function dateCellTimingRelativeIndexFactory(input) {
5557
5556
  if (isDateCellTimingRelativeIndexFactory(input)) {
5558
5557
  return input;
5559
- } else {
5560
- var timing = input;
5561
- var _dateCellTimingStartPair = dateCellTimingStartPair(input), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
5562
- var startInUtc = normalInstance.baseDateToTargetDate(start); // takes the target date and puts in into UTC normal
5563
- var factory = function factory(input) {
5564
- var inputType = typeof input === "undefined" ? "undefined" : _type_of$3(input);
5565
- var diff;
5566
- if (inputType === 'number') {
5567
- return input;
5568
- } else if (inputType === 'string') {
5569
- var startOfDayInUtc = parseISO8601DayStringToUTCDate(input); // parse as UTC
5570
- diff = differenceInHours(startOfDayInUtc, startInUtc, {
5571
- roundingMethod: 'floor'
5572
- }); // compare the UTC times. Round down.
5573
- // console.log({ startOfDayInUtc, diff, startInUtc });
5574
- } else {
5575
- var dateInUtc = normalInstance.baseDateToTargetDate(input); // convert to UTC normal
5576
- diff = differenceInHours(dateInUtc, startInUtc, {
5577
- roundingMethod: 'floor'
5578
- }); // compare the difference in UTC times. Round down.
5579
- // console.log({ input, dateInUtc, diff, startInUtc, tz: normalInstance.configuredTimezoneString, systemTargetOffset: normalInstance.targetDateToSystemDateOffset(input as Date) / MS_IN_HOUR, targetBaseOffset: normalInstance.targetDateToBaseDateOffset(input as Date) / MS_IN_HOUR });
5580
- }
5581
- var daysOffset = Math.floor(diff / HOURS_IN_DAY); // total number of hours difference from the original UTC date
5582
- return daysOffset ? daysOffset : 0; // do not return -0
5583
- };
5584
- factory._timing = timing;
5585
- factory._normalInstance = normalInstance;
5586
- return factory;
5587
5558
  }
5559
+ var timing = input;
5560
+ var _dateCellTimingStartPair = dateCellTimingStartPair(input), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
5561
+ var startInUtc = normalInstance.baseDateToTargetDate(start); // takes the target date and puts in into UTC normal
5562
+ var factory = function factory(input) {
5563
+ var inputType = typeof input === "undefined" ? "undefined" : _type_of$3(input);
5564
+ if (inputType === 'number') {
5565
+ return input;
5566
+ }
5567
+ var diff;
5568
+ if (inputType === 'string') {
5569
+ var startOfDayInUtc = parseISO8601DayStringToUTCDate(input); // parse as UTC
5570
+ diff = differenceInHours(startOfDayInUtc, startInUtc, {
5571
+ roundingMethod: 'floor'
5572
+ }); // compare the UTC times. Round down.
5573
+ // console.log({ startOfDayInUtc, diff, startInUtc });
5574
+ } else {
5575
+ var dateInUtc = normalInstance.baseDateToTargetDate(input); // convert to UTC normal
5576
+ diff = differenceInHours(dateInUtc, startInUtc, {
5577
+ roundingMethod: 'floor'
5578
+ }); // compare the difference in UTC times. Round down.
5579
+ // console.log({ input, dateInUtc, diff, startInUtc, tz: normalInstance.configuredTimezoneString, systemTargetOffset: normalInstance.targetDateToSystemDateOffset(input as Date) / MS_IN_HOUR, targetBaseOffset: normalInstance.targetDateToBaseDateOffset(input as Date) / MS_IN_HOUR });
5580
+ }
5581
+ var daysOffset = Math.floor(diff / HOURS_IN_DAY); // total number of hours difference from the original UTC date
5582
+ return daysOffset ? daysOffset : 0; // do not return -0
5583
+ };
5584
+ factory._timing = timing;
5585
+ factory._normalInstance = normalInstance;
5586
+ return factory;
5588
5587
  }
5589
5588
  /**
5590
5589
  * Creates a {@link DateCellTimingRelativeIndexArrayFactory} that converts mixed arrays of
@@ -5675,17 +5674,16 @@ function _type_of$3(obj) {
5675
5674
  var factory = function factory(input, inputNow) {
5676
5675
  if (isDate$2(input)) {
5677
5676
  return input;
5678
- } else {
5679
- var now = inputNow !== null && inputNow !== void 0 ? inputNow : new Date();
5680
- var nowHours = now.getUTCHours();
5681
- var utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
5682
- // 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.
5683
- if (startUtcHours > nowHours) {
5684
- input += 1;
5685
- }
5686
- // add days to apply the correct offset to the target index
5687
- return addHours(utcStartDateWithNowTime, input * HOURS_IN_DAY);
5688
5677
  }
5678
+ var now = inputNow !== null && inputNow !== void 0 ? inputNow : new Date();
5679
+ var nowHours = now.getUTCHours();
5680
+ var utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
5681
+ // 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.
5682
+ if (startUtcHours > nowHours) {
5683
+ input += 1;
5684
+ }
5685
+ // add days to apply the correct offset to the target index
5686
+ return addHours(utcStartDateWithNowTime, input * HOURS_IN_DAY);
5689
5687
  };
5690
5688
  factory._timing = timing;
5691
5689
  return factory;
@@ -6985,12 +6983,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
6985
6983
  * @param b - second schedule to compare
6986
6984
  * @returns whether both schedules are equivalent
6987
6985
  */ function isSameDateCellSchedule(a, b) {
6988
- if (a && b) {
6989
- var _a_ex, _b_ex, _a_d, _b_d;
6990
- return a.w === b.w && iterablesAreSetEquivalent((_a_ex = a.ex) !== null && _a_ex !== void 0 ? _a_ex : [], (_b_ex = b.ex) !== null && _b_ex !== void 0 ? _b_ex : []) && iterablesAreSetEquivalent((_a_d = a.d) !== null && _a_d !== void 0 ? _a_d : [], (_b_d = b.d) !== null && _b_d !== void 0 ? _b_d : []);
6991
- } else {
6992
- return a == b;
6993
- }
6986
+ var _a_ex, _b_ex, _a_d, _b_d;
6987
+ return a && b ? a.w === b.w && iterablesAreSetEquivalent((_a_ex = a.ex) !== null && _a_ex !== void 0 ? _a_ex : [], (_b_ex = b.ex) !== null && _b_ex !== void 0 ? _b_ex : []) && iterablesAreSetEquivalent((_a_d = a.d) !== null && _a_d !== void 0 ? _a_d : [], (_b_d = b.d) !== null && _b_d !== void 0 ? _b_d : []) : a == b;
6994
6988
  }
6995
6989
  /**
6996
6990
  * Returns true if the input is possibly a DateCellScheduleDateRange (has schedule fields and valid start/end dates).
@@ -7026,11 +7020,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7026
7020
  * @param b - second schedule date range to compare
7027
7021
  * @returns whether both have identical date ranges and schedules
7028
7022
  */ function isSameDateCellScheduleDateRange(a, b) {
7029
- if (a && b) {
7030
- return isSameDateRange(a, b) && isSameDateCellSchedule(a, b);
7031
- } else {
7032
- return a == b;
7033
- }
7023
+ return a && b ? isSameDateRange(a, b) && isSameDateCellSchedule(a, b) : a == b;
7034
7024
  }
7035
7025
  /**
7036
7026
  * Creates a DateCellScheduleDateRange from the input, normalizing the start date to the start of day in the target timezone.
@@ -7113,11 +7103,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7113
7103
  * @param b - second event range to compare
7114
7104
  * @returns whether both event ranges are equivalent
7115
7105
  */ function isSameDateCellScheduleEventRange(a, b) {
7116
- if (a && b) {
7117
- return isSameDateCellScheduleDateRange(a, b) && isSameDateCellScheduleEventRange(a, b);
7118
- } else {
7119
- return a == b;
7120
- }
7106
+ return a && b ? isSameDateCellScheduleDateRange(a, b) && isSameDateCellScheduleEventRange(a, b) : a == b;
7121
7107
  }
7122
7108
  /**
7123
7109
  * Returns true if the input is possibly a FullDateCellScheduleRange (has schedule fields and full timing fields).
@@ -7140,11 +7126,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7140
7126
  * @param b - second full schedule range to compare
7141
7127
  * @returns whether both full schedule ranges are equivalent
7142
7128
  */ function isSameFullDateCellScheduleDateRange(a, b) {
7143
- if (a && b) {
7144
- return isSameDateCellScheduleDateRange(a, b) && isSameFullDateCellTiming(a, b);
7145
- } else {
7146
- return a == b;
7147
- }
7129
+ return a && b ? isSameDateCellScheduleDateRange(a, b) && isSameFullDateCellTiming(a, b) : a == b;
7148
7130
  }
7149
7131
  /**
7150
7132
  * If a duration is not set, this is the default used.
@@ -7292,6 +7274,9 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
7292
7274
  /**
7293
7275
  * Converts a minMaxDateRange Date or index to a day index. For Date inputs, extracts the calendar day
7294
7276
  * from the system timezone as an ISO8601 day string to avoid cross-timezone day boundary issues.
7277
+ *
7278
+ * @param input - A Date or numeric day index to convert.
7279
+ * @returns The corresponding zero-based day cell index relative to the schedule start.
7295
7280
  */ function _minMaxDateRangeDateOrIndexToIndex(input) {
7296
7281
  var result;
7297
7282
  if (typeof input === 'number') {
@@ -7820,6 +7805,9 @@ function _object_spread_props$5(target, source) {
7820
7805
  */ var DURATION_COMPONENT_REGEX = /(\d+(?:\.\d+)?)\s*(w|wk|weeks?|d|days?|h|hr|hours?|m(?!s)|min|minutes?|s|sec|seconds?|ms|milliseconds?)/gi;
7821
7806
  /**
7822
7807
  * Maps parsed unit strings to their canonical TimeUnit value.
7808
+ *
7809
+ * @param unitStr - The raw unit string from a parsed duration component (e.g., 'hr', 'minutes', 'ms').
7810
+ * @returns The canonical {@link TimeUnit} corresponding to the input string.
7823
7811
  */ function normalizeUnitString(unitStr) {
7824
7812
  var lower = unitStr.toLowerCase();
7825
7813
  if (lower === 'ms' || lower === 'milliseconds' || lower === 'millisecond') {
@@ -9549,15 +9537,11 @@ function _object_spread_props$3(target, source) {
9549
9537
  */ function dateTimeMinuteWholeDayDecisionFunction(config) {
9550
9538
  var startAndEndOfDayMustBeValid = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
9551
9539
  var instance = new DateTimeMinuteInstance(config, null);
9552
- if (startAndEndOfDayMustBeValid) {
9553
- return function(date) {
9554
- return instance.isValid(startOfDay(date)) && instance.isValid(endOfDay(date));
9555
- };
9556
- } else {
9557
- return function(date) {
9558
- return instance.dateDayContainsValidDateValue(date);
9559
- };
9560
- }
9540
+ return startAndEndOfDayMustBeValid ? function(date) {
9541
+ return instance.isValid(startOfDay(date)) && instance.isValid(endOfDay(date));
9542
+ } : function(date) {
9543
+ return instance.dateDayContainsValidDateValue(date);
9544
+ };
9561
9545
  }
9562
9546
 
9563
9547
  function _class_call_check$4(instance, Constructor) {
@@ -9775,9 +9759,8 @@ function _object_spread_props$2(target, source) {
9775
9759
  return {
9776
9760
  valid: false
9777
9761
  };
9778
- } else {
9779
- input = input.trim();
9780
9762
  }
9763
+ input = input.trim();
9781
9764
  var systemParsedDateTime;
9782
9765
  var valid = false;
9783
9766
  function parseTimeString() {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dereekb/date",
3
- "version": "13.6.17",
3
+ "version": "13.8.0",
4
4
  "peerDependencies": {
5
- "@dereekb/model": "13.6.17",
6
- "@dereekb/rxjs": "13.6.17",
7
- "@dereekb/util": "13.6.17",
5
+ "@dereekb/model": "13.8.0",
6
+ "@dereekb/rxjs": "13.8.0",
7
+ "@dereekb/util": "13.8.0",
8
8
  "@vvo/tzdb": "^6.0.0",
9
9
  "arktype": "^2.2.0",
10
10
  "date-fns": "^4.0.0",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {},
16
16
  "devDependencies": {
17
- "@dereekb/rxjs": "13.6.17"
17
+ "@dereekb/rxjs": "13.8.0"
18
18
  },
19
19
  "exports": {
20
20
  "./package.json": "./package.json",