@dereekb/date 10.2.0 → 11.0.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.
- package/index.cjs.js +228 -171
- package/index.esm.js +2 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -1903,8 +1903,8 @@ function toISODateString(input) {
|
|
|
1903
1903
|
* @returns
|
|
1904
1904
|
*/
|
|
1905
1905
|
function guessCurrentTimezone() {
|
|
1906
|
-
var
|
|
1907
|
-
return (
|
|
1906
|
+
var _Intl$DateTimeFormat;
|
|
1907
|
+
return (_Intl$DateTimeFormat = Intl.DateTimeFormat()) == null || (_Intl$DateTimeFormat = _Intl$DateTimeFormat.resolvedOptions()) == null ? void 0 : _Intl$DateTimeFormat.timeZone;
|
|
1908
1908
|
}
|
|
1909
1909
|
/**
|
|
1910
1910
|
* Convenience function for getCurrentTimezone() that asserts a timezone is returned.
|
|
@@ -1928,8 +1928,8 @@ function safeToJsDate(input) {
|
|
|
1928
1928
|
* @returns
|
|
1929
1929
|
*/
|
|
1930
1930
|
function toJsDate(input) {
|
|
1931
|
-
var
|
|
1932
|
-
return isDate(input) ? input : (
|
|
1931
|
+
var _parseJsDateString;
|
|
1932
|
+
return isDate(input) ? input : (_parseJsDateString = parseJsDateString(input)) != null ? _parseJsDateString : new Date(input);
|
|
1933
1933
|
}
|
|
1934
1934
|
function parseJsDateString(input) {
|
|
1935
1935
|
const date = typeof input === 'string' && util.isISO8601DateString(input) ? dateFns.parseISO(input) : new Date(input);
|
|
@@ -2028,11 +2028,11 @@ function copyHoursAndMinutesToDate({
|
|
|
2028
2028
|
removeSeconds,
|
|
2029
2029
|
roundDownToMinute = true
|
|
2030
2030
|
}, target) {
|
|
2031
|
-
return dateFns.set(target
|
|
2031
|
+
return dateFns.set(target != null ? target : new Date(), Object.assign({
|
|
2032
2032
|
hours
|
|
2033
2033
|
}, minutes != null ? {
|
|
2034
2034
|
minutes
|
|
2035
|
-
} : undefined
|
|
2035
|
+
} : undefined, roundDownToMinute || removeSeconds ? {
|
|
2036
2036
|
seconds: 0,
|
|
2037
2037
|
milliseconds: 0
|
|
2038
2038
|
} : undefined));
|
|
@@ -2250,6 +2250,8 @@ function isDateRangeStart(value) {
|
|
|
2250
2250
|
const sortDateRangeStartAscendingCompareFunction = sortByDateFunction(x => x.start);
|
|
2251
2251
|
class DateRange {
|
|
2252
2252
|
constructor(template) {
|
|
2253
|
+
this.start = void 0;
|
|
2254
|
+
this.end = void 0;
|
|
2253
2255
|
if (template != null) {
|
|
2254
2256
|
this.start = template.start;
|
|
2255
2257
|
this.end = template.end;
|
|
@@ -2298,11 +2300,10 @@ function isFullDateRange(input) {
|
|
|
2298
2300
|
return input.start != null && input.end != null;
|
|
2299
2301
|
}
|
|
2300
2302
|
function dateOrDateRangeToDateRange(startOrDateRange, end) {
|
|
2301
|
-
var _a;
|
|
2302
2303
|
if (isDate(startOrDateRange)) {
|
|
2303
2304
|
return {
|
|
2304
2305
|
start: startOrDateRange,
|
|
2305
|
-
end:
|
|
2306
|
+
end: end != null ? end : startOrDateRange
|
|
2306
2307
|
};
|
|
2307
2308
|
} else {
|
|
2308
2309
|
return startOrDateRange;
|
|
@@ -2384,6 +2385,7 @@ class DateRangeParams {
|
|
|
2384
2385
|
* Date to filter on. If not provided, assumes now.
|
|
2385
2386
|
*/
|
|
2386
2387
|
this.date = new Date();
|
|
2388
|
+
this.distance = void 0;
|
|
2387
2389
|
if (template) {
|
|
2388
2390
|
this.type = template.type;
|
|
2389
2391
|
this.date = template.date;
|
|
@@ -2411,10 +2413,10 @@ function dateRange(input, inputRoundToMinute) {
|
|
|
2411
2413
|
distance: inputDistance,
|
|
2412
2414
|
roundToMinute: inputConfigRoundToMinute = false
|
|
2413
2415
|
} = config;
|
|
2414
|
-
const rawDistance = inputDistance
|
|
2415
|
-
const roundToMinute = inputRoundToMinute
|
|
2416
|
-
let date = inputDate
|
|
2417
|
-
let distance = inputDistance
|
|
2416
|
+
const rawDistance = inputDistance != null ? inputDistance : undefined;
|
|
2417
|
+
const roundToMinute = inputRoundToMinute != null ? inputRoundToMinute : inputConfigRoundToMinute;
|
|
2418
|
+
let date = inputDate != null ? inputDate : new Date();
|
|
2419
|
+
let distance = inputDistance != null ? inputDistance : 1;
|
|
2418
2420
|
let start = date;
|
|
2419
2421
|
let end = date;
|
|
2420
2422
|
if (roundToMinute) {
|
|
@@ -2738,25 +2740,25 @@ function fitUTCDateRangeToDayPeriod(dateRange) {
|
|
|
2738
2740
|
newDistance = util.MS_IN_DAY;
|
|
2739
2741
|
}
|
|
2740
2742
|
const end = dateFns.addMilliseconds(dateRange.start, newDistance);
|
|
2741
|
-
return Object.assign(
|
|
2743
|
+
return Object.assign({}, dateRange, {
|
|
2742
2744
|
start: dateRange.start,
|
|
2743
2745
|
end
|
|
2744
2746
|
});
|
|
2745
2747
|
}
|
|
2746
2748
|
function clampDateFunction(dateRange) {
|
|
2747
|
-
var _a, _b;
|
|
2748
2749
|
let fn;
|
|
2749
2750
|
const hasStartDate = dateRange.start != null;
|
|
2750
2751
|
const hasEndDate = dateRange.end != null;
|
|
2751
2752
|
if (hasStartDate || hasEndDate) {
|
|
2753
|
+
var _dateRange$start, _dateRange$end;
|
|
2752
2754
|
// Start Clamp
|
|
2753
|
-
const startTime = ((
|
|
2755
|
+
const startTime = ((_dateRange$start = dateRange.start) == null ? void 0 : _dateRange$start.getTime()) || 0;
|
|
2754
2756
|
const clampStart = input => {
|
|
2755
2757
|
const time = input.getTime();
|
|
2756
2758
|
return time >= startTime ? input : dateRange.start;
|
|
2757
2759
|
};
|
|
2758
2760
|
// End Clamp
|
|
2759
|
-
const endTime = ((
|
|
2761
|
+
const endTime = ((_dateRange$end = dateRange.end) == null ? void 0 : _dateRange$end.getTime()) || 0;
|
|
2760
2762
|
const clampEnd = input => {
|
|
2761
2763
|
const time = input.getTime();
|
|
2762
2764
|
return time <= endTime ? input : dateRange.end;
|
|
@@ -2848,6 +2850,8 @@ function getDaysOfWeekInDateRange(dateRange) {
|
|
|
2848
2850
|
|
|
2849
2851
|
class DateDurationSpan {
|
|
2850
2852
|
constructor(template) {
|
|
2853
|
+
this.startsAt = void 0;
|
|
2854
|
+
this.duration = void 0;
|
|
2851
2855
|
if (template != null) {
|
|
2852
2856
|
this.startsAt = template.startsAt;
|
|
2853
2857
|
this.duration = template.duration;
|
|
@@ -3076,16 +3080,20 @@ class DateTimezoneUtcNormalInstance {
|
|
|
3076
3080
|
const {
|
|
3077
3081
|
timezone
|
|
3078
3082
|
} = this.config;
|
|
3079
|
-
return timezone
|
|
3083
|
+
return timezone != null ? timezone : this.config.useSystemTimezone ? guessCurrentTimezone() : undefined;
|
|
3080
3084
|
}
|
|
3081
3085
|
constructor(config) {
|
|
3086
|
+
this.config = void 0;
|
|
3087
|
+
this.hasConversion = void 0;
|
|
3088
|
+
this._getOffset = void 0;
|
|
3082
3089
|
this._setOnDate = util.cachedGetter(() => setOnDateWithTimezoneNormalFunction(this));
|
|
3083
3090
|
let getOffsetInMsFn;
|
|
3084
3091
|
function useTimezone(timezone) {
|
|
3085
3092
|
getOffsetInMsFn = date => calculateTimezoneOffset(timezone, date);
|
|
3086
3093
|
}
|
|
3087
3094
|
if (config == null || typeof config === 'string') {
|
|
3088
|
-
|
|
3095
|
+
var _config;
|
|
3096
|
+
const timezone = (_config = config) != null ? _config : util.UTC_TIMEZONE_STRING;
|
|
3089
3097
|
config = {
|
|
3090
3098
|
timezone
|
|
3091
3099
|
};
|
|
@@ -3277,7 +3285,7 @@ class DateTimezoneUtcNormalInstance {
|
|
|
3277
3285
|
if (typeof date === 'string') {
|
|
3278
3286
|
return util.parseISO8601DayStringToUTCDate(date);
|
|
3279
3287
|
} else {
|
|
3280
|
-
const startOfDayForSystem = dateFns.startOfDay(date
|
|
3288
|
+
const startOfDayForSystem = dateFns.startOfDay(date != null ? date : new Date());
|
|
3281
3289
|
return this.baseDateToSystemDate(startOfDayForSystem);
|
|
3282
3290
|
}
|
|
3283
3291
|
}
|
|
@@ -3303,7 +3311,7 @@ class DateTimezoneUtcNormalInstance {
|
|
|
3303
3311
|
const utcDate = util.parseISO8601DayStringToUTCDate(date);
|
|
3304
3312
|
return this.systemDateToBaseDate(utcDate);
|
|
3305
3313
|
} else {
|
|
3306
|
-
return dateFns.startOfDay(date
|
|
3314
|
+
return dateFns.startOfDay(date != null ? date : new Date());
|
|
3307
3315
|
}
|
|
3308
3316
|
}
|
|
3309
3317
|
/**
|
|
@@ -3464,6 +3472,7 @@ function startOfDayInTimezoneFromISO8601DayString(day, timezone) {
|
|
|
3464
3472
|
function setOnDateWithTimezoneNormalFunction(timezone) {
|
|
3465
3473
|
const timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
3466
3474
|
const fn = input => {
|
|
3475
|
+
var _copyFrom, _copyFrom2;
|
|
3467
3476
|
const {
|
|
3468
3477
|
date: inputDate,
|
|
3469
3478
|
copyFrom: copyFromInput,
|
|
@@ -3476,7 +3485,7 @@ function setOnDateWithTimezoneNormalFunction(timezone) {
|
|
|
3476
3485
|
roundDownToMinute
|
|
3477
3486
|
} = input;
|
|
3478
3487
|
const DEFAULT_TYPE = 'target';
|
|
3479
|
-
const inputType = inputInputType
|
|
3488
|
+
const inputType = inputInputType != null ? inputInputType : DEFAULT_TYPE;
|
|
3480
3489
|
let baseDate;
|
|
3481
3490
|
let copyFrom;
|
|
3482
3491
|
// set copyFrom
|
|
@@ -3502,8 +3511,8 @@ function setOnDateWithTimezoneNormalFunction(timezone) {
|
|
|
3502
3511
|
} else {
|
|
3503
3512
|
baseDate = new Date();
|
|
3504
3513
|
}
|
|
3505
|
-
const hours = inputHours
|
|
3506
|
-
const minutes = inputMinutes
|
|
3514
|
+
const hours = inputHours != null ? inputHours : copyHours !== false ? (_copyFrom = copyFrom) == null ? void 0 : _copyFrom.getUTCHours() : undefined;
|
|
3515
|
+
const minutes = inputMinutes != null ? inputMinutes : copyMinutes !== false ? (_copyFrom2 = copyFrom) == null ? void 0 : _copyFrom2.getUTCMinutes() : undefined;
|
|
3507
3516
|
// NOTE: We do the math this way to avoid issues surrounding daylight savings
|
|
3508
3517
|
const time = baseDate.getTime();
|
|
3509
3518
|
const currentDayMillseconds = time % util.MS_IN_DAY;
|
|
@@ -3516,7 +3525,7 @@ function setOnDateWithTimezoneNormalFunction(timezone) {
|
|
|
3516
3525
|
const nextHours = hours != null ? hours * util.MS_IN_HOUR : hoursInTimeInMs;
|
|
3517
3526
|
const nextTime = nextDay + nextHours + nextMinutes + (roundDownToMinute ? 0 : secondsAndMilliseconds);
|
|
3518
3527
|
const nextBaseDate = new Date(nextTime);
|
|
3519
|
-
let result = timezoneInstance.convertDate(nextBaseDate, outputType
|
|
3528
|
+
let result = timezoneInstance.convertDate(nextBaseDate, outputType != null ? outputType : inputType, 'base');
|
|
3520
3529
|
// one more test to limit the "range" of the change
|
|
3521
3530
|
// if it is over 1 day, then we can infer there is a timezone mismatch issue. It only occurs in one direction here, so we can safely
|
|
3522
3531
|
// infer that the real valid result can be derived by subtracting one day
|
|
@@ -4036,8 +4045,8 @@ const allTimezoneInfos = util.cachedGetter(() => {
|
|
|
4036
4045
|
return allTimezoneStrings().map(x => timezoneStringToTimezoneInfo(x, now));
|
|
4037
4046
|
});
|
|
4038
4047
|
function timezoneInfoForSystem() {
|
|
4039
|
-
var
|
|
4040
|
-
return timezoneStringToTimezoneInfo((
|
|
4048
|
+
var _guessCurrentTimezone;
|
|
4049
|
+
return timezoneStringToTimezoneInfo((_guessCurrentTimezone = guessCurrentTimezone()) != null ? _guessCurrentTimezone : util.UTC_TIMEZONE_STRING);
|
|
4041
4050
|
}
|
|
4042
4051
|
function getTimezoneAbbreviation(timezone, date = new Date()) {
|
|
4043
4052
|
return timezone === util.UTC_TIMEZONE_STRING ? util.UTC_TIMEZONE_STRING : timezone ? dateFnsTz.formatInTimeZone(date, timezone, 'zzz') : 'UKNOWN';
|
|
@@ -4088,7 +4097,7 @@ function IsKnownTimezone(validationOptions) {
|
|
|
4088
4097
|
options: validationOptions,
|
|
4089
4098
|
validator: {
|
|
4090
4099
|
validate: isKnownTimezone,
|
|
4091
|
-
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args
|
|
4100
|
+
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args == null ? void 0 : args.value}" is not a known timezone.`, validationOptions)
|
|
4092
4101
|
}
|
|
4093
4102
|
});
|
|
4094
4103
|
};
|
|
@@ -4102,7 +4111,7 @@ function IsKnownTimezone(validationOptions) {
|
|
|
4102
4111
|
*/
|
|
4103
4112
|
function fitDateRangeToDayPeriodFunction(timezone) {
|
|
4104
4113
|
const transformFn = transformDateRangeInTimezoneNormalFunction(timezone, 'baseDateToTargetDate');
|
|
4105
|
-
const fn = input => Object.assign(
|
|
4114
|
+
const fn = input => Object.assign({}, input, transformFn(input, fitUTCDateRangeToDayPeriod));
|
|
4106
4115
|
fn._timezoneInstance = transformFn._timezoneInstance;
|
|
4107
4116
|
return fn;
|
|
4108
4117
|
}
|
|
@@ -4275,7 +4284,7 @@ function formatDateRangeDistanceFunction(inputConfig) {
|
|
|
4275
4284
|
timeRangeTimezone,
|
|
4276
4285
|
strict = false
|
|
4277
4286
|
} = inputConfig;
|
|
4278
|
-
const transform = inputTransform
|
|
4287
|
+
const transform = inputTransform != null ? inputTransform : onlyTimeRange ? timeRangeTimezone ? fitDateRangeToDayPeriodFunction(timeRangeTimezone) : fitUTCDateRangeToDayPeriod : util.mapIdentityFunction();
|
|
4279
4288
|
return (startOrDateRange, inputEnd) => {
|
|
4280
4289
|
const dateRange = transform(dateOrDateRangeToDateRange(startOrDateRange, inputEnd));
|
|
4281
4290
|
const {
|
|
@@ -4338,6 +4347,7 @@ function formatToDayTimeRangeString(startOrDateRange, end) {
|
|
|
4338
4347
|
});
|
|
4339
4348
|
}
|
|
4340
4349
|
function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
4350
|
+
var _inputFormat;
|
|
4341
4351
|
let end;
|
|
4342
4352
|
if (endOrFormat != null) {
|
|
4343
4353
|
if (typeof endOrFormat === 'function') {
|
|
@@ -4346,7 +4356,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
4346
4356
|
end = endOrFormat;
|
|
4347
4357
|
}
|
|
4348
4358
|
}
|
|
4349
|
-
const format =
|
|
4359
|
+
const format = (_inputFormat = inputFormat) != null ? _inputFormat : formatToShortDateString;
|
|
4350
4360
|
return formatDateRange(dateOrDateRangeToDateRange(startOrDateRange, end), {
|
|
4351
4361
|
format,
|
|
4352
4362
|
simplifySameDate: true
|
|
@@ -4488,6 +4498,7 @@ function isValidDateCellIndex(input) {
|
|
|
4488
4498
|
}
|
|
4489
4499
|
class DateCell {
|
|
4490
4500
|
constructor(template) {
|
|
4501
|
+
this.i = void 0;
|
|
4491
4502
|
if (template) {
|
|
4492
4503
|
this.i = template.i;
|
|
4493
4504
|
}
|
|
@@ -4512,8 +4523,8 @@ function dateCell(dateCellOrIndex) {
|
|
|
4512
4523
|
* @returns
|
|
4513
4524
|
*/
|
|
4514
4525
|
function dateCellTimingStartsAtForStartOfDay(input = {}) {
|
|
4515
|
-
var
|
|
4516
|
-
const timezone = (
|
|
4526
|
+
var _input$timezone;
|
|
4527
|
+
const timezone = (_input$timezone = input.timezone) != null ? _input$timezone : requireCurrentTimezone();
|
|
4517
4528
|
let startsAt = dateFns.startOfDay(new Date());
|
|
4518
4529
|
if (input.timezone != null) {
|
|
4519
4530
|
startsAt = dateTimezoneUtcNormal(timezone).targetDateToSystemDate(startsAt);
|
|
@@ -4526,6 +4537,8 @@ function dateCellTimingStartsAtForStartOfDay(input = {}) {
|
|
|
4526
4537
|
class DateCellTiming extends DateDurationSpan {
|
|
4527
4538
|
constructor(template) {
|
|
4528
4539
|
super(template);
|
|
4540
|
+
this.end = void 0;
|
|
4541
|
+
this.timezone = void 0;
|
|
4529
4542
|
if (template) {
|
|
4530
4543
|
this.end = template.end;
|
|
4531
4544
|
this.timezone = template.timezone;
|
|
@@ -4830,7 +4843,7 @@ function updateDateCellTimingToTimezoneFunction(timezone) {
|
|
|
4830
4843
|
const {
|
|
4831
4844
|
startsAt
|
|
4832
4845
|
} = timing;
|
|
4833
|
-
const newTiming = Object.assign(
|
|
4846
|
+
const newTiming = Object.assign({}, timing, {
|
|
4834
4847
|
start: dateCellTimingStart({
|
|
4835
4848
|
startsAt,
|
|
4836
4849
|
timezone
|
|
@@ -4885,7 +4898,7 @@ function shiftDateCellTimingToTimezoneFunction(timezoneInput) {
|
|
|
4885
4898
|
const endNormal = inputTimingNormalInstance.baseDateToTargetDate(timing.end);
|
|
4886
4899
|
const startsAt = normalInstance.targetDateToBaseDate(startsAtNormal);
|
|
4887
4900
|
const end = normalInstance.targetDateToBaseDate(endNormal);
|
|
4888
|
-
const newTiming = Object.assign(
|
|
4901
|
+
const newTiming = Object.assign({}, timing, {
|
|
4889
4902
|
start: dateCellTimingStart({
|
|
4890
4903
|
startsAt,
|
|
4891
4904
|
timezone
|
|
@@ -5085,6 +5098,7 @@ function isValidFullDateCellTiming(timing) {
|
|
|
5085
5098
|
class DateCellRange extends DateCell {
|
|
5086
5099
|
constructor(template) {
|
|
5087
5100
|
super(template);
|
|
5101
|
+
this.to = void 0;
|
|
5088
5102
|
if (template) {
|
|
5089
5103
|
this.to = template.to;
|
|
5090
5104
|
}
|
|
@@ -5152,8 +5166,8 @@ function isValidDateCellRangeSeries(input) {
|
|
|
5152
5166
|
* The input range is not expected to be sorted.
|
|
5153
5167
|
*/
|
|
5154
5168
|
function getLeastDateCellIndexInDateCellRanges(input) {
|
|
5155
|
-
var
|
|
5156
|
-
return (
|
|
5169
|
+
var _getLeastAndGreatestD, _getLeastAndGreatestD2;
|
|
5170
|
+
return (_getLeastAndGreatestD = (_getLeastAndGreatestD2 = getLeastAndGreatestDateCellIndexInDateCellRanges(input)) == null ? void 0 : _getLeastAndGreatestD2.leastIndex) != null ? _getLeastAndGreatestD : 0;
|
|
5157
5171
|
}
|
|
5158
5172
|
/**
|
|
5159
5173
|
* Returns the largest index between all the input date block ranges. Returns 0 by default.
|
|
@@ -5161,8 +5175,8 @@ function getLeastDateCellIndexInDateCellRanges(input) {
|
|
|
5161
5175
|
* The input range is not expected to be sorted.
|
|
5162
5176
|
*/
|
|
5163
5177
|
function getGreatestDateCellIndexInDateCellRanges(input) {
|
|
5164
|
-
var
|
|
5165
|
-
return (
|
|
5178
|
+
var _getLeastAndGreatestD3, _getLeastAndGreatestD4;
|
|
5179
|
+
return (_getLeastAndGreatestD3 = (_getLeastAndGreatestD4 = getLeastAndGreatestDateCellIndexInDateCellRanges(input)) == null ? void 0 : _getLeastAndGreatestD4.greatestIndex) != null ? _getLeastAndGreatestD3 : 0;
|
|
5166
5180
|
}
|
|
5167
5181
|
/**
|
|
5168
5182
|
* Returns the largest index between all the input date block ranges. Returns null if the input is empty.
|
|
@@ -5207,7 +5221,7 @@ function getLeastAndGreatestDateCellIndexInDateCellRanges(input) {
|
|
|
5207
5221
|
function dateCellRange(i, to) {
|
|
5208
5222
|
return {
|
|
5209
5223
|
i,
|
|
5210
|
-
to: to
|
|
5224
|
+
to: to != null ? to : i
|
|
5211
5225
|
};
|
|
5212
5226
|
}
|
|
5213
5227
|
/**
|
|
@@ -5244,9 +5258,9 @@ function dateCellRangeIncludedByRangeFunction(inputRange) {
|
|
|
5244
5258
|
to
|
|
5245
5259
|
} = dateCellRangeWithRange(inputRange);
|
|
5246
5260
|
return input => {
|
|
5247
|
-
var
|
|
5261
|
+
var _range$to;
|
|
5248
5262
|
const range = dateCellRangeWithRange(input);
|
|
5249
|
-
return range.i <= i && ((
|
|
5263
|
+
return range.i <= i && ((_range$to = range == null ? void 0 : range.to) != null ? _range$to : range.i) >= to;
|
|
5250
5264
|
};
|
|
5251
5265
|
}
|
|
5252
5266
|
/**
|
|
@@ -5261,9 +5275,9 @@ function dateCellRangeOverlapsRangeFunction(inputRange) {
|
|
|
5261
5275
|
to
|
|
5262
5276
|
} = dateCellRangeWithRange(inputRange);
|
|
5263
5277
|
return input => {
|
|
5264
|
-
var
|
|
5278
|
+
var _range$to2;
|
|
5265
5279
|
const range = dateCellRangeWithRange(input);
|
|
5266
|
-
return range.i <= to && ((
|
|
5280
|
+
return range.i <= to && ((_range$to2 = range == null ? void 0 : range.to) != null ? _range$to2 : range.i) >= i;
|
|
5267
5281
|
};
|
|
5268
5282
|
}
|
|
5269
5283
|
/**
|
|
@@ -5285,8 +5299,8 @@ function dateCellRangeOverlapsRange(rangeA, rangeB) {
|
|
|
5285
5299
|
*/
|
|
5286
5300
|
function sortDateCellRangeAndSizeFunction() {
|
|
5287
5301
|
return (a, b) => {
|
|
5288
|
-
var _a, _b;
|
|
5289
|
-
return a.i - b.i || ((_a = a.to)
|
|
5302
|
+
var _a$to, _b$to;
|
|
5303
|
+
return a.i - b.i || ((_a$to = a.to) != null ? _a$to : a.i) - ((_b$to = b.to) != null ? _b$to : b.i);
|
|
5290
5304
|
};
|
|
5291
5305
|
}
|
|
5292
5306
|
/**
|
|
@@ -5304,7 +5318,6 @@ function sortDateCellRanges(input) {
|
|
|
5304
5318
|
* @param input
|
|
5305
5319
|
*/
|
|
5306
5320
|
function groupToDateCellRanges(input) {
|
|
5307
|
-
var _a;
|
|
5308
5321
|
if (input.length === 0) {
|
|
5309
5322
|
return [];
|
|
5310
5323
|
}
|
|
@@ -5317,7 +5330,7 @@ function groupToDateCellRanges(input) {
|
|
|
5317
5330
|
} = blocks[blocksArrayIndex];
|
|
5318
5331
|
return {
|
|
5319
5332
|
i,
|
|
5320
|
-
to: to
|
|
5333
|
+
to: to != null ? to : i
|
|
5321
5334
|
};
|
|
5322
5335
|
}
|
|
5323
5336
|
// start at the first block
|
|
@@ -5327,8 +5340,9 @@ function groupToDateCellRanges(input) {
|
|
|
5327
5340
|
const block = blocks[i];
|
|
5328
5341
|
const isContinuous = block.i <= current.to + 1;
|
|
5329
5342
|
if (isContinuous) {
|
|
5343
|
+
var _blocks$i$to;
|
|
5330
5344
|
// extend the current block.
|
|
5331
|
-
current.to = (
|
|
5345
|
+
current.to = (_blocks$i$to = blocks[i].to) != null ? _blocks$i$to : blocks[i].i;
|
|
5332
5346
|
} else {
|
|
5333
5347
|
// complete/create new block.
|
|
5334
5348
|
results.push(current);
|
|
@@ -5385,14 +5399,14 @@ function filterDateCellsInDateCellRange(blocks, range) {
|
|
|
5385
5399
|
function isDateCellWithinDateCellRangeFunction(inputRange) {
|
|
5386
5400
|
const range = dateCellRangeWithRange(inputRange);
|
|
5387
5401
|
return input => {
|
|
5388
|
-
var _a;
|
|
5389
5402
|
if (typeof input === 'number') {
|
|
5390
5403
|
input = {
|
|
5391
5404
|
i: input
|
|
5392
5405
|
};
|
|
5393
5406
|
}
|
|
5394
5407
|
if (input.i >= range.i) {
|
|
5395
|
-
|
|
5408
|
+
var _input$to;
|
|
5409
|
+
const to = (_input$to = input.to) != null ? _input$to : input.i;
|
|
5396
5410
|
return to <= range.to;
|
|
5397
5411
|
}
|
|
5398
5412
|
return false;
|
|
@@ -5458,7 +5472,7 @@ function dateCellRangesFullyCoverDateCellRangeFunction(ranges) {
|
|
|
5458
5472
|
* @param input
|
|
5459
5473
|
*/
|
|
5460
5474
|
function getNextDateCellTimingIndex(input) {
|
|
5461
|
-
var
|
|
5475
|
+
var _relativeStateGroups$, _relativeStateGroups$2, _relativeStateGroups$3;
|
|
5462
5476
|
const {
|
|
5463
5477
|
ranges,
|
|
5464
5478
|
currentIndex
|
|
@@ -5466,9 +5480,9 @@ function getNextDateCellTimingIndex(input) {
|
|
|
5466
5480
|
const relativeStateGroups = util.makeValuesGroupMap(util.asArray(ranges), range => {
|
|
5467
5481
|
return dateRelativeStateForDateCellRangeComparedToIndex(range, currentIndex);
|
|
5468
5482
|
});
|
|
5469
|
-
const pastResults = (
|
|
5470
|
-
const presentResults = (
|
|
5471
|
-
const futureResults = (
|
|
5483
|
+
const pastResults = (_relativeStateGroups$ = relativeStateGroups.get('past')) != null ? _relativeStateGroups$ : [];
|
|
5484
|
+
const presentResults = (_relativeStateGroups$2 = relativeStateGroups.get('present')) != null ? _relativeStateGroups$2 : [];
|
|
5485
|
+
const futureResults = (_relativeStateGroups$3 = relativeStateGroups.get('future')) != null ? _relativeStateGroups$3 : [];
|
|
5472
5486
|
const currentResult = presentResults[0];
|
|
5473
5487
|
let nextResult;
|
|
5474
5488
|
let nextIndex = currentIndex + 1;
|
|
@@ -5523,7 +5537,7 @@ function dateRelativeStateForDateCellRangeComparedToIndex(range, nowIndex) {
|
|
|
5523
5537
|
*/
|
|
5524
5538
|
function expandDateCellRange(block) {
|
|
5525
5539
|
return util.range(block.i, dateCellEndIndex(block) + 1).map(i => {
|
|
5526
|
-
return Object.assign(
|
|
5540
|
+
return Object.assign({}, block, {
|
|
5527
5541
|
i,
|
|
5528
5542
|
to: i
|
|
5529
5543
|
}); // copy block, set to as i
|
|
@@ -5544,22 +5558,22 @@ function dateCellRangeHasRange(input) {
|
|
|
5544
5558
|
* @returns
|
|
5545
5559
|
*/
|
|
5546
5560
|
function dateCellEndIndex(input) {
|
|
5547
|
-
var
|
|
5548
|
-
return (
|
|
5561
|
+
var _input$to2;
|
|
5562
|
+
return (_input$to2 = input.to) != null ? _input$to2 : input.i;
|
|
5549
5563
|
}
|
|
5550
5564
|
/**
|
|
5551
5565
|
* Groups all input DateCellRange or UniqueDateCell values into a UniqueDateCellRangeGroup value amd sorts the input.
|
|
5552
5566
|
*/
|
|
5553
5567
|
function groupUniqueDateCells(input) {
|
|
5554
|
-
var _a;
|
|
5555
5568
|
const blocks = sortDateCellRanges([...input]);
|
|
5556
5569
|
const i = 0;
|
|
5557
5570
|
let to;
|
|
5558
5571
|
if (blocks.length === 0) {
|
|
5559
5572
|
to = i;
|
|
5560
5573
|
} else {
|
|
5574
|
+
var _lastBlock$to;
|
|
5561
5575
|
const lastBlock = util.lastValue(blocks);
|
|
5562
|
-
to = (
|
|
5576
|
+
to = (_lastBlock$to = lastBlock.to) != null ? _lastBlock$to : lastBlock.i;
|
|
5563
5577
|
}
|
|
5564
5578
|
return {
|
|
5565
5579
|
i,
|
|
@@ -5575,8 +5589,8 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5575
5589
|
fillFactory: inputFillFactory,
|
|
5576
5590
|
retainOnOverlap: inputRetainOnOverlap
|
|
5577
5591
|
} = config;
|
|
5578
|
-
const retainOnOverlap = inputRetainOnOverlap
|
|
5579
|
-
const maxAllowedIndex = endAtIndex
|
|
5592
|
+
const retainOnOverlap = inputRetainOnOverlap != null ? inputRetainOnOverlap : 'next';
|
|
5593
|
+
const maxAllowedIndex = endAtIndex != null ? endAtIndex : Number.MAX_SAFE_INTEGER;
|
|
5580
5594
|
const fillFactory = inputFillFactory;
|
|
5581
5595
|
if (!fillFactory && fill === 'fill') {
|
|
5582
5596
|
throw new Error('fillFactory is required when fillOption is "fill".');
|
|
@@ -5613,7 +5627,7 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5613
5627
|
const to = Math.min(inputTo, maxAllowedIndex) || 0;
|
|
5614
5628
|
let block = null;
|
|
5615
5629
|
if (inputBlock != null) {
|
|
5616
|
-
block = Object.assign(
|
|
5630
|
+
block = Object.assign({}, inputBlock, {
|
|
5617
5631
|
i,
|
|
5618
5632
|
to
|
|
5619
5633
|
});
|
|
@@ -5636,7 +5650,7 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5636
5650
|
to
|
|
5637
5651
|
};
|
|
5638
5652
|
const block = fillFactory(dateCellRange);
|
|
5639
|
-
addBlockWithRange(block, i, to
|
|
5653
|
+
addBlockWithRange(block, i, to != null ? to : i);
|
|
5640
5654
|
} else if (fill === 'empty') ; else if (blocks.length > 0) {
|
|
5641
5655
|
// only extend if one or more blocks have been pushed
|
|
5642
5656
|
const blockToExtend = util.lastValue(blocks);
|
|
@@ -5719,7 +5733,7 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5719
5733
|
// add current
|
|
5720
5734
|
addBlockWithRange(current.block, currentNextIndex, currentEndIndex);
|
|
5721
5735
|
// change next to start at the next range
|
|
5722
|
-
continueToNext(Object.assign(
|
|
5736
|
+
continueToNext(Object.assign({}, next.block, {
|
|
5723
5737
|
i: currentEndIndex + 1,
|
|
5724
5738
|
to: nextEndIndex
|
|
5725
5739
|
}), next.priority);
|
|
@@ -5739,7 +5753,7 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5739
5753
|
// add the next item first since it overwrites the current
|
|
5740
5754
|
addBlockWithRange(next.block, nextStartIndex, nextEndIndex);
|
|
5741
5755
|
// continue with the current item as next.
|
|
5742
|
-
continueToNext(Object.assign(
|
|
5756
|
+
continueToNext(Object.assign({}, current.block, {
|
|
5743
5757
|
i: nextEndIndex + 1,
|
|
5744
5758
|
to: currentEndIndex
|
|
5745
5759
|
}), current.priority);
|
|
@@ -5754,7 +5768,7 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5754
5768
|
addBlockWithRange(current.block, currentNextIndex, currentEndIndex);
|
|
5755
5769
|
if (nextEndIndex > currentEndIndex) {
|
|
5756
5770
|
// change next to start at the next range
|
|
5757
|
-
continueToNext(Object.assign(
|
|
5771
|
+
continueToNext(Object.assign({}, next.block, {
|
|
5758
5772
|
i: currentEndIndex + 1,
|
|
5759
5773
|
to: nextEndIndex
|
|
5760
5774
|
}), next.priority);
|
|
@@ -5770,7 +5784,7 @@ function expandUniqueDateCellsFunction(config) {
|
|
|
5770
5784
|
// add the next
|
|
5771
5785
|
addBlockWithRange(next.block, nextStartIndex, nextEndIndex);
|
|
5772
5786
|
// continue with the current
|
|
5773
|
-
continueToNext(Object.assign(
|
|
5787
|
+
continueToNext(Object.assign({}, current.block, {
|
|
5774
5788
|
i: nextEndIndex + 1,
|
|
5775
5789
|
to: currentEndIndex
|
|
5776
5790
|
}), next.priority);
|
|
@@ -5824,7 +5838,7 @@ function dateCellRangeOfTimingFactory(config) {
|
|
|
5824
5838
|
limitToCompletedIndexes: onlyIncludeIfComplete = false,
|
|
5825
5839
|
now: inputNowGetter
|
|
5826
5840
|
} = config;
|
|
5827
|
-
const nowGetter = util.asGetter(inputNowGetter
|
|
5841
|
+
const nowGetter = util.asGetter(inputNowGetter != null ? inputNowGetter : () => new Date());
|
|
5828
5842
|
const indexFactory = dateCellTimingRelativeIndexFactory(timing);
|
|
5829
5843
|
const minIndex = fitToTimingRange ? 0 : Number.MIN_SAFE_INTEGER;
|
|
5830
5844
|
const maxIndex = fitToTimingRange ? indexFactory(indexFactory._timing.end) : Number.MAX_SAFE_INTEGER;
|
|
@@ -5867,9 +5881,9 @@ function dateCellRangeOfTimingFactory(config) {
|
|
|
5867
5881
|
const {
|
|
5868
5882
|
i: start,
|
|
5869
5883
|
to: end
|
|
5870
|
-
} = input
|
|
5871
|
-
const startIndex = indexFactory(start
|
|
5872
|
-
const endIndex = indexFactory(end
|
|
5884
|
+
} = input != null ? input : {};
|
|
5885
|
+
const startIndex = indexFactory(start != null ? start : 0);
|
|
5886
|
+
const endIndex = indexFactory(end != null ? end : nowGetter());
|
|
5873
5887
|
const maxIndex = getCurrentMaxIndex();
|
|
5874
5888
|
const to = Math.min(maxIndex, endIndex); // calculate to first to get the max value
|
|
5875
5889
|
const i = Math.min(Math.max(minIndex, startIndex), to); // i should never be greater than to
|
|
@@ -5899,11 +5913,11 @@ function dateCellRangeOfTiming(config, input) {
|
|
|
5899
5913
|
* By default fitToTimingRange is true.
|
|
5900
5914
|
*/
|
|
5901
5915
|
function dateCellTimingCompletedTimeRange(timing, config) {
|
|
5902
|
-
var
|
|
5916
|
+
var _config$fitToTimingRa;
|
|
5903
5917
|
return dateCellRangeOfTiming({
|
|
5904
5918
|
timing,
|
|
5905
|
-
now: config
|
|
5906
|
-
fitToTimingRange: (
|
|
5919
|
+
now: config == null ? void 0 : config.now,
|
|
5920
|
+
fitToTimingRange: (_config$fitToTimingRa = config == null ? void 0 : config.fitToTimingRange) != null ? _config$fitToTimingRa : true,
|
|
5907
5921
|
limitToCompletedIndexes: true
|
|
5908
5922
|
});
|
|
5909
5923
|
}
|
|
@@ -5921,10 +5935,10 @@ function dateCellTimingLatestCompletedIndex(timing, now) {
|
|
|
5921
5935
|
}).to;
|
|
5922
5936
|
}
|
|
5923
5937
|
function dateCellRangeToDateCellIndexRange(range) {
|
|
5924
|
-
var
|
|
5938
|
+
var _range$to;
|
|
5925
5939
|
return {
|
|
5926
5940
|
minIndex: range.i,
|
|
5927
|
-
maxIndex: ((
|
|
5941
|
+
maxIndex: ((_range$to = range.to) != null ? _range$to : range.i) + 1
|
|
5928
5942
|
};
|
|
5929
5943
|
}
|
|
5930
5944
|
function dateCellIndexRangeToDateCellRange(range) {
|
|
@@ -6018,7 +6032,7 @@ function dateCellTimingExpansionFactory(config) {
|
|
|
6018
6032
|
});
|
|
6019
6033
|
const filter = util.mergeFilterFunctions(x => isInRange(x.i), inputFilter);
|
|
6020
6034
|
const startsAtFactory = dateCellTimingStartsAtDateFactory(timing);
|
|
6021
|
-
const durationSpanFilter = inputDurationSpanFilter
|
|
6035
|
+
const durationSpanFilter = inputDurationSpanFilter != null ? inputDurationSpanFilter : () => true;
|
|
6022
6036
|
return input => {
|
|
6023
6037
|
const blocks = Array.isArray(input) ? input : input.blocks;
|
|
6024
6038
|
const spans = [];
|
|
@@ -6028,7 +6042,7 @@ function dateCellTimingExpansionFactory(config) {
|
|
|
6028
6042
|
blocksEvaluated += 1;
|
|
6029
6043
|
if (filter(block, blockIndex)) {
|
|
6030
6044
|
const startsAt = startsAtFactory(block.i);
|
|
6031
|
-
const durationSpan = Object.assign(
|
|
6045
|
+
const durationSpan = Object.assign({}, block, {
|
|
6032
6046
|
startsAt,
|
|
6033
6047
|
duration
|
|
6034
6048
|
});
|
|
@@ -6046,7 +6060,7 @@ function dateCellTimingExpansionFactory(config) {
|
|
|
6046
6060
|
if (dateCellRangeHasRange(block)) {
|
|
6047
6061
|
// Expands the block's range as if it is at a single index
|
|
6048
6062
|
util.range(block.i, block.to + 1).findIndex(i => {
|
|
6049
|
-
const blockAtIndex = Object.assign(
|
|
6063
|
+
const blockAtIndex = Object.assign({}, block, {
|
|
6050
6064
|
i,
|
|
6051
6065
|
to: i
|
|
6052
6066
|
}); // copy block, set to as i
|
|
@@ -6086,7 +6100,7 @@ function dateCellDayTimingInfoFactory(config) {
|
|
|
6086
6100
|
const date = typeof input === 'number' ? dayFactory(input) : input;
|
|
6087
6101
|
const dayIndex = indexFactory(input);
|
|
6088
6102
|
const isInRange = checkIsInRange(dayIndex);
|
|
6089
|
-
const now = inputNow
|
|
6103
|
+
const now = inputNow != null ? inputNow : date;
|
|
6090
6104
|
const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
|
|
6091
6105
|
const endsAtOnDay = dateFns.addMinutes(startsAtOnDay, duration);
|
|
6092
6106
|
const potentiallyInProgress = !dateFns.isAfter(startsAtOnDay, now); // is potentially in progress if the now is equal-to or after the start time.
|
|
@@ -6191,13 +6205,13 @@ function dateCellTimingRelativeIndexArrayFactory(indexFactory) {
|
|
|
6191
6205
|
const inputAsArray = util.asArray(input);
|
|
6192
6206
|
const result = [];
|
|
6193
6207
|
inputAsArray.forEach(value => {
|
|
6194
|
-
var _a;
|
|
6195
6208
|
let resultIndexes;
|
|
6196
6209
|
if (typeof value === 'object' && !util.isDate(value)) {
|
|
6197
6210
|
if (isDateRange(value)) {
|
|
6198
6211
|
resultIndexes = util.range(indexFactory(value.start), indexFactory(value.end) + 1);
|
|
6199
6212
|
} else {
|
|
6200
|
-
|
|
6213
|
+
var _value$to;
|
|
6214
|
+
resultIndexes = util.range(value.i, ((_value$to = value.to) != null ? _value$to : value.i) + 1);
|
|
6201
6215
|
}
|
|
6202
6216
|
} else {
|
|
6203
6217
|
resultIndexes = [indexFactory(value)];
|
|
@@ -6235,7 +6249,7 @@ function dateCellTimingDateFactory(timing) {
|
|
|
6235
6249
|
if (util.isDate(input)) {
|
|
6236
6250
|
return input;
|
|
6237
6251
|
} else {
|
|
6238
|
-
const now = inputNow
|
|
6252
|
+
const now = inputNow != null ? inputNow : new Date();
|
|
6239
6253
|
const nowHours = now.getUTCHours();
|
|
6240
6254
|
const utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
|
|
6241
6255
|
// 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.
|
|
@@ -6534,7 +6548,7 @@ function modifyDateCellsToFitRangeFunction(range) {
|
|
|
6534
6548
|
const asRange = dateCellRangeWithRange(x);
|
|
6535
6549
|
const rangesOverlap = overlapsRange(asRange);
|
|
6536
6550
|
if (rangesOverlap) {
|
|
6537
|
-
result = Object.assign(
|
|
6551
|
+
result = Object.assign({}, x, {
|
|
6538
6552
|
i: Math.max(i, asRange.i),
|
|
6539
6553
|
to: Math.min(to, asRange.to) // should be no larger than to
|
|
6540
6554
|
});
|
|
@@ -6649,7 +6663,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6649
6663
|
* @returns
|
|
6650
6664
|
*/
|
|
6651
6665
|
function yearWeekCodeFactory(config) {
|
|
6652
|
-
const normal = yearWeekCodeDateTimezoneInstance(config
|
|
6666
|
+
const normal = yearWeekCodeDateTimezoneInstance(config == null ? void 0 : config.timezone);
|
|
6653
6667
|
const result = (dateOrYear, inputWeek) => {
|
|
6654
6668
|
let pair;
|
|
6655
6669
|
if (isDate(dateOrYear)) {
|
|
@@ -6752,7 +6766,7 @@ function yearWeekCodeForCalendarMonthFactory(factory = yearWeekCodeFactory()) {
|
|
|
6752
6766
|
* @returns
|
|
6753
6767
|
*/
|
|
6754
6768
|
function yearWeekCodeDateFactory(config) {
|
|
6755
|
-
const normal = yearWeekCodeDateTimezoneInstance(config
|
|
6769
|
+
const normal = yearWeekCodeDateTimezoneInstance(config == null ? void 0 : config.timezone);
|
|
6756
6770
|
return yearWeekCode => {
|
|
6757
6771
|
const pair = yearWeekCodePair(yearWeekCode);
|
|
6758
6772
|
const utcYearDate = new Date(Date.UTC(pair.year, 0, 1, 0, 0, 0, 0));
|
|
@@ -7061,7 +7075,7 @@ function rawDateCellScheduleDayCodes(input) {
|
|
|
7061
7075
|
* @returns
|
|
7062
7076
|
*/
|
|
7063
7077
|
function dateCellScheduleDayCodeFactory(config) {
|
|
7064
|
-
const normal = yearWeekCodeDateTimezoneInstance(config
|
|
7078
|
+
const normal = yearWeekCodeDateTimezoneInstance(config == null ? void 0 : config.timezone);
|
|
7065
7079
|
return date => {
|
|
7066
7080
|
const target = normal.systemDateToTargetDate(date);
|
|
7067
7081
|
const day = dateFns.getDay(target);
|
|
@@ -7094,15 +7108,18 @@ function isDateCellSchedule(input) {
|
|
|
7094
7108
|
return false;
|
|
7095
7109
|
}
|
|
7096
7110
|
function isSameDateCellSchedule(a, b) {
|
|
7097
|
-
var _a, _b, _c, _d;
|
|
7098
7111
|
if (a && b) {
|
|
7099
|
-
|
|
7112
|
+
var _a$ex, _b$ex, _a$d, _b$d;
|
|
7113
|
+
return a.w === b.w && util.iterablesAreSetEquivalent((_a$ex = a.ex) != null ? _a$ex : [], (_b$ex = b.ex) != null ? _b$ex : []) && util.iterablesAreSetEquivalent((_a$d = a.d) != null ? _a$d : [], (_b$d = b.d) != null ? _b$d : []);
|
|
7100
7114
|
} else {
|
|
7101
7115
|
return a == b;
|
|
7102
7116
|
}
|
|
7103
7117
|
}
|
|
7104
7118
|
class DateCellSchedule {
|
|
7105
7119
|
constructor(template) {
|
|
7120
|
+
this.w = void 0;
|
|
7121
|
+
this.d = void 0;
|
|
7122
|
+
this.ex = void 0;
|
|
7106
7123
|
if (template) {
|
|
7107
7124
|
this.w = template.w;
|
|
7108
7125
|
this.d = template.d;
|
|
@@ -7180,7 +7197,7 @@ function dateCellScheduleDateRange(input) {
|
|
|
7180
7197
|
end: inputEnd,
|
|
7181
7198
|
timezone: inputTimezone
|
|
7182
7199
|
} = input;
|
|
7183
|
-
const timezone = inputTimezone
|
|
7200
|
+
const timezone = inputTimezone != null ? inputTimezone : requireCurrentTimezone(); // treat input as the current timezone
|
|
7184
7201
|
const normalInstance = dateTimezoneUtcNormal(timezone);
|
|
7185
7202
|
let start;
|
|
7186
7203
|
let end;
|
|
@@ -7198,7 +7215,7 @@ function dateCellScheduleDateRange(input) {
|
|
|
7198
7215
|
}
|
|
7199
7216
|
}
|
|
7200
7217
|
// set the end value
|
|
7201
|
-
end = inputEnd
|
|
7218
|
+
end = inputEnd != null ? inputEnd : dateFns.addMinutes(start, 1); // default the end to one minute after the start
|
|
7202
7219
|
return {
|
|
7203
7220
|
w,
|
|
7204
7221
|
ex,
|
|
@@ -7313,8 +7330,8 @@ function fullDateCellScheduleRange(input) {
|
|
|
7313
7330
|
} else {
|
|
7314
7331
|
// fill in the blanks for the date range
|
|
7315
7332
|
const initialDateRange = dateCellScheduleDateRange(dateCellScheduleRange);
|
|
7316
|
-
initialDateRange.startsAt = inputStartsAt
|
|
7317
|
-
initialDateRange.duration = inputDuration
|
|
7333
|
+
initialDateRange.startsAt = inputStartsAt != null ? inputStartsAt : initialDateRange.start;
|
|
7334
|
+
initialDateRange.duration = inputDuration != null ? inputDuration : DEFAULT_FULL_DATE_SCHEDULE_RANGE_DURATION; // copy duration and startsAt
|
|
7318
7335
|
initialFullDateRange = initialDateRange;
|
|
7319
7336
|
if (isDateCellScheduleStartOfDayDateRange(dateCellScheduleRange)) {
|
|
7320
7337
|
const startOfLastDay = initialFullDateRange.end;
|
|
@@ -7328,8 +7345,8 @@ function fullDateCellScheduleRange(input) {
|
|
|
7328
7345
|
fullDateCellTiming = updateDateCellTimingWithDateCellTimingEvent({
|
|
7329
7346
|
timing: initialFullDateRange,
|
|
7330
7347
|
event: {
|
|
7331
|
-
startsAt: inputDefaultStartsAtTime
|
|
7332
|
-
duration: inputDefaultDuration
|
|
7348
|
+
startsAt: inputDefaultStartsAtTime != null ? inputDefaultStartsAtTime : initialFullDateRange.startsAt,
|
|
7349
|
+
duration: inputDefaultDuration != null ? inputDefaultDuration : initialFullDateRange.duration
|
|
7333
7350
|
},
|
|
7334
7351
|
// flag to replace the necessary items
|
|
7335
7352
|
replaceStartsAt: needsStartsAtAdjustment,
|
|
@@ -7378,10 +7395,10 @@ function dateCellScheduleDateFilter(config) {
|
|
|
7378
7395
|
setStartAsMinDate = true,
|
|
7379
7396
|
minMaxDateRange
|
|
7380
7397
|
} = config;
|
|
7381
|
-
const timezone = inputTimezone
|
|
7398
|
+
const timezone = inputTimezone != null ? inputTimezone : requireCurrentTimezone(); // if the timezone is not provided, assume the startsAt is a system timezone normal.
|
|
7382
7399
|
const normalInstance = dateTimezoneUtcNormal(timezone);
|
|
7383
7400
|
// derive the startsAt time for the range. If not provided, defaults to inputStart, or midnight today in the target timezone.
|
|
7384
|
-
const startsAt = inputStartsAt != null ? inputStartsAt : inputStart
|
|
7401
|
+
const startsAt = inputStartsAt != null ? inputStartsAt : inputStart != null ? inputStart : normalInstance.startOfDayInTargetTimezone();
|
|
7385
7402
|
const allowedDays = expandDateCellScheduleDayCodesToDayOfWeekSet(w);
|
|
7386
7403
|
const startsAtInSystem = normalInstance.systemDateToTargetDate(startsAt); // convert to the system date
|
|
7387
7404
|
const firstDateDay = dateFns.getDay(startsAtInSystem);
|
|
@@ -7403,8 +7420,8 @@ function dateCellScheduleDateFilter(config) {
|
|
|
7403
7420
|
end = expectedFinalStartsAt;
|
|
7404
7421
|
}
|
|
7405
7422
|
const indexFloor = setStartAsMinDate ? 0 : Number.MIN_SAFE_INTEGER;
|
|
7406
|
-
const minAllowedIndex = (minMaxDateRange
|
|
7407
|
-
const maxAllowedIndex = end != null ? _dateCellTimingRelativeIndexFactory(end) : (minMaxDateRange
|
|
7423
|
+
const minAllowedIndex = (minMaxDateRange == null ? void 0 : minMaxDateRange.start) != null ? Math.max(indexFloor, _dateCellTimingRelativeIndexFactory(minMaxDateRange.start)) : indexFloor; // start date should be the min inde
|
|
7424
|
+
const maxAllowedIndex = end != null ? _dateCellTimingRelativeIndexFactory(end) : (minMaxDateRange == null ? void 0 : minMaxDateRange.end) != null ? _dateCellTimingRelativeIndexFactory(minMaxDateRange.end) : Number.MAX_SAFE_INTEGER; // max "to" value
|
|
7408
7425
|
const includedIndexes = new Set(config.d);
|
|
7409
7426
|
const excludedIndexes = new Set(config.ex);
|
|
7410
7427
|
const fn = input => {
|
|
@@ -7567,7 +7584,7 @@ function expandDateCellScheduleRange(input) {
|
|
|
7567
7584
|
startsAtTime,
|
|
7568
7585
|
updateWithDefaults: true
|
|
7569
7586
|
});
|
|
7570
|
-
return expandDateCellSchedule(Object.assign(
|
|
7587
|
+
return expandDateCellSchedule(Object.assign({}, input, {
|
|
7571
7588
|
schedule: fullDateRange,
|
|
7572
7589
|
timing: fullDateRange
|
|
7573
7590
|
}));
|
|
@@ -7599,7 +7616,7 @@ function IsValidDateCellTiming(validationOptions) {
|
|
|
7599
7616
|
options: validationOptions,
|
|
7600
7617
|
validator: {
|
|
7601
7618
|
validate: isValidDateCellTiming,
|
|
7602
|
-
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${JSON.stringify(args
|
|
7619
|
+
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${JSON.stringify(args == null ? void 0 : args.value)}" is not a valid DateCellTiming.`, validationOptions)
|
|
7603
7620
|
}
|
|
7604
7621
|
});
|
|
7605
7622
|
};
|
|
@@ -7616,7 +7633,7 @@ function IsValidDateCellRange(validationOptions) {
|
|
|
7616
7633
|
options: validationOptions,
|
|
7617
7634
|
validator: {
|
|
7618
7635
|
validate: isValidDateCellRange,
|
|
7619
|
-
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${JSON.stringify(args
|
|
7636
|
+
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${JSON.stringify(args == null ? void 0 : args.value)}" is not a valid DateCellRange.`, validationOptions)
|
|
7620
7637
|
}
|
|
7621
7638
|
});
|
|
7622
7639
|
};
|
|
@@ -7633,7 +7650,7 @@ function IsValidDateCellRangeSeries(validationOptions) {
|
|
|
7633
7650
|
options: validationOptions,
|
|
7634
7651
|
validator: {
|
|
7635
7652
|
validate: isValidDateCellRangeSeries,
|
|
7636
|
-
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${JSON.stringify(args
|
|
7653
|
+
defaultMessage: classValidator.buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${JSON.stringify(args == null ? void 0 : args.value)}" is not a valid DateCellRange series. Items must be sorted in ascending order and have no repeat indexes.`, validationOptions)
|
|
7637
7654
|
}
|
|
7638
7655
|
});
|
|
7639
7656
|
};
|
|
@@ -7667,7 +7684,7 @@ class CalendarDate extends DateDurationSpan {
|
|
|
7667
7684
|
}
|
|
7668
7685
|
__decorate([classTransformer.Expose(), classValidator.IsEnum(exports.CalendarDateType), __metadata("design:type", String)], CalendarDate.prototype, "type", void 0);
|
|
7669
7686
|
function calendarDateFactory(config) {
|
|
7670
|
-
const normalConfig = (config
|
|
7687
|
+
const normalConfig = (config == null ? void 0 : config.timezone) === undefined ? {
|
|
7671
7688
|
useSystemTimezone: true
|
|
7672
7689
|
} : {
|
|
7673
7690
|
timezone: config.timezone ? config.timezone : undefined
|
|
@@ -7722,7 +7739,7 @@ function roundDateTimeDownToSteps(date, round) {
|
|
|
7722
7739
|
roundToSteps = true
|
|
7723
7740
|
} = round;
|
|
7724
7741
|
if (roundToSteps) {
|
|
7725
|
-
date = roundToMinuteSteps(date, step
|
|
7742
|
+
date = roundToMinuteSteps(date, step != null ? step : 1);
|
|
7726
7743
|
}
|
|
7727
7744
|
return roundDateTimeDown(date, round);
|
|
7728
7745
|
}
|
|
@@ -7733,13 +7750,13 @@ function roundDateTimeDown(date, round) {
|
|
|
7733
7750
|
} = round;
|
|
7734
7751
|
let rounding = {};
|
|
7735
7752
|
if (roundDownToMinute) {
|
|
7736
|
-
rounding = Object.assign(
|
|
7753
|
+
rounding = Object.assign({}, rounding, {
|
|
7737
7754
|
seconds: 0,
|
|
7738
7755
|
milliseconds: 0
|
|
7739
7756
|
});
|
|
7740
7757
|
}
|
|
7741
7758
|
if (roundDownToDay) {
|
|
7742
|
-
rounding = Object.assign(
|
|
7759
|
+
rounding = Object.assign({}, rounding, {
|
|
7743
7760
|
hours: 0,
|
|
7744
7761
|
minutes: 0
|
|
7745
7762
|
});
|
|
@@ -7786,7 +7803,7 @@ function dateInterval(config) {
|
|
|
7786
7803
|
if (!logicalDate && !inputFactory) {
|
|
7787
7804
|
logicalDate = 'now';
|
|
7788
7805
|
}
|
|
7789
|
-
const intervalPeriod = period
|
|
7806
|
+
const intervalPeriod = period != null ? period : util.MS_IN_SECOND;
|
|
7790
7807
|
const factory = inputFactory ? inputFactory : util.protectedFactory(logicalDateStringCodeDateFactory(logicalDate));
|
|
7791
7808
|
let obs = rxjs.interval(intervalPeriod, scheduler).pipe(rxjs.startWith(-1), rxjs.map(factory));
|
|
7792
7809
|
if (emitAll !== true) {
|
|
@@ -7813,13 +7830,13 @@ function nowInterval(period) {
|
|
|
7813
7830
|
*/
|
|
7814
7831
|
class LimitDateTimeInstance {
|
|
7815
7832
|
constructor(config = {}) {
|
|
7833
|
+
this.config = void 0;
|
|
7816
7834
|
this.config = config;
|
|
7817
7835
|
}
|
|
7818
7836
|
get instant() {
|
|
7819
7837
|
return this.config.instant || 'now';
|
|
7820
7838
|
}
|
|
7821
7839
|
get minimumMinutesIntoFuture() {
|
|
7822
|
-
var _a;
|
|
7823
7840
|
const {
|
|
7824
7841
|
limits = {}
|
|
7825
7842
|
} = this.config;
|
|
@@ -7828,7 +7845,8 @@ class LimitDateTimeInstance {
|
|
|
7828
7845
|
} = limits;
|
|
7829
7846
|
let minutes;
|
|
7830
7847
|
if (future) {
|
|
7831
|
-
|
|
7848
|
+
var _future$minutes;
|
|
7849
|
+
minutes = (_future$minutes = future.minutes) != null ? _future$minutes : 0;
|
|
7832
7850
|
if (future.hours) {
|
|
7833
7851
|
minutes += Math.floor(future.hours * 60);
|
|
7834
7852
|
}
|
|
@@ -7854,7 +7872,7 @@ class LimitDateTimeInstance {
|
|
|
7854
7872
|
limit = util.DATE_NOW_VALUE;
|
|
7855
7873
|
} else if (future) {
|
|
7856
7874
|
const minimumMinutesIntoFuture = this.minimumMinutesIntoFuture;
|
|
7857
|
-
limit = dateFns.addMinutes(instant, minimumMinutesIntoFuture
|
|
7875
|
+
limit = dateFns.addMinutes(instant, minimumMinutesIntoFuture != null ? minimumMinutesIntoFuture : 0);
|
|
7858
7876
|
}
|
|
7859
7877
|
}
|
|
7860
7878
|
return limit;
|
|
@@ -7901,12 +7919,12 @@ class LimitDateTimeInstance {
|
|
|
7901
7919
|
* Clamps the input date to the current range.
|
|
7902
7920
|
*/
|
|
7903
7921
|
clamp(date) {
|
|
7904
|
-
var _a;
|
|
7905
7922
|
let result = date;
|
|
7906
7923
|
const dateRange = this.dateRange();
|
|
7907
7924
|
result = clampDateToDateRange(date, dateRange);
|
|
7908
7925
|
if (this.config.takeNextUpcomingTime) {
|
|
7909
|
-
|
|
7926
|
+
var _this$config$roundDow;
|
|
7927
|
+
result = takeNextUpcomingTime(result, (_this$config$roundDow = this.config.roundDownToMinute) != null ? _this$config$roundDow : false);
|
|
7910
7928
|
} else if (this.config.roundDownToMinute) {
|
|
7911
7929
|
result = roundDownToMinute(result);
|
|
7912
7930
|
}
|
|
@@ -7927,10 +7945,15 @@ function limitDateTimeInstance(config) {
|
|
|
7927
7945
|
*/
|
|
7928
7946
|
class DateTimeMinuteInstance {
|
|
7929
7947
|
constructor(config = {}, dateOverride) {
|
|
7930
|
-
var
|
|
7948
|
+
var _config$step;
|
|
7949
|
+
this.config = void 0;
|
|
7950
|
+
this._date = void 0;
|
|
7951
|
+
this._step = void 0;
|
|
7952
|
+
this._limit = void 0;
|
|
7953
|
+
this._dateFilter = void 0;
|
|
7931
7954
|
this.config = config;
|
|
7932
7955
|
this._date = (dateOverride == undefined ? config.date : dateOverride) || new Date();
|
|
7933
|
-
this._step = (
|
|
7956
|
+
this._step = (_config$step = config.step) != null ? _config$step : 1;
|
|
7934
7957
|
this._limit = new LimitDateTimeInstance(config);
|
|
7935
7958
|
this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
|
|
7936
7959
|
}
|
|
@@ -8046,9 +8069,9 @@ class DateTimeMinuteInstance {
|
|
|
8046
8069
|
}
|
|
8047
8070
|
|
|
8048
8071
|
round(round) {
|
|
8049
|
-
var
|
|
8050
|
-
let date = roundDateTimeDownToSteps(this.date, Object.assign(
|
|
8051
|
-
step: (
|
|
8072
|
+
var _round$step;
|
|
8073
|
+
let date = roundDateTimeDownToSteps(this.date, Object.assign({}, round, {
|
|
8074
|
+
step: (_round$step = round.step) != null ? _round$step : this.step
|
|
8052
8075
|
}));
|
|
8053
8076
|
if (round.roundToBound) {
|
|
8054
8077
|
date = this._takeBoundedDate(date);
|
|
@@ -8062,6 +8085,7 @@ class DateTimeMinuteInstance {
|
|
|
8062
8085
|
return this._limit.clamp(date);
|
|
8063
8086
|
}
|
|
8064
8087
|
clampToSchedule(date = this.date, maxClampDistance = 370) {
|
|
8088
|
+
var _nextAvailableDate;
|
|
8065
8089
|
let nextAvailableDate;
|
|
8066
8090
|
if (this._dateFilter != null) {
|
|
8067
8091
|
const maxLimitedDateRange = this._limit.dateRange();
|
|
@@ -8098,7 +8122,7 @@ class DateTimeMinuteInstance {
|
|
|
8098
8122
|
}
|
|
8099
8123
|
}
|
|
8100
8124
|
}
|
|
8101
|
-
return
|
|
8125
|
+
return (_nextAvailableDate = nextAvailableDate) != null ? _nextAvailableDate : date;
|
|
8102
8126
|
}
|
|
8103
8127
|
findNextAvailableDayInSchedule(date, direction, maxDistance = 370) {
|
|
8104
8128
|
let nextAvailableDate;
|
|
@@ -8123,8 +8147,8 @@ class DateTimeMinuteInstance {
|
|
|
8123
8147
|
return this._takeMaximumBoundedDate(this._takeMinimumBoundedDate(date));
|
|
8124
8148
|
}
|
|
8125
8149
|
_takeMinimumBoundedDate(date = this.date) {
|
|
8126
|
-
var
|
|
8127
|
-
if (((
|
|
8150
|
+
var _this$config$behavior;
|
|
8151
|
+
if (((_this$config$behavior = this.config.behavior) == null ? void 0 : _this$config$behavior.capToMinLimit) !== false) {
|
|
8128
8152
|
const min = dateFromLogicalDate(this._limit.min);
|
|
8129
8153
|
if (min && dateFns.isBefore(date, min)) {
|
|
8130
8154
|
date = min;
|
|
@@ -8133,8 +8157,8 @@ class DateTimeMinuteInstance {
|
|
|
8133
8157
|
return date;
|
|
8134
8158
|
}
|
|
8135
8159
|
_takeMaximumBoundedDate(date = this.date) {
|
|
8136
|
-
var
|
|
8137
|
-
if (((
|
|
8160
|
+
var _this$config$behavior2;
|
|
8161
|
+
if (((_this$config$behavior2 = this.config.behavior) == null ? void 0 : _this$config$behavior2.capToMaxLimit) !== false) {
|
|
8138
8162
|
const max = dateFromLogicalDate(this._limit.max);
|
|
8139
8163
|
if (max && dateFns.isAfter(date, max)) {
|
|
8140
8164
|
date = max;
|
|
@@ -8489,17 +8513,18 @@ class DateTimeUtilityInstance {
|
|
|
8489
8513
|
* If the timezone is not defined, it defaults to UTC.
|
|
8490
8514
|
*/
|
|
8491
8515
|
constructor(timezone) {
|
|
8516
|
+
this.normalInstance = void 0;
|
|
8492
8517
|
this.normalInstance = new DateTimezoneUtcNormalInstance(timezone);
|
|
8493
8518
|
}
|
|
8494
8519
|
get timezone() {
|
|
8495
8520
|
return this.normalInstance.configuredTimezoneString;
|
|
8496
8521
|
}
|
|
8497
8522
|
getTimeAM(date = new Date(), timezone) {
|
|
8498
|
-
const am = dateFnsTz.formatInTimeZone(date, timezone
|
|
8523
|
+
const am = dateFnsTz.formatInTimeZone(date, timezone != null ? timezone : this.timezone, 'a');
|
|
8499
8524
|
return am;
|
|
8500
8525
|
}
|
|
8501
8526
|
toTimeString(date, timezone) {
|
|
8502
|
-
return dateFnsTz.formatInTimeZone(date, timezone
|
|
8527
|
+
return dateFnsTz.formatInTimeZone(date, timezone != null ? timezone : this.timezone, `h:mma`);
|
|
8503
8528
|
}
|
|
8504
8529
|
parseTimeString(input, config) {
|
|
8505
8530
|
const timestringResult = this._timeStringToDate(input, config);
|
|
@@ -8649,13 +8674,13 @@ class DateTimeUtilityInstance {
|
|
|
8649
8674
|
return output;
|
|
8650
8675
|
}
|
|
8651
8676
|
_normalizeInstanceForConfig(config) {
|
|
8652
|
-
var _a;
|
|
8653
8677
|
let instance;
|
|
8654
8678
|
if (isSameDateTimezoneConversionConfig(this.normalInstance.config, config)) {
|
|
8655
8679
|
instance = this.normalInstance;
|
|
8656
8680
|
} else {
|
|
8657
|
-
|
|
8658
|
-
|
|
8681
|
+
var _config$timezone;
|
|
8682
|
+
instance = new DateTimezoneUtcNormalInstance(Object.assign({}, config, {
|
|
8683
|
+
timezone: (_config$timezone = config.timezone) != null ? _config$timezone : this.normalInstance.config.timezone
|
|
8659
8684
|
}));
|
|
8660
8685
|
}
|
|
8661
8686
|
return instance;
|
|
@@ -8665,7 +8690,7 @@ function dateTimeInstanceUtc() {
|
|
|
8665
8690
|
return dateTimeInstance(util.UTC_TIMEZONE_STRING);
|
|
8666
8691
|
}
|
|
8667
8692
|
function dateTimeInstance(timezone) {
|
|
8668
|
-
return new DateTimeUtilityInstance(timezone
|
|
8693
|
+
return new DateTimeUtilityInstance(timezone != null ? timezone : util.UTC_TIMEZONE_STRING);
|
|
8669
8694
|
}
|
|
8670
8695
|
function getTimeAM(date = new Date(), timezone) {
|
|
8671
8696
|
return dateTimeInstance(timezone).getTimeAM(date);
|
|
@@ -8692,10 +8717,10 @@ function toReadableTimeString(date, timezone) {
|
|
|
8692
8717
|
* @returns
|
|
8693
8718
|
*/
|
|
8694
8719
|
function parseReadableTimeString(input, config) {
|
|
8695
|
-
return dateTimeInstance(config
|
|
8720
|
+
return dateTimeInstance(config == null ? void 0 : config.timezone).parseTimeString(input, config);
|
|
8696
8721
|
}
|
|
8697
8722
|
function readableTimeStringToDate(input, config) {
|
|
8698
|
-
return dateTimeInstance(config
|
|
8723
|
+
return dateTimeInstance(config == null ? void 0 : config.timezone).timeStringToDate(input, config);
|
|
8699
8724
|
}
|
|
8700
8725
|
// MARK: Limits
|
|
8701
8726
|
function limitDateTime(config) {
|
|
@@ -8796,8 +8821,8 @@ function hasExpired(expires) {
|
|
|
8796
8821
|
* Returns the expiration date, or a date 1 minute in the past if not defined.
|
|
8797
8822
|
*/
|
|
8798
8823
|
function getExpiration(expires) {
|
|
8799
|
-
var
|
|
8800
|
-
return (
|
|
8824
|
+
var _expires$expiresAt;
|
|
8825
|
+
return (_expires$expiresAt = expires == null ? void 0 : expires.expiresAt) != null ? _expires$expiresAt : dateFns.addMinutes(new Date(), -1);
|
|
8801
8826
|
}
|
|
8802
8827
|
|
|
8803
8828
|
/**
|
|
@@ -8862,7 +8887,7 @@ function makeDateQueryForDateItemRangeFilter(find) {
|
|
|
8862
8887
|
const result = {};
|
|
8863
8888
|
result.timezone = find.timezone;
|
|
8864
8889
|
// Apply the timezone to the date range if provided.
|
|
8865
|
-
const range = find.timezone ? Object.assign(
|
|
8890
|
+
const range = find.timezone ? Object.assign({}, find.range, {
|
|
8866
8891
|
date: dateFnsTz.utcToZonedTime(find.range.date, find.timezone)
|
|
8867
8892
|
}) : find.range;
|
|
8868
8893
|
const dates = dateRange(range);
|
|
@@ -8887,28 +8912,29 @@ function makeDateQueryForDateItemRangeFilter(find) {
|
|
|
8887
8912
|
return result;
|
|
8888
8913
|
}
|
|
8889
8914
|
function makeDateQueryForDateStartsEndsFilter(find) {
|
|
8890
|
-
var _a, _b;
|
|
8891
8915
|
const result = {};
|
|
8892
8916
|
result.timezone = find.timezone;
|
|
8893
8917
|
if (find.starts) {
|
|
8918
|
+
var _result$startsGte;
|
|
8894
8919
|
const {
|
|
8895
8920
|
before,
|
|
8896
8921
|
after,
|
|
8897
8922
|
at: equals
|
|
8898
8923
|
} = find.starts;
|
|
8899
|
-
result.startsGte = after
|
|
8900
|
-
result.startsLte = before
|
|
8901
|
-
result.rStart = (
|
|
8924
|
+
result.startsGte = after != null ? after : equals;
|
|
8925
|
+
result.startsLte = before != null ? before : equals;
|
|
8926
|
+
result.rStart = (_result$startsGte = result.startsGte) != null ? _result$startsGte : result.startsLte;
|
|
8902
8927
|
}
|
|
8903
8928
|
if (find.ends) {
|
|
8929
|
+
var _result$endsGte;
|
|
8904
8930
|
const {
|
|
8905
8931
|
before,
|
|
8906
8932
|
after,
|
|
8907
8933
|
at: equals
|
|
8908
8934
|
} = find.ends;
|
|
8909
|
-
result.endsGte = after
|
|
8910
|
-
result.endsLte = before
|
|
8911
|
-
result.rEnd = (
|
|
8935
|
+
result.endsGte = after != null ? after : equals;
|
|
8936
|
+
result.endsLte = before != null ? before : equals;
|
|
8937
|
+
result.rEnd = (_result$endsGte = result.endsGte) != null ? _result$endsGte : result.endsLte;
|
|
8912
8938
|
}
|
|
8913
8939
|
return result;
|
|
8914
8940
|
}
|
|
@@ -8947,10 +8973,10 @@ function makeDaysAndTimeFiltersFunction(builder) {
|
|
|
8947
8973
|
}
|
|
8948
8974
|
|
|
8949
8975
|
function mergeMongoDBLikeRangeFilters(startsAt, endsAt) {
|
|
8950
|
-
var
|
|
8976
|
+
var _startsAt$$lte, _endsAt$$gte;
|
|
8951
8977
|
return {
|
|
8952
|
-
$lte: (
|
|
8953
|
-
$gte: (
|
|
8978
|
+
$lte: (_startsAt$$lte = startsAt == null ? void 0 : startsAt.$lte) != null ? _startsAt$$lte : endsAt == null ? void 0 : endsAt.$lte,
|
|
8979
|
+
$gte: (_endsAt$$gte = endsAt == null ? void 0 : endsAt.$gte) != null ? _endsAt$$gte : startsAt == null ? void 0 : startsAt.$gte
|
|
8954
8980
|
};
|
|
8955
8981
|
}
|
|
8956
8982
|
function makeMongoDBLikeDateQueryBuilder(config) {
|
|
@@ -8961,9 +8987,9 @@ function makeMongoDBLikeDateQueryBuilder(config) {
|
|
|
8961
8987
|
makeRangeFilter(gte, lte) {
|
|
8962
8988
|
let result;
|
|
8963
8989
|
if (gte || lte) {
|
|
8964
|
-
result = Object.assign(
|
|
8990
|
+
result = Object.assign({}, gte ? {
|
|
8965
8991
|
$gte: gte
|
|
8966
|
-
} : undefined
|
|
8992
|
+
} : undefined, lte ? {
|
|
8967
8993
|
$lte: lte
|
|
8968
8994
|
} : undefined);
|
|
8969
8995
|
}
|
|
@@ -8990,7 +9016,7 @@ function makeMongoDBLikeDateQueryBuilder(config) {
|
|
|
8990
9016
|
[fields.end]: endsAt
|
|
8991
9017
|
} : undefined;
|
|
8992
9018
|
}
|
|
8993
|
-
const filter = Object.assign(
|
|
9019
|
+
const filter = Object.assign({}, startsAtFilter, endsAtFilter);
|
|
8994
9020
|
return filter;
|
|
8995
9021
|
}
|
|
8996
9022
|
};
|
|
@@ -9049,8 +9075,9 @@ class BaseRRuleIter {
|
|
|
9049
9075
|
class LastIterResult extends BaseRRuleIter {
|
|
9050
9076
|
constructor(maxIterationsAllowed = DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED) {
|
|
9051
9077
|
super();
|
|
9052
|
-
this.maxIterationsAllowed =
|
|
9078
|
+
this.maxIterationsAllowed = void 0;
|
|
9053
9079
|
this.maxDate = maxFutureDate();
|
|
9080
|
+
this.maxIterationsAllowed = maxIterationsAllowed;
|
|
9054
9081
|
}
|
|
9055
9082
|
accept(date) {
|
|
9056
9083
|
++this.total;
|
|
@@ -9074,9 +9101,12 @@ class LastIterResult extends BaseRRuleIter {
|
|
|
9074
9101
|
class NextIterResult extends BaseRRuleIter {
|
|
9075
9102
|
constructor(minDate, maxIterationsAllowed = DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED) {
|
|
9076
9103
|
super();
|
|
9104
|
+
this.minDate = void 0;
|
|
9105
|
+
this.maxIterationsAllowed = void 0;
|
|
9106
|
+
this.maxDate = void 0;
|
|
9077
9107
|
this.minDate = minDate;
|
|
9078
9108
|
this.maxIterationsAllowed = maxIterationsAllowed;
|
|
9079
|
-
this.maxDate =
|
|
9109
|
+
this.maxDate = minDate;
|
|
9080
9110
|
}
|
|
9081
9111
|
accept(date) {
|
|
9082
9112
|
this.total += 1;
|
|
@@ -9099,14 +9129,15 @@ class NextIterResult extends BaseRRuleIter {
|
|
|
9099
9129
|
}
|
|
9100
9130
|
class AnyIterResult extends BaseRRuleIter {
|
|
9101
9131
|
constructor(filter, maxIterationsAllowed = DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED) {
|
|
9102
|
-
var _a, _b;
|
|
9103
9132
|
super();
|
|
9104
|
-
this.maxIterationsAllowed =
|
|
9133
|
+
this.maxIterationsAllowed = void 0;
|
|
9105
9134
|
this.minDate = null;
|
|
9106
9135
|
this.maxDate = null;
|
|
9136
|
+
this.maxIterationsAllowed = maxIterationsAllowed;
|
|
9107
9137
|
if (filter) {
|
|
9108
|
-
|
|
9109
|
-
this.
|
|
9138
|
+
var _filter$minDate, _filter$maxDate;
|
|
9139
|
+
this.minDate = (_filter$minDate = filter.minDate) != null ? _filter$minDate : null;
|
|
9140
|
+
this.maxDate = (_filter$maxDate = filter.maxDate) != null ? _filter$maxDate : null;
|
|
9110
9141
|
}
|
|
9111
9142
|
}
|
|
9112
9143
|
accept(date) {
|
|
@@ -9234,8 +9265,8 @@ class DateRRuleParseUtility {
|
|
|
9234
9265
|
return DateRRuleParseUtility.parseExdateAttributeFromProperty(property);
|
|
9235
9266
|
}
|
|
9236
9267
|
static parseExdateAttributeFromProperty(property) {
|
|
9237
|
-
var
|
|
9238
|
-
const timezone = (
|
|
9268
|
+
var _property$params$find;
|
|
9269
|
+
const timezone = (_property$params$find = property.params.find(x => x.key === 'TZID')) == null ? void 0 : _property$params$find.value;
|
|
9239
9270
|
const rawDates = property.values.split(',');
|
|
9240
9271
|
const conversion = new DateTimezoneUtcNormalInstance({
|
|
9241
9272
|
timezone
|
|
@@ -9336,20 +9367,22 @@ class DateRRuleInstance {
|
|
|
9336
9367
|
* Creates a new DateRRuleInstance from the input.
|
|
9337
9368
|
*/
|
|
9338
9369
|
static make(params) {
|
|
9339
|
-
var
|
|
9370
|
+
var _params$rruleStringLi, _params$options$exclu;
|
|
9340
9371
|
if (!(params.rruleLines || params.rruleStringLineSet)) {
|
|
9341
9372
|
throw new Error('Missing rruleLines or rruleStringLineSet input.');
|
|
9342
9373
|
}
|
|
9343
|
-
const rruleStringLineSet = (
|
|
9374
|
+
const rruleStringLineSet = (_params$rruleStringLi = params.rruleStringLineSet) != null ? _params$rruleStringLi : DateRRuleParseUtility.toRRuleStringSet(params.rruleLines);
|
|
9344
9375
|
const rruleOptions = DateRRuleUtility.toRRuleOptions(rruleStringLineSet);
|
|
9345
|
-
const exclude = rruleOptions.exdates.addAll((
|
|
9376
|
+
const exclude = rruleOptions.exdates.addAll((_params$options$exclu = params.options.exclude) == null ? void 0 : _params$options$exclu.valuesArray());
|
|
9346
9377
|
const rrule = new DateRRule(rruleOptions.options);
|
|
9347
|
-
return new DateRRuleInstance(rrule, Object.assign(
|
|
9378
|
+
return new DateRRuleInstance(rrule, Object.assign({}, params.options, {
|
|
9348
9379
|
exclude
|
|
9349
9380
|
}));
|
|
9350
9381
|
}
|
|
9351
9382
|
constructor(rrule, options) {
|
|
9352
|
-
|
|
9383
|
+
this.options = void 0;
|
|
9384
|
+
this.rrule = void 0;
|
|
9385
|
+
this.normalInstance = void 0;
|
|
9353
9386
|
this.options = options;
|
|
9354
9387
|
const tzid = rrule.origOptions.tzid;
|
|
9355
9388
|
let dtstart = rrule.origOptions.dtstart;
|
|
@@ -9360,17 +9393,19 @@ class DateRRuleInstance {
|
|
|
9360
9393
|
*/
|
|
9361
9394
|
this.normalInstance = new DateTimezoneUtcNormalInstance(timezone);
|
|
9362
9395
|
if (dtstart && tzid) ; else if (timezone) {
|
|
9363
|
-
|
|
9396
|
+
var _options$date;
|
|
9397
|
+
const startsAt = (_options$date = options.date) == null ? void 0 : _options$date.startsAt;
|
|
9364
9398
|
// If startsAt is provided, need to change it to start from the base UTC date, if any timezone is provided.
|
|
9365
9399
|
if (startsAt) {
|
|
9366
9400
|
const baseStartDate = this.normalInstance.baseDateToTargetDate(startsAt);
|
|
9367
9401
|
dtstart = baseStartDate;
|
|
9368
9402
|
}
|
|
9369
9403
|
} else {
|
|
9404
|
+
var _dtstart, _options$date2;
|
|
9370
9405
|
// If start date is provided without a timezone, assume timezone is UTC. Do nothing.
|
|
9371
|
-
dtstart =
|
|
9406
|
+
dtstart = (_dtstart = dtstart) != null ? _dtstart : (_options$date2 = options.date) == null ? void 0 : _options$date2.startsAt;
|
|
9372
9407
|
}
|
|
9373
|
-
const rruleOptions = Object.assign(
|
|
9408
|
+
const rruleOptions = Object.assign({}, rrule.origOptions, {
|
|
9374
9409
|
tzid: undefined,
|
|
9375
9410
|
dtstart
|
|
9376
9411
|
});
|
|
@@ -9415,13 +9450,13 @@ class DateRRuleInstance {
|
|
|
9415
9450
|
startsAtDates = this.rrule.all();
|
|
9416
9451
|
}
|
|
9417
9452
|
const referenceDate = this.options.date;
|
|
9418
|
-
const allDates = startsAtDates.map(startsAt => Object.assign(
|
|
9453
|
+
const allDates = startsAtDates.map(startsAt => Object.assign({}, referenceDate, {
|
|
9419
9454
|
startsAt
|
|
9420
9455
|
})); // Inherit calendar time, etc.
|
|
9421
9456
|
let dates = allDates;
|
|
9422
9457
|
// Fix Dates w/ Timezones
|
|
9423
9458
|
if (this.normalInstance.hasConversion) {
|
|
9424
|
-
dates = dates.map(x => Object.assign(
|
|
9459
|
+
dates = dates.map(x => Object.assign({}, x, {
|
|
9425
9460
|
startsAt: this.normalInstance.targetDateToBaseDate(x.startsAt)
|
|
9426
9461
|
}));
|
|
9427
9462
|
}
|
|
@@ -9465,7 +9500,7 @@ class DateRRuleInstance {
|
|
|
9465
9500
|
end = this.rrule.last();
|
|
9466
9501
|
}
|
|
9467
9502
|
const referenceDate = this.options.date;
|
|
9468
|
-
const finalRecurrenceDateRange = durationSpanToDateRange(Object.assign(
|
|
9503
|
+
const finalRecurrenceDateRange = durationSpanToDateRange(Object.assign({}, referenceDate, {
|
|
9469
9504
|
startsAt: end
|
|
9470
9505
|
}));
|
|
9471
9506
|
finalRecurrenceEndsAt = finalRecurrenceDateRange.end;
|
|
@@ -9494,11 +9529,11 @@ class DateRRuleUtility {
|
|
|
9494
9529
|
* Creates the expansion item results based on the input.
|
|
9495
9530
|
*/
|
|
9496
9531
|
static expand(options) {
|
|
9497
|
-
var
|
|
9532
|
+
var _options$instance;
|
|
9498
9533
|
if (!options.instance && !options.instanceFrom) {
|
|
9499
9534
|
throw new Error('Rrules be defined for expansion.');
|
|
9500
9535
|
}
|
|
9501
|
-
const dateRrule = (
|
|
9536
|
+
const dateRrule = (_options$instance = options.instance) != null ? _options$instance : DateRRuleInstance.make(options.instanceFrom);
|
|
9502
9537
|
return dateRrule.expand(options);
|
|
9503
9538
|
}
|
|
9504
9539
|
static makeInstance(params) {
|
|
@@ -9509,7 +9544,7 @@ class DateRRuleUtility {
|
|
|
9509
9544
|
const rules = DateRRuleParseUtility.separateRRuleStringSetValues(rruleStringLineSet);
|
|
9510
9545
|
const lines = DateRRuleParseUtility.toRRuleLines(rules.basic);
|
|
9511
9546
|
const ruleOptions = rrule.RRule.parseString(lines);
|
|
9512
|
-
return Object.assign(
|
|
9547
|
+
return Object.assign({}, rules, {
|
|
9513
9548
|
options: ruleOptions
|
|
9514
9549
|
});
|
|
9515
9550
|
}
|
|
@@ -9520,6 +9555,28 @@ class DateRRuleUtility {
|
|
|
9520
9555
|
*/
|
|
9521
9556
|
exports.ModelRecurrenceInfo = class ModelRecurrenceInfo {
|
|
9522
9557
|
constructor(template) {
|
|
9558
|
+
/**
|
|
9559
|
+
* Timezone the rule is a part of.
|
|
9560
|
+
*
|
|
9561
|
+
* Required for RRules that have timezone-sensitive implementations.
|
|
9562
|
+
*/
|
|
9563
|
+
this.timezone = void 0;
|
|
9564
|
+
/**
|
|
9565
|
+
* RRules for this recurrence.
|
|
9566
|
+
*/
|
|
9567
|
+
this.rrule = void 0;
|
|
9568
|
+
/**
|
|
9569
|
+
* First instance of the recurrence.
|
|
9570
|
+
*/
|
|
9571
|
+
this.start = void 0;
|
|
9572
|
+
/**
|
|
9573
|
+
* Final instance of the recurrence.
|
|
9574
|
+
*/
|
|
9575
|
+
this.end = void 0;
|
|
9576
|
+
/**
|
|
9577
|
+
* True if the recurrence has no end.
|
|
9578
|
+
*/
|
|
9579
|
+
this.forever = void 0;
|
|
9523
9580
|
if (template != null) {
|
|
9524
9581
|
this.timezone = template.timezone;
|
|
9525
9582
|
this.rrule = template.rrule;
|
|
@@ -9543,7 +9600,7 @@ class ModelRecurrenceInfoUtility {
|
|
|
9543
9600
|
* Creates a ModelRecurrenceInfo instance from the input ModelRecurrenceStart.
|
|
9544
9601
|
*/
|
|
9545
9602
|
static expandModelRecurrenceStartToModelRecurrenceInfo(update) {
|
|
9546
|
-
var
|
|
9603
|
+
var _dates$finalRecurrenc;
|
|
9547
9604
|
const {
|
|
9548
9605
|
date,
|
|
9549
9606
|
rrule,
|
|
@@ -9561,7 +9618,7 @@ class ModelRecurrenceInfoUtility {
|
|
|
9561
9618
|
timezone,
|
|
9562
9619
|
rrule: rruleSetString,
|
|
9563
9620
|
start: dates.start,
|
|
9564
|
-
end: (
|
|
9621
|
+
end: (_dates$finalRecurrenc = dates.finalRecurrenceEndsAt) != null ? _dates$finalRecurrenc : dates.end,
|
|
9565
9622
|
forever: dates.forever
|
|
9566
9623
|
};
|
|
9567
9624
|
return new exports.ModelRecurrenceInfo(recurrenceInfo);
|
package/index.esm.js
CHANGED
|
@@ -10098,7 +10098,8 @@ class NextIterResult extends BaseRRuleIter {
|
|
|
10098
10098
|
super();
|
|
10099
10099
|
this.minDate = minDate;
|
|
10100
10100
|
this.maxIterationsAllowed = maxIterationsAllowed;
|
|
10101
|
-
this.maxDate =
|
|
10101
|
+
this.maxDate = void 0;
|
|
10102
|
+
this.maxDate = minDate;
|
|
10102
10103
|
}
|
|
10103
10104
|
accept(date) {
|
|
10104
10105
|
this.total += 1;
|