@dereekb/date 13.3.1 → 13.4.1
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 +987 -356
- package/index.esm.js +983 -357
- package/package.json +5 -4
- package/src/lib/date/date.calendar.d.ts +3 -3
- package/src/lib/date/date.cell.d.ts +5 -0
- package/src/lib/date/date.cell.factory.d.ts +77 -0
- package/src/lib/date/date.cell.filter.d.ts +7 -0
- package/src/lib/date/date.cell.index.d.ts +44 -4
- package/src/lib/date/date.cell.schedule.d.ts +2 -0
- package/src/lib/date/date.d.ts +6 -0
- package/src/lib/date/date.day.d.ts +22 -3
- package/src/lib/date/date.format.d.ts +70 -8
- package/src/lib/date/date.range.d.ts +105 -2
- package/src/lib/date/date.range.timezone.d.ts +1 -0
- package/src/lib/date/date.time.d.ts +12 -0
- package/src/lib/date/date.time.limit.d.ts +9 -0
- package/src/lib/date/date.time.minute.d.ts +28 -0
- package/src/lib/date/date.timezone.d.ts +107 -15
- package/src/lib/date/date.week.d.ts +9 -4
- package/src/lib/date/index.d.ts +0 -1
- package/src/lib/query/query.builder.mongo.d.ts +9 -3
- package/src/lib/rrule/date.recurrence.d.ts +21 -7
- package/src/lib/rrule/date.rrule.d.ts +2 -0
- package/src/lib/rrule/date.rrule.extension.d.ts +10 -0
- package/src/lib/rrule/date.rrule.parse.d.ts +41 -0
- package/src/lib/timezone/index.d.ts +0 -1
- package/src/lib/timezone/timezone.d.ts +38 -4
package/index.cjs.js
CHANGED
|
@@ -9,6 +9,14 @@ var model = require('@dereekb/model');
|
|
|
9
9
|
var rxjs = require('rxjs');
|
|
10
10
|
var rrule = require('rrule');
|
|
11
11
|
|
|
12
|
+
function _array_like_to_array$7(arr, len) {
|
|
13
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
14
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
15
|
+
return arr2;
|
|
16
|
+
}
|
|
17
|
+
function _array_without_holes$5(arr) {
|
|
18
|
+
if (Array.isArray(arr)) return _array_like_to_array$7(arr);
|
|
19
|
+
}
|
|
12
20
|
function _define_property$h(obj, key, value) {
|
|
13
21
|
if (key in obj) {
|
|
14
22
|
Object.defineProperty(obj, key, {
|
|
@@ -22,6 +30,12 @@ function _define_property$h(obj, key, value) {
|
|
|
22
30
|
}
|
|
23
31
|
return obj;
|
|
24
32
|
}
|
|
33
|
+
function _iterable_to_array$5(iter) {
|
|
34
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
35
|
+
}
|
|
36
|
+
function _non_iterable_spread$5() {
|
|
37
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
38
|
+
}
|
|
25
39
|
function _object_spread$e(target) {
|
|
26
40
|
for(var i = 1; i < arguments.length; i++){
|
|
27
41
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -37,6 +51,17 @@ function _object_spread$e(target) {
|
|
|
37
51
|
}
|
|
38
52
|
return target;
|
|
39
53
|
}
|
|
54
|
+
function _to_consumable_array$5(arr) {
|
|
55
|
+
return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$5();
|
|
56
|
+
}
|
|
57
|
+
function _unsupported_iterable_to_array$7(o, minLen) {
|
|
58
|
+
if (!o) return;
|
|
59
|
+
if (typeof o === "string") return _array_like_to_array$7(o, minLen);
|
|
60
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
61
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
62
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
63
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
|
|
64
|
+
}
|
|
40
65
|
/**
|
|
41
66
|
* Sentinel date representing the maximum future date (January 1, 9999 UTC).
|
|
42
67
|
*
|
|
@@ -134,6 +159,8 @@ function _object_spread$e(target) {
|
|
|
134
159
|
*
|
|
135
160
|
* Useful as a default for "no expiration" comparisons.
|
|
136
161
|
*
|
|
162
|
+
* @returns the MAX_FUTURE_DATE sentinel
|
|
163
|
+
*
|
|
137
164
|
* @example
|
|
138
165
|
* ```ts
|
|
139
166
|
* const futureDate = maxFutureDate();
|
|
@@ -204,8 +231,7 @@ function _object_spread$e(target) {
|
|
|
204
231
|
* // tz === 'America/New_York' (or similar)
|
|
205
232
|
* ```
|
|
206
233
|
*/ function guessCurrentTimezone() {
|
|
207
|
-
|
|
208
|
-
return (_Intl_DateTimeFormat = Intl.DateTimeFormat()) === null || _Intl_DateTimeFormat === void 0 ? void 0 : (_Intl_DateTimeFormat_resolvedOptions = _Intl_DateTimeFormat.resolvedOptions()) === null || _Intl_DateTimeFormat_resolvedOptions === void 0 ? void 0 : _Intl_DateTimeFormat_resolvedOptions.timeZone;
|
|
234
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
209
235
|
}
|
|
210
236
|
/**
|
|
211
237
|
* Returns the current system's timezone, throwing if detection fails.
|
|
@@ -295,15 +321,15 @@ function isBefore(a, b) {
|
|
|
295
321
|
}
|
|
296
322
|
function isSameDate(a, b) {
|
|
297
323
|
var defaultValue = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
298
|
-
return a != null && b != null ? dateFns.isEqual(a, b) : defaultValue
|
|
324
|
+
return a != null && b != null ? dateFns.isEqual(a, b) : defaultValue !== null && defaultValue !== void 0 ? defaultValue : a == b;
|
|
299
325
|
}
|
|
300
326
|
function isSameDateHoursAndMinutes(a, b) {
|
|
301
327
|
var defaultValue = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
302
|
-
return a != null && b != null ? dateFns.isEqual(roundDownToMinute(a), roundDownToMinute(b)) : defaultValue
|
|
328
|
+
return a != null && b != null ? dateFns.isEqual(roundDownToMinute(a), roundDownToMinute(b)) : defaultValue !== null && defaultValue !== void 0 ? defaultValue : a == b;
|
|
303
329
|
}
|
|
304
330
|
function isSameDateDay(a, b) {
|
|
305
331
|
var defaultValue = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
306
|
-
return a != null && b != null ? dateFns.isSameDay(a, b) : defaultValue
|
|
332
|
+
return a != null && b != null ? dateFns.isSameDay(a, b) : defaultValue !== null && defaultValue !== void 0 ? defaultValue : a == b;
|
|
307
333
|
}
|
|
308
334
|
// MARK: Unix Date/Time
|
|
309
335
|
/**
|
|
@@ -347,6 +373,10 @@ function isSameDateDay(a, b) {
|
|
|
347
373
|
* Sets the hours and optionally minutes on a target date (defaults to now), with optional rounding to strip seconds/milliseconds.
|
|
348
374
|
*
|
|
349
375
|
* @param config - hours, optional minutes, and rounding options
|
|
376
|
+
* @param config.hours - the hours value to set
|
|
377
|
+
* @param config.minutes - optional minutes value to set
|
|
378
|
+
* @param config.removeSeconds - whether to zero out seconds
|
|
379
|
+
* @param config.roundDownToMinute - whether to zero out seconds and milliseconds (defaults to true)
|
|
350
380
|
* @param target - date to modify (defaults to the current date/time)
|
|
351
381
|
* @returns a new Date with the specified time values applied
|
|
352
382
|
*
|
|
@@ -411,7 +441,7 @@ function isSameDateDay(a, b) {
|
|
|
411
441
|
}
|
|
412
442
|
function roundDateTo(date, roundToUnit) {
|
|
413
443
|
var roundType = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 'floor';
|
|
414
|
-
return typeof date === 'number' ? roundDateToUnixDateTimeNumber(date, roundToUnit, roundType) :
|
|
444
|
+
return typeof date === 'number' ? roundDateToUnixDateTimeNumber(date, roundToUnit, roundType) : roundDateToDate(date, roundToUnit, roundType);
|
|
415
445
|
}
|
|
416
446
|
/**
|
|
417
447
|
* Rounds a date or unix timestamp to the nearest unit boundary, always returning a Date.
|
|
@@ -576,7 +606,7 @@ function roundDateTo(date, roundToUnit) {
|
|
|
576
606
|
* // names === ['Mon', 'Tue']
|
|
577
607
|
* ```
|
|
578
608
|
*/ function readDaysOfWeekNames(values, readDate, nameFunction) {
|
|
579
|
-
return
|
|
609
|
+
return _to_consumable_array$5(readDaysOfWeek(values, readDate)).sort(util.sortNumbersAscendingFunction).map(nameFunction);
|
|
580
610
|
}
|
|
581
611
|
/**
|
|
582
612
|
* Checks whether the given date falls exactly at midnight (00:00:00.000) in UTC.
|
|
@@ -845,6 +875,9 @@ function _is_native_reflect_construct$2() {
|
|
|
845
875
|
/**
|
|
846
876
|
* Type guard to check if a value conforms to the {@link DateRangeStart} interface.
|
|
847
877
|
*
|
|
878
|
+
* @param value - the value to check
|
|
879
|
+
* @returns true if the value has a valid Date `start` property
|
|
880
|
+
*
|
|
848
881
|
* @example
|
|
849
882
|
* ```ts
|
|
850
883
|
* isDateRangeStart({ start: new Date() }); // true
|
|
@@ -873,6 +906,9 @@ function _is_native_reflect_construct$2() {
|
|
|
873
906
|
* Counts the total number of calendar days spanned by the range, inclusive of both endpoints.
|
|
874
907
|
* Always returns at least 1, even for same-day ranges.
|
|
875
908
|
*
|
|
909
|
+
* @param dateRange - the date range to measure
|
|
910
|
+
* @returns the number of days in the range, inclusive
|
|
911
|
+
*
|
|
876
912
|
* @example
|
|
877
913
|
* ```ts
|
|
878
914
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-01-03') };
|
|
@@ -884,6 +920,9 @@ function _is_native_reflect_construct$2() {
|
|
|
884
920
|
/**
|
|
885
921
|
* Type guard to check if a value is a valid {@link DateRange} with both start and end as Date objects.
|
|
886
922
|
*
|
|
923
|
+
* @param input - the value to check
|
|
924
|
+
* @returns true if the value has valid Date `start` and `end` properties
|
|
925
|
+
*
|
|
887
926
|
* @example
|
|
888
927
|
* ```ts
|
|
889
928
|
* isDateRange({ start: new Date(), end: new Date() }); // true
|
|
@@ -897,6 +936,10 @@ function _is_native_reflect_construct$2() {
|
|
|
897
936
|
* Compares two date ranges for exact millisecond equality on both start and end.
|
|
898
937
|
* Returns true if both are nullish.
|
|
899
938
|
*
|
|
939
|
+
* @param a - first date range to compare
|
|
940
|
+
* @param b - second date range to compare
|
|
941
|
+
* @returns true if both ranges are equal or both are nullish
|
|
942
|
+
*
|
|
900
943
|
* @example
|
|
901
944
|
* ```ts
|
|
902
945
|
* const a = { start: new Date('2024-01-01'), end: new Date('2024-01-31') };
|
|
@@ -911,6 +954,10 @@ function _is_native_reflect_construct$2() {
|
|
|
911
954
|
* Compares two date ranges for calendar-day equality, ignoring time-of-day differences.
|
|
912
955
|
* Returns true if both are nullish.
|
|
913
956
|
*
|
|
957
|
+
* @param a - first date range to compare
|
|
958
|
+
* @param b - second date range to compare
|
|
959
|
+
* @returns true if both ranges fall on the same calendar days or both are nullish
|
|
960
|
+
*
|
|
914
961
|
* @example
|
|
915
962
|
* ```ts
|
|
916
963
|
* const a = { start: new Date('2024-01-01T08:00:00'), end: new Date('2024-01-31T10:00:00') };
|
|
@@ -923,6 +970,9 @@ function _is_native_reflect_construct$2() {
|
|
|
923
970
|
/**
|
|
924
971
|
* Checks whether the range is unbounded (neither start nor end is set), meaning it conceptually includes all dates.
|
|
925
972
|
*
|
|
973
|
+
* @param input - the partial date range to check
|
|
974
|
+
* @returns true if neither start nor end is set
|
|
975
|
+
*
|
|
926
976
|
* @example
|
|
927
977
|
* ```ts
|
|
928
978
|
* isInfiniteDateRange({}); // true
|
|
@@ -934,6 +984,9 @@ function _is_native_reflect_construct$2() {
|
|
|
934
984
|
/**
|
|
935
985
|
* Checks whether the range has only one of start or end set, but not both.
|
|
936
986
|
*
|
|
987
|
+
* @param input - the partial date range to check
|
|
988
|
+
* @returns true if exactly one of start or end is set
|
|
989
|
+
*
|
|
937
990
|
* @example
|
|
938
991
|
* ```ts
|
|
939
992
|
* isPartialDateRange({ start: new Date() }); // true
|
|
@@ -945,6 +998,9 @@ function _is_native_reflect_construct$2() {
|
|
|
945
998
|
/**
|
|
946
999
|
* Checks whether the range has both start and end set.
|
|
947
1000
|
*
|
|
1001
|
+
* @param input - the partial date range to check
|
|
1002
|
+
* @returns true if both start and end are set
|
|
1003
|
+
*
|
|
948
1004
|
* @example
|
|
949
1005
|
* ```ts
|
|
950
1006
|
* isFullDateRange({ start: new Date(), end: new Date() }); // true
|
|
@@ -957,6 +1013,10 @@ function _is_native_reflect_construct$2() {
|
|
|
957
1013
|
* Normalizes a Date or {@link DateRange} into a DateRange. When given a single Date,
|
|
958
1014
|
* uses it as start and optionally uses the provided end date (defaults to the same date).
|
|
959
1015
|
*
|
|
1016
|
+
* @param startOrDateRange - a Date or existing DateRange
|
|
1017
|
+
* @param end - optional end date when the first argument is a plain Date
|
|
1018
|
+
* @returns a DateRange
|
|
1019
|
+
*
|
|
960
1020
|
* @example
|
|
961
1021
|
* ```ts
|
|
962
1022
|
* const range = dateOrDateRangeToDateRange(new Date('2024-01-01'), new Date('2024-01-31'));
|
|
@@ -966,14 +1026,16 @@ function _is_native_reflect_construct$2() {
|
|
|
966
1026
|
* dateOrDateRangeToDateRange(existing); // returns the same range
|
|
967
1027
|
* ```
|
|
968
1028
|
*/ function dateOrDateRangeToDateRange(startOrDateRange, end) {
|
|
1029
|
+
var result;
|
|
969
1030
|
if (isDate(startOrDateRange)) {
|
|
970
|
-
|
|
1031
|
+
result = {
|
|
971
1032
|
start: startOrDateRange,
|
|
972
1033
|
end: end !== null && end !== void 0 ? end : startOrDateRange
|
|
973
1034
|
};
|
|
974
1035
|
} else {
|
|
975
|
-
|
|
1036
|
+
result = startOrDateRange;
|
|
976
1037
|
}
|
|
1038
|
+
return result;
|
|
977
1039
|
}
|
|
978
1040
|
exports.DateRangeType = void 0;
|
|
979
1041
|
(function(DateRangeType) {
|
|
@@ -1027,6 +1089,9 @@ exports.DateRangeType = void 0;
|
|
|
1027
1089
|
* Creates a {@link DateRange} from the given type and optional parameters. Supports many range
|
|
1028
1090
|
* strategies including fixed periods (day, week, month), directional ranges, and radii.
|
|
1029
1091
|
*
|
|
1092
|
+
* @param input - the range type or full configuration object
|
|
1093
|
+
* @param inputRoundToMinute - optional override to round the date to the start of its minute
|
|
1094
|
+
* @returns a computed DateRange
|
|
1030
1095
|
* @throws Error if the type is not a recognized {@link DateRangeType}
|
|
1031
1096
|
*
|
|
1032
1097
|
* @example
|
|
@@ -1060,25 +1125,27 @@ exports.DateRangeType = void 0;
|
|
|
1060
1125
|
start = startOfFn(preStart);
|
|
1061
1126
|
end = endOfFn(preEnd);
|
|
1062
1127
|
}
|
|
1063
|
-
function calculateStartAndEndForBetween(
|
|
1064
|
-
var
|
|
1128
|
+
function calculateStartAndEndForBetween(config) {
|
|
1129
|
+
var addFn = config.addFn, tmp = config.distance, betweenDistance = tmp === void 0 ? 0 : tmp, startOfFn = config.startOfFn, endOfFn = config.endOfFn;
|
|
1065
1130
|
var preStart;
|
|
1066
1131
|
var preEnd;
|
|
1067
|
-
switch(
|
|
1132
|
+
switch(betweenDistance){
|
|
1068
1133
|
case 0:
|
|
1069
1134
|
preStart = date;
|
|
1070
1135
|
preEnd = date;
|
|
1071
1136
|
break;
|
|
1072
1137
|
default:
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1138
|
+
{
|
|
1139
|
+
var hasNegativeDistance = betweenDistance < 0;
|
|
1140
|
+
if (hasNegativeDistance) {
|
|
1141
|
+
preStart = addFn(date, betweenDistance);
|
|
1142
|
+
preEnd = date;
|
|
1143
|
+
} else {
|
|
1144
|
+
preStart = date;
|
|
1145
|
+
preEnd = addFn(date, betweenDistance);
|
|
1146
|
+
}
|
|
1147
|
+
break;
|
|
1080
1148
|
}
|
|
1081
|
-
break;
|
|
1082
1149
|
}
|
|
1083
1150
|
start = startOfFn(preStart);
|
|
1084
1151
|
end = endOfFn(preEnd);
|
|
@@ -1100,19 +1167,44 @@ exports.DateRangeType = void 0;
|
|
|
1100
1167
|
calculateStartAndEndForDate(dateFns.startOfMinute, dateFns.endOfMinute);
|
|
1101
1168
|
break;
|
|
1102
1169
|
case exports.DateRangeType.MINUTES_RANGE:
|
|
1103
|
-
calculateStartAndEndForBetween(
|
|
1170
|
+
calculateStartAndEndForBetween({
|
|
1171
|
+
addFn: dateFns.addMinutes,
|
|
1172
|
+
distance: rawDistance,
|
|
1173
|
+
startOfFn: dateFns.startOfMinute,
|
|
1174
|
+
endOfFn: dateFns.endOfMinute
|
|
1175
|
+
});
|
|
1104
1176
|
break;
|
|
1105
1177
|
case exports.DateRangeType.HOURS_RANGE:
|
|
1106
|
-
calculateStartAndEndForBetween(
|
|
1178
|
+
calculateStartAndEndForBetween({
|
|
1179
|
+
addFn: dateFns.addHours,
|
|
1180
|
+
distance: rawDistance,
|
|
1181
|
+
startOfFn: dateFns.startOfHour,
|
|
1182
|
+
endOfFn: dateFns.endOfHour
|
|
1183
|
+
});
|
|
1107
1184
|
break;
|
|
1108
1185
|
case exports.DateRangeType.DAYS_RANGE:
|
|
1109
|
-
calculateStartAndEndForBetween(
|
|
1186
|
+
calculateStartAndEndForBetween({
|
|
1187
|
+
addFn: dateFns.addDays,
|
|
1188
|
+
distance: rawDistance,
|
|
1189
|
+
startOfFn: dateFns.startOfDay,
|
|
1190
|
+
endOfFn: dateFns.endOfDay
|
|
1191
|
+
});
|
|
1110
1192
|
break;
|
|
1111
1193
|
case exports.DateRangeType.WEEKS_RANGE:
|
|
1112
|
-
calculateStartAndEndForBetween(
|
|
1194
|
+
calculateStartAndEndForBetween({
|
|
1195
|
+
addFn: dateFns.addWeeks,
|
|
1196
|
+
distance: rawDistance,
|
|
1197
|
+
startOfFn: dateFns.startOfWeek,
|
|
1198
|
+
endOfFn: dateFns.endOfWeek
|
|
1199
|
+
});
|
|
1113
1200
|
break;
|
|
1114
1201
|
case exports.DateRangeType.MONTHS_RANGE:
|
|
1115
|
-
calculateStartAndEndForBetween(
|
|
1202
|
+
calculateStartAndEndForBetween({
|
|
1203
|
+
addFn: dateFns.addMonths,
|
|
1204
|
+
distance: rawDistance,
|
|
1205
|
+
startOfFn: dateFns.startOfMonth,
|
|
1206
|
+
endOfFn: dateFns.endOfMonth
|
|
1207
|
+
});
|
|
1116
1208
|
break;
|
|
1117
1209
|
case exports.DateRangeType.MINUTES_RADIUS:
|
|
1118
1210
|
distance = Math.abs(distance);
|
|
@@ -1135,10 +1227,12 @@ exports.DateRangeType = void 0;
|
|
|
1135
1227
|
end = dateFns.addDays(date, distance * 7);
|
|
1136
1228
|
break;
|
|
1137
1229
|
case exports.DateRangeType.CALENDAR_MONTH:
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1230
|
+
{
|
|
1231
|
+
var monthStart = dateFns.startOfMonth(dateFns.endOfWeek(date));
|
|
1232
|
+
start = dateFns.startOfWeek(monthStart);
|
|
1233
|
+
end = dateFns.endOfWeek(dateFns.endOfMonth(monthStart));
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1142
1236
|
default:
|
|
1143
1237
|
throw new Error("Unknown date range type: ".concat(type));
|
|
1144
1238
|
}
|
|
@@ -1151,6 +1245,9 @@ exports.DateRangeType = void 0;
|
|
|
1151
1245
|
* Returns a range spanning the full calendar day (first to last millisecond) of the given date.
|
|
1152
1246
|
* Convenience wrapper around {@link dateRange} with {@link DateRangeType.DAY}.
|
|
1153
1247
|
*
|
|
1248
|
+
* @param date - the date whose full day range to return
|
|
1249
|
+
* @returns a DateRange from start of day to end of day
|
|
1250
|
+
*
|
|
1154
1251
|
* @example
|
|
1155
1252
|
* ```ts
|
|
1156
1253
|
* const range = dateRangeFromStartAndEndOfDay(new Date('2024-06-15T14:30:00'));
|
|
@@ -1189,6 +1286,8 @@ var DEFAULT_ITERATE_DAYS_IN_DATE_RANGE_MAX_ITERATIONS = 4000;
|
|
|
1189
1286
|
* Creates a reusable function that iterates over dates within a range using a configurable step function.
|
|
1190
1287
|
* Supports max iteration limits and early bail-out via {@link endItreateDaysInDateRangeEarly}.
|
|
1191
1288
|
*
|
|
1289
|
+
* @param input - configuration or a step function for advancing between dates
|
|
1290
|
+
* @returns a reusable iteration function
|
|
1192
1291
|
* @throws Error if max iterations is exceeded and throwErrorOnMaxIterations is true
|
|
1193
1292
|
*
|
|
1194
1293
|
* @example
|
|
@@ -1242,6 +1341,8 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1242
1341
|
* Creates a reusable function that expands a {@link DateRange} into an array of individual day dates.
|
|
1243
1342
|
* Includes a configurable safety limit to prevent accidental memory exhaustion from large ranges.
|
|
1244
1343
|
*
|
|
1344
|
+
* @param config - optional configuration for the max expansion size
|
|
1345
|
+
* @returns a function that expands a DateRange into an array of Dates
|
|
1245
1346
|
* @throws Error if the range spans more days than the configured maxExpansionSize
|
|
1246
1347
|
*
|
|
1247
1348
|
* @example
|
|
@@ -1271,6 +1372,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1271
1372
|
* Expands a {@link DateRange} into an array of one Date per day. Uses the default max expansion size.
|
|
1272
1373
|
* Convenience wrapper around {@link expandDaysForDateRangeFunction}.
|
|
1273
1374
|
*
|
|
1375
|
+
* @param range - the date range to expand
|
|
1376
|
+
* @returns an array of Dates, one per day in the range
|
|
1377
|
+
*
|
|
1274
1378
|
* @example
|
|
1275
1379
|
* ```ts
|
|
1276
1380
|
* const days = expandDaysForDateRange({ start: new Date('2024-01-01'), end: new Date('2024-01-03') });
|
|
@@ -1282,6 +1386,12 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1282
1386
|
/**
|
|
1283
1387
|
* Determines whether the current moment (or provided `now`) falls before, within, or after the given range.
|
|
1284
1388
|
*
|
|
1389
|
+
* @param dateRange - the date range to compare against
|
|
1390
|
+
* @param dateRange.start - the start of the range
|
|
1391
|
+
* @param dateRange.end - the end of the range
|
|
1392
|
+
* @param now - the reference date, defaults to the current moment
|
|
1393
|
+
* @returns 'past', 'present', or 'future'
|
|
1394
|
+
*
|
|
1285
1395
|
* @example
|
|
1286
1396
|
* ```ts
|
|
1287
1397
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1291,17 +1401,23 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1291
1401
|
* ```
|
|
1292
1402
|
*/ function dateRangeRelativeState(param) {
|
|
1293
1403
|
var start = param.start, end = param.end, now = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Date();
|
|
1404
|
+
var result;
|
|
1294
1405
|
if (dateFns.isAfter(now, end)) {
|
|
1295
|
-
|
|
1406
|
+
result = 'past';
|
|
1296
1407
|
} else if (dateFns.isBefore(now, start)) {
|
|
1297
|
-
|
|
1408
|
+
result = 'future';
|
|
1298
1409
|
} else {
|
|
1299
|
-
|
|
1410
|
+
result = 'present';
|
|
1300
1411
|
}
|
|
1412
|
+
return result;
|
|
1301
1413
|
}
|
|
1302
1414
|
/**
|
|
1303
1415
|
* Groups an array of date ranges into past, present, and future buckets based on the current moment (or provided `now`).
|
|
1304
1416
|
*
|
|
1417
|
+
* @param dateRanges - the date ranges to group
|
|
1418
|
+
* @param _now - the reference date, defaults to the current moment
|
|
1419
|
+
* @returns an object with past, present, and future arrays
|
|
1420
|
+
*
|
|
1305
1421
|
* @example
|
|
1306
1422
|
* ```ts
|
|
1307
1423
|
* const ranges = [
|
|
@@ -1320,6 +1436,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1320
1436
|
* Checks whether a date falls within a (possibly partial) date range.
|
|
1321
1437
|
* Convenience wrapper around {@link isDateInDateRangeFunction}.
|
|
1322
1438
|
*
|
|
1439
|
+
* @param date - the date to test
|
|
1440
|
+
* @param dateRange - the range to test against
|
|
1441
|
+
* @returns true if the date falls within the range
|
|
1442
|
+
*
|
|
1323
1443
|
* @example
|
|
1324
1444
|
* ```ts
|
|
1325
1445
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1334,6 +1454,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1334
1454
|
* Handles partial ranges: if only start is set, checks >= start; if only end, checks <= end;
|
|
1335
1455
|
* if neither, all dates are considered in range.
|
|
1336
1456
|
*
|
|
1457
|
+
* @param dateRange - the boundary range to test against
|
|
1458
|
+
* @returns a function that tests whether a date falls within the range
|
|
1459
|
+
*
|
|
1337
1460
|
* @example
|
|
1338
1461
|
* ```ts
|
|
1339
1462
|
* const isInQ1 = isDateInDateRangeFunction({
|
|
@@ -1368,7 +1491,7 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1368
1491
|
return time <= endTime1;
|
|
1369
1492
|
};
|
|
1370
1493
|
} else {
|
|
1371
|
-
fn = function fn(
|
|
1494
|
+
fn = function fn(_input) {
|
|
1372
1495
|
return true;
|
|
1373
1496
|
};
|
|
1374
1497
|
}
|
|
@@ -1379,6 +1502,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1379
1502
|
* Checks whether a date range is fully contained within another (possibly partial) date range.
|
|
1380
1503
|
* Convenience wrapper around {@link isDateRangeInDateRangeFunction}.
|
|
1381
1504
|
*
|
|
1505
|
+
* @param compareDateRange - the range to test for containment
|
|
1506
|
+
* @param dateRange - the boundary range
|
|
1507
|
+
* @returns true if compareDateRange is fully within dateRange
|
|
1508
|
+
*
|
|
1382
1509
|
* @example
|
|
1383
1510
|
* ```ts
|
|
1384
1511
|
* const outer = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1392,6 +1519,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1392
1519
|
* Creates a reusable function that tests whether a given date range is fully contained within
|
|
1393
1520
|
* the configured boundary range. Both start and end of the input must be within bounds.
|
|
1394
1521
|
*
|
|
1522
|
+
* @param dateRange - the boundary range
|
|
1523
|
+
* @returns a function that tests containment of other ranges
|
|
1524
|
+
*
|
|
1395
1525
|
* @example
|
|
1396
1526
|
* ```ts
|
|
1397
1527
|
* const isInYear = isDateRangeInDateRangeFunction({
|
|
@@ -1413,6 +1543,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1413
1543
|
* Checks whether two date ranges overlap in any way (partial or full).
|
|
1414
1544
|
* Convenience wrapper around {@link dateRangeOverlapsDateRangeFunction}.
|
|
1415
1545
|
*
|
|
1546
|
+
* @param compareDateRange - the range to test for overlap
|
|
1547
|
+
* @param dateRange - the reference range
|
|
1548
|
+
* @returns true if the ranges overlap
|
|
1549
|
+
*
|
|
1416
1550
|
* @example
|
|
1417
1551
|
* ```ts
|
|
1418
1552
|
* const a = { start: new Date('2024-01-01'), end: new Date('2024-06-30') };
|
|
@@ -1426,6 +1560,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1426
1560
|
* Creates a reusable function that tests whether input ranges overlap the configured boundary range.
|
|
1427
1561
|
* Two ranges overlap if one starts before the other ends, and vice versa.
|
|
1428
1562
|
*
|
|
1563
|
+
* @param dateRange - the boundary range to test overlap against
|
|
1564
|
+
* @returns a function that tests overlap of other ranges
|
|
1565
|
+
*
|
|
1429
1566
|
* @example
|
|
1430
1567
|
* ```ts
|
|
1431
1568
|
* const overlapsQ1 = dateRangeOverlapsDateRangeFunction({
|
|
@@ -1457,6 +1594,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1457
1594
|
*
|
|
1458
1595
|
* Operates in UTC, so daylight savings transitions are not considered.
|
|
1459
1596
|
*
|
|
1597
|
+
* @param dateRange - the date range to fit into a single day period
|
|
1598
|
+
* @returns a new date range with the same start and an end within 24 hours of start
|
|
1599
|
+
*
|
|
1460
1600
|
* @example
|
|
1461
1601
|
* ```ts
|
|
1462
1602
|
* // 10AM to 1PM across 3 days becomes same-day 10AM to 1PM
|
|
@@ -1484,6 +1624,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1484
1624
|
* Dates before start are clamped to start; dates after end are clamped to end.
|
|
1485
1625
|
* Partial ranges clamp only on the side that is defined.
|
|
1486
1626
|
*
|
|
1627
|
+
* @param dateRange - the boundary range for clamping
|
|
1628
|
+
* @returns a function that clamps dates to the range
|
|
1629
|
+
*
|
|
1487
1630
|
* @example
|
|
1488
1631
|
* ```ts
|
|
1489
1632
|
* const clamp = clampDateFunction({
|
|
@@ -1499,15 +1642,16 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1499
1642
|
var hasStartDate = dateRange.start != null;
|
|
1500
1643
|
var hasEndDate = dateRange.end != null;
|
|
1501
1644
|
if (hasStartDate || hasEndDate) {
|
|
1645
|
+
var _ref, _ref1;
|
|
1502
1646
|
var _dateRange_start, _dateRange_end;
|
|
1503
1647
|
// Start Clamp
|
|
1504
|
-
var startTime = ((_dateRange_start = dateRange.start) === null || _dateRange_start === void 0 ? void 0 : _dateRange_start.getTime())
|
|
1648
|
+
var startTime = (_ref = (_dateRange_start = dateRange.start) === null || _dateRange_start === void 0 ? void 0 : _dateRange_start.getTime()) !== null && _ref !== void 0 ? _ref : 0;
|
|
1505
1649
|
var clampStart = function clampStart(input) {
|
|
1506
1650
|
var time = input.getTime();
|
|
1507
1651
|
return time >= startTime ? input : dateRange.start;
|
|
1508
1652
|
};
|
|
1509
1653
|
// End Clamp
|
|
1510
|
-
var endTime = ((_dateRange_end = dateRange.end) === null || _dateRange_end === void 0 ? void 0 : _dateRange_end.getTime())
|
|
1654
|
+
var endTime = (_ref1 = (_dateRange_end = dateRange.end) === null || _dateRange_end === void 0 ? void 0 : _dateRange_end.getTime()) !== null && _ref1 !== void 0 ? _ref1 : 0;
|
|
1511
1655
|
var clampEnd = function clampEnd(input) {
|
|
1512
1656
|
var time = input.getTime();
|
|
1513
1657
|
return time <= endTime ? input : dateRange.end;
|
|
@@ -1537,6 +1681,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1537
1681
|
* Clamps a single date to fall within the given range boundaries.
|
|
1538
1682
|
* Convenience wrapper around {@link clampDateFunction}.
|
|
1539
1683
|
*
|
|
1684
|
+
* @param date - the date to clamp
|
|
1685
|
+
* @param dateRange - the boundary range
|
|
1686
|
+
* @returns the clamped date
|
|
1687
|
+
*
|
|
1540
1688
|
* @example
|
|
1541
1689
|
* ```ts
|
|
1542
1690
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1564,6 +1712,10 @@ function clampDateRangeFunction(dateRange) {
|
|
|
1564
1712
|
* Clamps a date range to fit within a boundary range.
|
|
1565
1713
|
* Convenience wrapper around {@link clampDateRangeFunction}.
|
|
1566
1714
|
*
|
|
1715
|
+
* @param inputDateRange - the date range to clamp
|
|
1716
|
+
* @param limitToDateRange - the boundary range
|
|
1717
|
+
* @returns the clamped date range
|
|
1718
|
+
*
|
|
1567
1719
|
* @example
|
|
1568
1720
|
* ```ts
|
|
1569
1721
|
* const input = { start: new Date('2023-06-01'), end: new Date('2024-06-30') };
|
|
@@ -1577,6 +1729,9 @@ function clampDateRangeFunction(dateRange) {
|
|
|
1577
1729
|
/**
|
|
1578
1730
|
* Creates a function that applies a date transformation to both start and end of a {@link DateRange}.
|
|
1579
1731
|
*
|
|
1732
|
+
* @param transform - the transformation to apply to both dates
|
|
1733
|
+
* @returns a function that transforms both dates of a DateRange
|
|
1734
|
+
*
|
|
1580
1735
|
* @example
|
|
1581
1736
|
* ```ts
|
|
1582
1737
|
* import { startOfHour } from 'date-fns';
|
|
@@ -1600,6 +1755,9 @@ function clampDateRangeFunction(dateRange) {
|
|
|
1600
1755
|
* Returns each unique day of the week present in the range, in the order they appear starting from
|
|
1601
1756
|
* the range's start day. For ranges spanning 7+ days, returns all days of the week.
|
|
1602
1757
|
*
|
|
1758
|
+
* @param dateRange - the date range to inspect
|
|
1759
|
+
* @returns an array of unique day-of-week values present in the range
|
|
1760
|
+
*
|
|
1603
1761
|
* @example
|
|
1604
1762
|
* ```ts
|
|
1605
1763
|
* // Wednesday through Friday
|
|
@@ -1763,8 +1921,11 @@ function _type_of$6(obj) {
|
|
|
1763
1921
|
* isValidDateTimezoneConversionConfig({ timezone: 'America/Chicago' }); // true
|
|
1764
1922
|
* isValidDateTimezoneConversionConfig({}); // false
|
|
1765
1923
|
* ```
|
|
1924
|
+
*
|
|
1925
|
+
* @param input - the conversion config to validate
|
|
1926
|
+
* @returns true if the config has at least one meaningful conversion property set
|
|
1766
1927
|
*/ function isValidDateTimezoneConversionConfig(input) {
|
|
1767
|
-
return input.useSystemTimezone || input.timezone != null || input.timezoneOffset != null || input.noConversion
|
|
1928
|
+
return input.useSystemTimezone === true || input.timezone != null || input.timezoneOffset != null || input.noConversion === true;
|
|
1768
1929
|
}
|
|
1769
1930
|
/**
|
|
1770
1931
|
* Compares two configs for logical equivalence, accounting for the fact that
|
|
@@ -1775,12 +1936,16 @@ function _type_of$6(obj) {
|
|
|
1775
1936
|
* isSameDateTimezoneConversionConfig({ timezone: 'UTC' }, { timezone: undefined }); // true
|
|
1776
1937
|
* isSameDateTimezoneConversionConfig({ useSystemTimezone: true }, { timezone: 'America/Denver' }); // false
|
|
1777
1938
|
* ```
|
|
1939
|
+
*
|
|
1940
|
+
* @param a - first conversion config to compare
|
|
1941
|
+
* @param b - second conversion config to compare
|
|
1942
|
+
* @returns true if both configs are logically equivalent
|
|
1778
1943
|
*/ function isSameDateTimezoneConversionConfig(a, b) {
|
|
1779
1944
|
var isSame = false;
|
|
1780
1945
|
if (a.useSystemTimezone || b.useSystemTimezone || a.timezoneOffset || b.timezoneOffset) {
|
|
1781
1946
|
isSame = util.isSameNonNullValue(a.useSystemTimezone, b.useSystemTimezone) || util.isSameNonNullValue(a.timezoneOffset, b.timezoneOffset);
|
|
1782
1947
|
} else {
|
|
1783
|
-
isSame = util.isConsideredUtcTimezoneString(a.timezone) && util.isConsideredUtcTimezoneString(b.timezone) || a
|
|
1948
|
+
isSame = util.isConsideredUtcTimezoneString(a.timezone) && util.isConsideredUtcTimezoneString(b.timezone) || a === b;
|
|
1784
1949
|
}
|
|
1785
1950
|
return isSame;
|
|
1786
1951
|
}
|
|
@@ -1799,6 +1964,7 @@ function _type_of$6(obj) {
|
|
|
1799
1964
|
* ```
|
|
1800
1965
|
*
|
|
1801
1966
|
* @param date - required to determine the correct offset for that instant (DST-aware)
|
|
1967
|
+
* @returns the system timezone UTC offset in milliseconds
|
|
1802
1968
|
*/ function getCurrentSystemOffsetInMs(date) {
|
|
1803
1969
|
// Use native getTimezoneOffset() instead of calculateTimezoneOffset() to avoid
|
|
1804
1970
|
// a DST edge case where toZonedTime() creates an epoch that lands on the system's
|
|
@@ -1815,6 +1981,7 @@ function _type_of$6(obj) {
|
|
|
1815
1981
|
* ```
|
|
1816
1982
|
*
|
|
1817
1983
|
* @param date - required to determine the correct offset for that instant (DST-aware)
|
|
1984
|
+
* @returns the system timezone UTC offset truncated to whole hours
|
|
1818
1985
|
*/ function getCurrentSystemOffsetInHours(date) {
|
|
1819
1986
|
return dateFns.millisecondsToHours(getCurrentSystemOffsetInMs(date));
|
|
1820
1987
|
}
|
|
@@ -1831,6 +1998,7 @@ function _type_of$6(obj) {
|
|
|
1831
1998
|
* ```
|
|
1832
1999
|
*
|
|
1833
2000
|
* @param date - required to determine the correct offset for that instant (DST-aware)
|
|
2001
|
+
* @returns the system timezone UTC offset in minutes
|
|
1834
2002
|
*/ function getCurrentSystemOffsetInMinutes(date) {
|
|
1835
2003
|
return dateFns.millisecondsToMinutes(getCurrentSystemOffsetInMs(date));
|
|
1836
2004
|
}
|
|
@@ -1851,6 +2019,7 @@ function _type_of$6(obj) {
|
|
|
1851
2019
|
*
|
|
1852
2020
|
* @param timezone - IANA timezone string (e.g. 'America/New_York')
|
|
1853
2021
|
* @param date - the instant to evaluate, since DST may shift the offset
|
|
2022
|
+
* @returns the UTC offset for the given timezone at the given instant, in milliseconds
|
|
1854
2023
|
*/ function calculateTimezoneOffset(timezone, date) {
|
|
1855
2024
|
var tzOffset;
|
|
1856
2025
|
// UTC always has zero offset; skip toZonedTime which can produce wrong results
|
|
@@ -1877,7 +2046,15 @@ function _type_of$6(obj) {
|
|
|
1877
2046
|
}
|
|
1878
2047
|
return tzOffset;
|
|
1879
2048
|
}
|
|
1880
|
-
|
|
2049
|
+
/**
|
|
2050
|
+
* Calculates offset values for every pair of conversion targets (target, base, system)
|
|
2051
|
+
* and returns them as a keyed map (e.g. `'target-base'`, `'base-system'`).
|
|
2052
|
+
*
|
|
2053
|
+
* @param date - the reference date used to compute offsets
|
|
2054
|
+
* @param converter - the converter instance providing offset calculations
|
|
2055
|
+
* @param map - optional mapping function applied to each raw millisecond offset
|
|
2056
|
+
* @returns a map of conversion-pair keys to their computed offset values
|
|
2057
|
+
*/ function calculateAllConversions(date, converter) {
|
|
1881
2058
|
var map = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function(x) {
|
|
1882
2059
|
return x;
|
|
1883
2060
|
};
|
|
@@ -1904,6 +2081,9 @@ function calculateAllConversions(date, converter) {
|
|
|
1904
2081
|
* inverseDateTimezoneUtcNormalInstanceTransformType('targetDateToBaseDate'); // 'baseDateToTargetDate'
|
|
1905
2082
|
* inverseDateTimezoneUtcNormalInstanceTransformType('systemDateToTargetDate'); // 'targetDateToSystemDate'
|
|
1906
2083
|
* ```
|
|
2084
|
+
*
|
|
2085
|
+
* @param input - the transform type to invert
|
|
2086
|
+
* @returns the inverse transform type for round-trip conversion
|
|
1907
2087
|
*/ function inverseDateTimezoneUtcNormalInstanceTransformType(input) {
|
|
1908
2088
|
var result;
|
|
1909
2089
|
switch(input){
|
|
@@ -1925,6 +2105,8 @@ function calculateAllConversions(date, converter) {
|
|
|
1925
2105
|
case 'targetDateToSystemDate':
|
|
1926
2106
|
result = 'systemDateToTargetDate';
|
|
1927
2107
|
break;
|
|
2108
|
+
default:
|
|
2109
|
+
throw new Error("Unexpected transform type: ".concat(input));
|
|
1928
2110
|
}
|
|
1929
2111
|
return result;
|
|
1930
2112
|
}
|
|
@@ -1956,8 +2138,7 @@ function calculateAllConversions(date, converter) {
|
|
|
1956
2138
|
};
|
|
1957
2139
|
};
|
|
1958
2140
|
var calculateOffset = function calculateOffset(date) {
|
|
1959
|
-
|
|
1960
|
-
return offset;
|
|
2141
|
+
return getOffsetInMsFn(date);
|
|
1961
2142
|
};
|
|
1962
2143
|
var calculateSystemNormalDifference = function calculateSystemNormalDifference(date) {
|
|
1963
2144
|
var normalOffset = calculateOffset(date);
|
|
@@ -2066,12 +2247,11 @@ function calculateAllConversions(date, converter) {
|
|
|
2066
2247
|
* For example, when daylight savings changed on November 3, 2024 the offset returned was 5 but to get back to the original an offset of 6 was required.
|
|
2067
2248
|
* This is where some contextual data was not being used. This function uses that contextual data to make sure the reverse will be consistent.
|
|
2068
2249
|
*
|
|
2069
|
-
* @param
|
|
2070
|
-
* @
|
|
2071
|
-
* @param fromOrTo the "type" of date the originalContextDate is
|
|
2250
|
+
* @param config - configuration for the safe mirrored conversion
|
|
2251
|
+
* @returns the converted date and the DST offset adjustment applied
|
|
2072
2252
|
*/ key: "safeMirroredConvertDate",
|
|
2073
|
-
value: function safeMirroredConvertDate(
|
|
2074
|
-
var
|
|
2253
|
+
value: function safeMirroredConvertDate(config) {
|
|
2254
|
+
var baseDate = config.baseDate, originalContextDate = config.originalContextDate, contextType = config.contextType, _config_safeConvert = config.safeConvert, safeConvert = _config_safeConvert === void 0 ? true : _config_safeConvert;
|
|
2075
2255
|
if (contextType === 'base') {
|
|
2076
2256
|
return {
|
|
2077
2257
|
date: baseDate,
|
|
@@ -2234,7 +2414,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2234
2414
|
/**
|
|
2235
2415
|
* Returns true if the input is midnight in the target timezone.
|
|
2236
2416
|
*
|
|
2237
|
-
* @param date
|
|
2417
|
+
* @param date - the date to check
|
|
2418
|
+
* @returns true if the date is at the start of the day in the target timezone
|
|
2238
2419
|
*/ key: "isStartOfDayInTargetTimezone",
|
|
2239
2420
|
value: function isStartOfDayInTargetTimezone(date) {
|
|
2240
2421
|
var utcNormal = this.baseDateToTargetDate(date);
|
|
@@ -2245,7 +2426,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2245
2426
|
/**
|
|
2246
2427
|
* Start of the given day in the target timezone.
|
|
2247
2428
|
*
|
|
2248
|
-
* @param date
|
|
2429
|
+
* @param date - the input is treated as an instant in time
|
|
2430
|
+
* @returns the start-of-day date in the target timezone
|
|
2249
2431
|
*/ key: "startOfDayInTargetTimezone",
|
|
2250
2432
|
value: function startOfDayInTargetTimezone(date) {
|
|
2251
2433
|
var baseDay = this.startOfDayInBaseDate(date);
|
|
@@ -2256,7 +2438,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2256
2438
|
/**
|
|
2257
2439
|
* Start of the given day in UTC.
|
|
2258
2440
|
*
|
|
2259
|
-
* @param date
|
|
2441
|
+
* @param date - the date or ISO8601 day string to get the start of day for
|
|
2442
|
+
* @returns the start of the day as a BaseDateAsUTC
|
|
2260
2443
|
*/ key: "startOfDayInBaseDate",
|
|
2261
2444
|
value: function startOfDayInBaseDate(date) {
|
|
2262
2445
|
if (typeof date === 'string') {
|
|
@@ -2271,8 +2454,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2271
2454
|
/**
|
|
2272
2455
|
* End of the given day in UTC.
|
|
2273
2456
|
*
|
|
2274
|
-
* @param date
|
|
2275
|
-
* @returns
|
|
2457
|
+
* @param date - the date or ISO8601 day string to get the end of day for
|
|
2458
|
+
* @returns the end of the day as a BaseDateAsUTC (23:59:59.999)
|
|
2276
2459
|
*/ key: "endOfDayInBaseDate",
|
|
2277
2460
|
value: function endOfDayInBaseDate(date) {
|
|
2278
2461
|
var result = this.startOfDayInBaseDate(date);
|
|
@@ -2284,8 +2467,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2284
2467
|
/**
|
|
2285
2468
|
* Start of the given day for the system.
|
|
2286
2469
|
*
|
|
2287
|
-
* @param date
|
|
2288
|
-
* @returns
|
|
2470
|
+
* @param date - the date or ISO8601 day string to get the start of day for
|
|
2471
|
+
* @returns the start of the day in the system timezone
|
|
2289
2472
|
*/ key: "startOfDayInSystemDate",
|
|
2290
2473
|
value: function startOfDayInSystemDate(date) {
|
|
2291
2474
|
if (typeof date === 'string') {
|
|
@@ -2300,8 +2483,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2300
2483
|
/**
|
|
2301
2484
|
* End of the given day for the system.
|
|
2302
2485
|
*
|
|
2303
|
-
* @param date
|
|
2304
|
-
* @returns
|
|
2486
|
+
* @param date - the date or ISO8601 day string to get the end of day for
|
|
2487
|
+
* @returns the end of the day in the system timezone
|
|
2305
2488
|
*/ key: "endOfDayInSystemDate",
|
|
2306
2489
|
value: function endOfDayInSystemDate(date) {
|
|
2307
2490
|
return dateFns.endOfDay(this.startOfDayInSystemDate(date));
|
|
@@ -2309,9 +2492,10 @@ function calculateAllConversions(date, converter) {
|
|
|
2309
2492
|
},
|
|
2310
2493
|
{
|
|
2311
2494
|
/**
|
|
2312
|
-
* Whether or not the
|
|
2495
|
+
* Whether or not the target timezone experiences daylight savings for the given year.
|
|
2313
2496
|
*
|
|
2314
|
-
* @param year
|
|
2497
|
+
* @param year - the year to check, as a Date or number; defaults to the current year
|
|
2498
|
+
* @returns true if the target timezone has different offsets in January and July
|
|
2315
2499
|
*/ key: "targetTimezoneExperiencesDaylightSavings",
|
|
2316
2500
|
value: function targetTimezoneExperiencesDaylightSavings() {
|
|
2317
2501
|
var year = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
@@ -2368,6 +2552,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2368
2552
|
* const same = dateTimezoneUtcNormal(denver); // same reference
|
|
2369
2553
|
* ```
|
|
2370
2554
|
*
|
|
2555
|
+
* @param config - timezone input: an existing instance, timezone string, millisecond offset, or config object
|
|
2556
|
+
* @returns a DateTimezoneUtcNormalInstance for the given input
|
|
2371
2557
|
* @throws Error if the input type is not recognized
|
|
2372
2558
|
*/ function dateTimezoneUtcNormal(config) {
|
|
2373
2559
|
var instance;
|
|
@@ -2375,6 +2561,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2375
2561
|
instance = config;
|
|
2376
2562
|
} else {
|
|
2377
2563
|
var type = typeof config === "undefined" ? "undefined" : _type_of$6(config);
|
|
2564
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
2378
2565
|
switch(type){
|
|
2379
2566
|
case 'object':
|
|
2380
2567
|
instance = new DateTimezoneUtcNormalInstance(config);
|
|
@@ -2390,7 +2577,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2390
2577
|
});
|
|
2391
2578
|
break;
|
|
2392
2579
|
default:
|
|
2393
|
-
throw new Error('Invalid input passed to dateTimezoneUtcNormal()');
|
|
2580
|
+
throw new Error('Invalid input type "'.concat(type, '" passed to dateTimezoneUtcNormal()'));
|
|
2394
2581
|
}
|
|
2395
2582
|
}
|
|
2396
2583
|
return instance;
|
|
@@ -2413,6 +2600,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2413
2600
|
*
|
|
2414
2601
|
* Prefer this over constructing a new instance when you need system-timezone conversions,
|
|
2415
2602
|
* as the singleton avoids unnecessary allocations.
|
|
2603
|
+
*
|
|
2604
|
+
* @returns the shared system-timezone DateTimezoneUtcNormalInstance singleton
|
|
2416
2605
|
*/ function systemDateTimezoneUtcNormal() {
|
|
2417
2606
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE;
|
|
2418
2607
|
}
|
|
@@ -2429,10 +2618,13 @@ function calculateAllConversions(date, converter) {
|
|
|
2429
2618
|
* const target = baseDateToTargetDate(base, 'America/Denver');
|
|
2430
2619
|
* // target is 2024-06-15T14:00:00.000-06:00 (2PM MDT)
|
|
2431
2620
|
* ```
|
|
2621
|
+
*
|
|
2622
|
+
* @param date - the BaseDateAsUTC to convert
|
|
2623
|
+
* @param timezone - the target IANA timezone string
|
|
2624
|
+
* @returns a real instant in the specified timezone
|
|
2432
2625
|
*/ function baseDateToTargetDate(date, timezone) {
|
|
2433
2626
|
var instance = new DateTimezoneUtcNormalInstance(timezone);
|
|
2434
|
-
|
|
2435
|
-
return result;
|
|
2627
|
+
return instance.baseDateToTargetDate(date);
|
|
2436
2628
|
}
|
|
2437
2629
|
/**
|
|
2438
2630
|
* Convenience function that strips the timezone offset from a target-timezone date,
|
|
@@ -2447,30 +2639,46 @@ function calculateAllConversions(date, converter) {
|
|
|
2447
2639
|
* const base = targetDateToBaseDate(target, 'America/Denver');
|
|
2448
2640
|
* // base is 2024-06-15T14:00:00.000Z — wall-clock 2PM preserved as UTC
|
|
2449
2641
|
* ```
|
|
2642
|
+
*
|
|
2643
|
+
* @param date - the target-timezone date to convert
|
|
2644
|
+
* @param timezone - the IANA timezone the date is expressed in
|
|
2645
|
+
* @returns a BaseDateAsUTC with wall-clock time preserved as UTC
|
|
2450
2646
|
*/ function targetDateToBaseDate(date, timezone) {
|
|
2451
2647
|
return new DateTimezoneUtcNormalInstance(timezone).targetDateToBaseDate(date);
|
|
2452
2648
|
}
|
|
2453
2649
|
/**
|
|
2454
2650
|
* Converts a {@link BaseDateAsUTC} to a target date in the system's local timezone
|
|
2455
2651
|
* using the shared system-timezone instance.
|
|
2652
|
+
*
|
|
2653
|
+
* @param date - the BaseDateAsUTC to convert
|
|
2654
|
+
* @returns the date converted to the system's local timezone
|
|
2456
2655
|
*/ function systemBaseDateToNormalDate(date) {
|
|
2457
2656
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.baseDateToTargetDate(date);
|
|
2458
2657
|
}
|
|
2459
2658
|
/**
|
|
2460
2659
|
* Converts a target date in the system's local timezone back to a {@link BaseDateAsUTC}
|
|
2461
2660
|
* using the shared system-timezone instance.
|
|
2661
|
+
*
|
|
2662
|
+
* @param date - the system-timezone target date to convert back to base
|
|
2663
|
+
* @returns the corresponding BaseDateAsUTC
|
|
2462
2664
|
*/ function systemNormalDateToBaseDate(date) {
|
|
2463
2665
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.targetDateToBaseDate(date);
|
|
2464
2666
|
}
|
|
2465
2667
|
/**
|
|
2466
2668
|
* Returns the millisecond offset needed to convert a {@link BaseDateAsUTC} to a target date
|
|
2467
2669
|
* in the system's local timezone.
|
|
2670
|
+
*
|
|
2671
|
+
* @param date - the date to compute the offset for
|
|
2672
|
+
* @returns the offset in milliseconds
|
|
2468
2673
|
*/ function systemBaseDateToNormalDateOffset(date) {
|
|
2469
2674
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.baseDateToTargetDateOffset(date);
|
|
2470
2675
|
}
|
|
2471
2676
|
/**
|
|
2472
2677
|
* Returns the millisecond offset needed to convert a target date in the system's
|
|
2473
2678
|
* local timezone back to a {@link BaseDateAsUTC}.
|
|
2679
|
+
*
|
|
2680
|
+
* @param date - the date to compute the offset for
|
|
2681
|
+
* @returns the offset in milliseconds
|
|
2474
2682
|
*/ function systemNormalDateToBaseDateOffset(date) {
|
|
2475
2683
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.targetDateToBaseDateOffset(date);
|
|
2476
2684
|
}
|
|
@@ -2478,6 +2686,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2478
2686
|
* Returns whether the system's local timezone observes daylight saving time in the given year.
|
|
2479
2687
|
*
|
|
2480
2688
|
* Compares the offset on January 1 and July 1; if they differ, DST is in effect for part of the year.
|
|
2689
|
+
*
|
|
2690
|
+
* @param year - the year to check, as a Date
|
|
2691
|
+
* @returns true if the system timezone observes DST in the given year
|
|
2481
2692
|
*/ function systemExperiencesDaylightSavings(year) {
|
|
2482
2693
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.targetTimezoneExperiencesDaylightSavings(year);
|
|
2483
2694
|
}
|
|
@@ -2493,7 +2704,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2493
2704
|
* const result = fn(someDate, (d) => startOfDay(d));
|
|
2494
2705
|
* ```
|
|
2495
2706
|
*
|
|
2707
|
+
* @param timezoneInput - timezone configuration for the conversion
|
|
2496
2708
|
* @param transformType - defaults to `'systemDateToTargetDate'`
|
|
2709
|
+
* @returns a function that transforms dates within the specified timezone normalization
|
|
2497
2710
|
*/ function transformDateInTimezoneNormalFunction(timezoneInput) {
|
|
2498
2711
|
var transformType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'systemDateToTargetDate';
|
|
2499
2712
|
var timezoneInstance = dateTimezoneUtcNormal(timezoneInput);
|
|
@@ -2512,7 +2725,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2512
2725
|
* Creates a {@link TransformDateRangeToTimezoneFunction} that converts both dates in
|
|
2513
2726
|
* a {@link DateRange} using the specified transform type.
|
|
2514
2727
|
*
|
|
2728
|
+
* @param timezoneInput - timezone configuration for the conversion
|
|
2515
2729
|
* @param transformType - defaults to `'systemDateToTargetDate'`
|
|
2730
|
+
* @returns a function that converts DateRange dates using the specified transform
|
|
2516
2731
|
*/ function transformDateRangeToTimezoneFunction(timezoneInput) {
|
|
2517
2732
|
var transformType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'systemDateToTargetDate';
|
|
2518
2733
|
var timezoneInstance = dateTimezoneUtcNormal(timezoneInput);
|
|
@@ -2525,7 +2740,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2525
2740
|
* Creates a {@link TransformDateRangeInTimezoneNormalFunction} that converts a date range
|
|
2526
2741
|
* into the specified date space, applies a user-provided range transformation, then converts back.
|
|
2527
2742
|
*
|
|
2743
|
+
* @param timezoneInput - timezone configuration for the conversion
|
|
2528
2744
|
* @param transformType - defaults to `'systemDateToTargetDate'`
|
|
2745
|
+
* @returns a function that transforms date ranges within the specified timezone normalization
|
|
2529
2746
|
*/ function transformDateRangeInTimezoneNormalFunction(timezoneInput) {
|
|
2530
2747
|
var transformType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'systemDateToTargetDate';
|
|
2531
2748
|
var timezoneInstance = dateTimezoneUtcNormal(timezoneInput);
|
|
@@ -2549,6 +2766,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2549
2766
|
* const midnight = startOfDayInDenver('2024-06-15');
|
|
2550
2767
|
* // midnight is 2024-06-15T06:00:00.000Z (midnight MDT = 6AM UTC)
|
|
2551
2768
|
* ```
|
|
2769
|
+
*
|
|
2770
|
+
* @param timezone - timezone configuration to bind the factory to
|
|
2771
|
+
* @returns a factory that converts ISO8601 day strings to start-of-day dates
|
|
2552
2772
|
*/ function startOfDayInTimezoneDayStringFactory(timezone) {
|
|
2553
2773
|
var timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
2554
2774
|
return function(day) {
|
|
@@ -2564,6 +2784,10 @@ function calculateAllConversions(date, converter) {
|
|
|
2564
2784
|
* ```ts
|
|
2565
2785
|
* const midnight = startOfDayInTimezoneFromISO8601DayString('2024-06-15', 'America/Denver');
|
|
2566
2786
|
* ```
|
|
2787
|
+
*
|
|
2788
|
+
* @param day - the ISO8601 day string to parse
|
|
2789
|
+
* @param timezone - timezone configuration for the start-of-day calculation
|
|
2790
|
+
* @returns the start-of-day instant in the given timezone
|
|
2567
2791
|
*/ function startOfDayInTimezoneFromISO8601DayString(day, timezone) {
|
|
2568
2792
|
return startOfDayInTimezoneDayStringFactory(timezone)(day);
|
|
2569
2793
|
}
|
|
@@ -2580,8 +2804,12 @@ function calculateAllConversions(date, converter) {
|
|
|
2580
2804
|
* const result = setOnDate({ date: someDate, hours: 14, minutes: 30, inputType: 'target' });
|
|
2581
2805
|
* // result is someDate with hours set to 14:30 in Denver time
|
|
2582
2806
|
* ```
|
|
2807
|
+
*
|
|
2808
|
+
* @param timezone - the timezone configuration to bind to
|
|
2809
|
+
* @returns a function that sets hours/minutes on dates in the given timezone
|
|
2583
2810
|
*/ function setOnDateWithTimezoneNormalFunction(timezone) {
|
|
2584
2811
|
var timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
2812
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
2585
2813
|
var fn = function fn(input) {
|
|
2586
2814
|
var inputDate = input.date, copyFromInput = input.copyFrom, copyHours = input.copyHours, copyMinutes = input.copyMinutes, inputInputType = input.inputType, outputType = input.outputType, inputHours = input.hours, inputMinutes = input.minutes, roundDownToMinute = input.roundDownToMinute;
|
|
2587
2815
|
var DEFAULT_TYPE = 'target';
|
|
@@ -2597,7 +2825,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2597
2825
|
return roundDownToMinute ? roundDateDownTo(inputDate, 'minute') : inputDate;
|
|
2598
2826
|
}
|
|
2599
2827
|
if (inputType !== 'base') {
|
|
2600
|
-
copyFrom =
|
|
2828
|
+
copyFrom = timezoneInstance.convertDate(copyFrom, 'base', inputType);
|
|
2601
2829
|
}
|
|
2602
2830
|
}
|
|
2603
2831
|
// set baseDate
|
|
@@ -2646,6 +2874,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2646
2874
|
*
|
|
2647
2875
|
* @param input - the date whose day is preserved
|
|
2648
2876
|
* @param timezone - the timezone context for the hour/minute interpretation
|
|
2877
|
+
* @returns the input date with hours and minutes set to the current time in the given timezone
|
|
2649
2878
|
*/ function copyHoursAndMinutesFromNowWithTimezoneNormal(input, timezone) {
|
|
2650
2879
|
return copyHoursAndMinutesFromDateWithTimezoneNormal(input, 'now', timezone);
|
|
2651
2880
|
}
|
|
@@ -2666,16 +2895,16 @@ function calculateAllConversions(date, converter) {
|
|
|
2666
2895
|
* @param input - the date whose day is preserved
|
|
2667
2896
|
* @param copyFrom - the date (or `'now'`) whose hours/minutes are copied
|
|
2668
2897
|
* @param timezone - the timezone context for interpreting both dates
|
|
2898
|
+
* @returns the input date with hours and minutes copied from the source
|
|
2669
2899
|
*/ function copyHoursAndMinutesFromDateWithTimezoneNormal(input, copyFrom, timezone) {
|
|
2670
2900
|
var timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
2671
|
-
|
|
2901
|
+
return timezoneInstance.setOnDate({
|
|
2672
2902
|
date: input,
|
|
2673
2903
|
copyFrom: copyFrom,
|
|
2674
2904
|
inputType: 'target',
|
|
2675
2905
|
copyHours: true,
|
|
2676
2906
|
copyMinutes: true
|
|
2677
2907
|
});
|
|
2678
|
-
return result;
|
|
2679
2908
|
}
|
|
2680
2909
|
|
|
2681
2910
|
function _define_property$e(obj, key, value) {
|
|
@@ -2736,6 +2965,7 @@ function _object_spread$c(target) {
|
|
|
2736
2965
|
*
|
|
2737
2966
|
* @param dateRange - the range to fit
|
|
2738
2967
|
* @param timezone - the timezone for day boundary calculation
|
|
2968
|
+
* @returns the date range fitted to a single day period
|
|
2739
2969
|
*/ function fitDateRangeToDayPeriod(dateRange, timezone) {
|
|
2740
2970
|
return fitDateRangeToDayPeriodFunction(timezone)(dateRange);
|
|
2741
2971
|
}
|
|
@@ -2746,6 +2976,7 @@ function _object_spread$c(target) {
|
|
|
2746
2976
|
* Useful when the same range formatting logic needs to be applied repeatedly with consistent settings.
|
|
2747
2977
|
*
|
|
2748
2978
|
* @param inputConfig - format function or full configuration
|
|
2979
|
+
* @returns a reusable function that formats date ranges into strings
|
|
2749
2980
|
*
|
|
2750
2981
|
* @example
|
|
2751
2982
|
* ```ts
|
|
@@ -2782,6 +3013,7 @@ function _object_spread$c(target) {
|
|
|
2782
3013
|
* @param range - date range to format
|
|
2783
3014
|
* @param inputConfig - format function or full configuration
|
|
2784
3015
|
* @param separator - optional separator override when inputConfig is a function
|
|
3016
|
+
* @returns the formatted date range string
|
|
2785
3017
|
*
|
|
2786
3018
|
* @example
|
|
2787
3019
|
* ```ts
|
|
@@ -2805,6 +3037,7 @@ function _object_spread$c(target) {
|
|
|
2805
3037
|
* (e.g., "3 hours", "about 2 days"). Delegates to date-fns `formatDistance` or `formatDistanceStrict`.
|
|
2806
3038
|
*
|
|
2807
3039
|
* @param inputConfig - controls distance formatting, optional transforms, and same-day handling
|
|
3040
|
+
* @returns a reusable function that computes and formats date range distances
|
|
2808
3041
|
*
|
|
2809
3042
|
* @example
|
|
2810
3043
|
* ```ts
|
|
@@ -2858,6 +3091,7 @@ function _object_spread$c(target) {
|
|
|
2858
3091
|
*
|
|
2859
3092
|
* @param range - date range to compute distance for
|
|
2860
3093
|
* @param inputConfig - optional distance formatting configuration
|
|
3094
|
+
* @returns the human-readable distance string
|
|
2861
3095
|
*
|
|
2862
3096
|
* @example
|
|
2863
3097
|
* ```ts
|
|
@@ -2898,7 +3132,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2898
3132
|
end = endOrFormat;
|
|
2899
3133
|
}
|
|
2900
3134
|
}
|
|
2901
|
-
var format = inputFormat !== null && inputFormat !== void 0 ? inputFormat :
|
|
3135
|
+
var format = inputFormat !== null && inputFormat !== void 0 ? inputFormat : formatToMonthDaySlashDate;
|
|
2902
3136
|
return formatDateRange(dateOrDateRangeToDateRange(startOrDateRange, end), {
|
|
2903
3137
|
format: format,
|
|
2904
3138
|
simplifySameDate: true
|
|
@@ -2909,6 +3143,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2909
3143
|
* instead of throwing.
|
|
2910
3144
|
*
|
|
2911
3145
|
* @param input - date, date string, or nullish value
|
|
3146
|
+
* @returns the ISO 8601 date string, or `undefined` if the input is invalid or nullish
|
|
2912
3147
|
*
|
|
2913
3148
|
* @example
|
|
2914
3149
|
* ```ts
|
|
@@ -2931,6 +3166,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2931
3166
|
* Formats a Date to a full ISO 8601 date-time string via `Date.toISOString()`. Defaults to the current date/time.
|
|
2932
3167
|
*
|
|
2933
3168
|
* @param date - date to format; defaults to `new Date()`
|
|
3169
|
+
* @returns the full ISO 8601 date-time string
|
|
2934
3170
|
*
|
|
2935
3171
|
* @example
|
|
2936
3172
|
* ```ts
|
|
@@ -2950,6 +3186,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2950
3186
|
* Use {@link toISO8601DayStringForUTC} when the UTC date is needed instead.
|
|
2951
3187
|
*
|
|
2952
3188
|
* @param dateOrString - date or existing day string
|
|
3189
|
+
* @returns the ISO 8601 day string in system timezone
|
|
2953
3190
|
*
|
|
2954
3191
|
* @example
|
|
2955
3192
|
* ```ts
|
|
@@ -2969,6 +3206,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2969
3206
|
* Defaults to the current date.
|
|
2970
3207
|
*
|
|
2971
3208
|
* @param date - date to format; defaults to `new Date()`
|
|
3209
|
+
* @returns the ISO 8601 day string in system timezone
|
|
2972
3210
|
*
|
|
2973
3211
|
* @example
|
|
2974
3212
|
* ```ts
|
|
@@ -2988,6 +3226,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2988
3226
|
* Use {@link toISO8601DayStringForSystem} when the system-local date is needed instead.
|
|
2989
3227
|
*
|
|
2990
3228
|
* @param dateOrString - date or existing day string
|
|
3229
|
+
* @returns the ISO 8601 day string in UTC
|
|
2991
3230
|
*
|
|
2992
3231
|
* @example
|
|
2993
3232
|
* ```ts
|
|
@@ -3008,6 +3247,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3008
3247
|
* Defaults to the current date.
|
|
3009
3248
|
*
|
|
3010
3249
|
* @param date - date to format; defaults to `new Date()`
|
|
3250
|
+
* @returns the ISO 8601 day string using UTC date components
|
|
3011
3251
|
*
|
|
3012
3252
|
* @example
|
|
3013
3253
|
* ```ts
|
|
@@ -3020,11 +3260,18 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3020
3260
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
3021
3261
|
return "".concat(date.getUTCFullYear(), "-").concat((date.getUTCMonth() + 1).toString().padStart(2, '0'), "-").concat(date.getUTCDate().toString().padStart(2, '0'));
|
|
3022
3262
|
}
|
|
3023
|
-
/**
|
|
3263
|
+
/**
|
|
3264
|
+
* date-fns format string for `MM/dd/yyyy` (e.g., `"01/15/2024"`).
|
|
3265
|
+
*/ var MONTH_DAY_SLASH_DATE_STRING_FORMAT = 'MM/dd/yyyy';
|
|
3266
|
+
/**
|
|
3267
|
+
* @deprecated Use MONTH_DAY_SLASH_DATE_STRING_FORMAT instead.
|
|
3268
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3269
|
+
var monthDaySlashDateStringFormat = MONTH_DAY_SLASH_DATE_STRING_FORMAT;
|
|
3024
3270
|
/**
|
|
3025
3271
|
* Formats a Date as a month/day/year slash-separated string (`MM/dd/yyyy`). Defaults to the current date.
|
|
3026
3272
|
*
|
|
3027
3273
|
* @param date - date to format; defaults to `new Date()`
|
|
3274
|
+
* @returns the formatted `MM/dd/yyyy` string
|
|
3028
3275
|
*
|
|
3029
3276
|
* @example
|
|
3030
3277
|
* ```ts
|
|
@@ -3035,16 +3282,23 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3035
3282
|
* ```
|
|
3036
3283
|
*/ function formatToMonthDaySlashDate() {
|
|
3037
3284
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
3038
|
-
return dateFns.format(date,
|
|
3285
|
+
return dateFns.format(date, MONTH_DAY_SLASH_DATE_STRING_FORMAT);
|
|
3039
3286
|
}
|
|
3040
3287
|
/**
|
|
3041
3288
|
* @deprecated use formatToMonthDaySlashDate instead.
|
|
3042
3289
|
*/ var formatToShortDateString = formatToMonthDaySlashDate;
|
|
3043
|
-
/**
|
|
3290
|
+
/**
|
|
3291
|
+
* date-fns format string for `MM/dd` (e.g., `"01/15"`).
|
|
3292
|
+
*/ var DATE_MONTH_DAY_STRING_FORMAT = 'MM/dd';
|
|
3293
|
+
/**
|
|
3294
|
+
* @deprecated Use DATE_MONTH_DAY_STRING_FORMAT instead.
|
|
3295
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3296
|
+
var dateMonthDayStringFormat = DATE_MONTH_DAY_STRING_FORMAT;
|
|
3044
3297
|
/**
|
|
3045
3298
|
* Formats a Date as a month/day string (`MM/dd`) without the year. Defaults to the current date.
|
|
3046
3299
|
*
|
|
3047
3300
|
* @param date - date to format; defaults to `new Date()`
|
|
3301
|
+
* @returns the formatted `MM/dd` string
|
|
3048
3302
|
*
|
|
3049
3303
|
* @example
|
|
3050
3304
|
* ```ts
|
|
@@ -3055,12 +3309,13 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3055
3309
|
* ```
|
|
3056
3310
|
*/ function formatToMonthDayString() {
|
|
3057
3311
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
3058
|
-
return dateFns.format(date,
|
|
3312
|
+
return dateFns.format(date, DATE_MONTH_DAY_STRING_FORMAT);
|
|
3059
3313
|
}
|
|
3060
3314
|
/**
|
|
3061
3315
|
* Formats a Date as a human-friendly weekday and month/day string (e.g., `"Mon, Jan 15th"`).
|
|
3062
3316
|
*
|
|
3063
3317
|
* @param date - date to format
|
|
3318
|
+
* @returns the formatted weekday and month/day string
|
|
3064
3319
|
*
|
|
3065
3320
|
* @example
|
|
3066
3321
|
* ```ts
|
|
@@ -3072,11 +3327,18 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3072
3327
|
*/ function formatToDateString(date) {
|
|
3073
3328
|
return dateFns.format(date, 'EEE, MMM do');
|
|
3074
3329
|
}
|
|
3075
|
-
/**
|
|
3330
|
+
/**
|
|
3331
|
+
* date-fns format string for 12-hour time with AM/PM (e.g., `"9:00 AM"`).
|
|
3332
|
+
*/ var DATE_TIME_STRING_FORMAT = 'h:mm a';
|
|
3333
|
+
/**
|
|
3334
|
+
* @deprecated Use DATE_TIME_STRING_FORMAT instead.
|
|
3335
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3336
|
+
var dateTimeStringFormat = DATE_TIME_STRING_FORMAT;
|
|
3076
3337
|
/**
|
|
3077
3338
|
* Formats a Date as a 12-hour time string with AM/PM (e.g., `"9:00 AM"`).
|
|
3078
3339
|
*
|
|
3079
3340
|
* @param date - date to format
|
|
3341
|
+
* @returns the formatted 12-hour time string with AM/PM
|
|
3080
3342
|
*
|
|
3081
3343
|
* @example
|
|
3082
3344
|
* ```ts
|
|
@@ -3086,13 +3348,20 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3086
3348
|
* // "2:30 PM"
|
|
3087
3349
|
* ```
|
|
3088
3350
|
*/ function formatToTimeString(date) {
|
|
3089
|
-
return dateFns.format(date,
|
|
3351
|
+
return dateFns.format(date, DATE_TIME_STRING_FORMAT);
|
|
3090
3352
|
}
|
|
3091
|
-
/**
|
|
3353
|
+
/**
|
|
3354
|
+
* Combined date-fns format string for `MM/dd/yyyy h:mm a` (e.g., `"01/15/2024 9:00 AM"`).
|
|
3355
|
+
*/ var DATE_SHORT_DATE_AND_TIME_STRING_FORMAT = "".concat(MONTH_DAY_SLASH_DATE_STRING_FORMAT, " ").concat(DATE_TIME_STRING_FORMAT);
|
|
3356
|
+
/**
|
|
3357
|
+
* @deprecated Use DATE_SHORT_DATE_AND_TIME_STRING_FORMAT instead.
|
|
3358
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3359
|
+
var dateShortDateAndTimeStringFormat = DATE_SHORT_DATE_AND_TIME_STRING_FORMAT;
|
|
3092
3360
|
/**
|
|
3093
3361
|
* Formats a Date as a short date and time string (e.g., `"01/15/2024 9:00 AM"`).
|
|
3094
3362
|
*
|
|
3095
3363
|
* @param date - date to format
|
|
3364
|
+
* @returns the formatted short date and time string
|
|
3096
3365
|
*
|
|
3097
3366
|
* @example
|
|
3098
3367
|
* ```ts
|
|
@@ -3102,7 +3371,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3102
3371
|
* // "01/15/2024 2:30 PM"
|
|
3103
3372
|
* ```
|
|
3104
3373
|
*/ function formatToShortDateAndTimeString(date) {
|
|
3105
|
-
return dateFns.format(date,
|
|
3374
|
+
return dateFns.format(date, DATE_SHORT_DATE_AND_TIME_STRING_FORMAT);
|
|
3106
3375
|
}
|
|
3107
3376
|
/**
|
|
3108
3377
|
* Formats a start time with an appended duration indicator. For durations over 2 hours, uses
|
|
@@ -3110,6 +3379,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3110
3379
|
*
|
|
3111
3380
|
* @param start - start date/time
|
|
3112
3381
|
* @param end - end date/time
|
|
3382
|
+
* @returns the formatted time string with an appended duration indicator
|
|
3113
3383
|
*
|
|
3114
3384
|
* @example
|
|
3115
3385
|
* ```ts
|
|
@@ -3131,7 +3401,8 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3131
3401
|
includeSeconds: false
|
|
3132
3402
|
}), ")");
|
|
3133
3403
|
} else {
|
|
3134
|
-
|
|
3404
|
+
var minutesLabel = minutes ? "(".concat(minutes, " Minutes)") : '';
|
|
3405
|
+
subtitle = minutesLabel;
|
|
3135
3406
|
}
|
|
3136
3407
|
return "".concat(formatToTimeString(start), " ").concat(subtitle);
|
|
3137
3408
|
}
|
|
@@ -3154,6 +3425,11 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3154
3425
|
* formatStartedEndedDistanceString(activeRange);
|
|
3155
3426
|
* // "started about 1 hour ago"
|
|
3156
3427
|
* ```
|
|
3428
|
+
*
|
|
3429
|
+
* @param dateRange - date range with start and end dates
|
|
3430
|
+
* @param dateRange.start - the start date of the range
|
|
3431
|
+
* @param dateRange.end - the end date of the range
|
|
3432
|
+
* @returns the relative-time label describing the date range state
|
|
3157
3433
|
*/ function formatStartedEndedDistanceString(param) {
|
|
3158
3434
|
var start = param.start, end = param.end;
|
|
3159
3435
|
var state = dateRangeRelativeState({
|
|
@@ -3185,6 +3461,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3185
3461
|
* Useful for converting heterogeneous date inputs into a consistent midnight-aligned Date.
|
|
3186
3462
|
*
|
|
3187
3463
|
* @param input - date or day string to normalize
|
|
3464
|
+
* @returns a Date set to midnight of the corresponding day in the system timezone
|
|
3188
3465
|
*
|
|
3189
3466
|
* @example
|
|
3190
3467
|
* ```ts
|
|
@@ -3204,6 +3481,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3204
3481
|
* in the system timezone. Supports year formats with more than 4 digits but does not support negative years.
|
|
3205
3482
|
*
|
|
3206
3483
|
* @param dayString - ISO 8601 day or date string to parse
|
|
3484
|
+
* @returns a Date at the start of the parsed day in the system timezone
|
|
3207
3485
|
*
|
|
3208
3486
|
* @example
|
|
3209
3487
|
* ```ts
|
|
@@ -3420,6 +3698,11 @@ function _type_of$5(obj) {
|
|
|
3420
3698
|
* The end date is used just to determine the number of days, but a minimum of 1 day is always enforced as a DateCellTiming must contain atleast 1 day.
|
|
3421
3699
|
*
|
|
3422
3700
|
* The start date from the inputDate is considered to to have the offset noted in DateCell, and will be retained.
|
|
3701
|
+
*
|
|
3702
|
+
* @param durationInput - the duration span containing the startsAt time and event duration in minutes
|
|
3703
|
+
* @param rangeInput - specifies the date range: a number of days, a DateRange, or a DateRangeDayDistanceInput
|
|
3704
|
+
* @param timezoneInput - optional timezone configuration; defaults to the system timezone if omitted
|
|
3705
|
+
* @returns a fully computed FullDateCellTiming with start, startsAt, end, duration, and timezone
|
|
3423
3706
|
*/ function dateCellTiming(durationInput, rangeInput, timezoneInput) {
|
|
3424
3707
|
var duration = durationInput.duration;
|
|
3425
3708
|
if (duration > util.MINUTES_IN_DAY) {
|
|
@@ -3474,7 +3757,12 @@ function _type_of$5(obj) {
|
|
|
3474
3757
|
var utcDay = formatToISO8601DayStringForUTC(startsAtInUtc);
|
|
3475
3758
|
var start = normalInstance.startOfDayInTargetTimezone(utcDay);
|
|
3476
3759
|
var safeMirror = util.isEqualDate(startsAtInUtc, startsAtInUtcInitial);
|
|
3477
|
-
var _normalInstance_safeMirroredConvertDate = normalInstance.safeMirroredConvertDate(
|
|
3760
|
+
var _normalInstance_safeMirroredConvertDate = normalInstance.safeMirroredConvertDate({
|
|
3761
|
+
baseDate: startsAtInUtc,
|
|
3762
|
+
originalContextDate: inputStartsAt,
|
|
3763
|
+
contextType: 'target',
|
|
3764
|
+
safeConvert: safeMirror
|
|
3765
|
+
}), startsAt = _normalInstance_safeMirroredConvertDate.date, daylightSavingsOffset = _normalInstance_safeMirroredConvertDate.daylightSavingsOffset;
|
|
3478
3766
|
// calculate end to be the ending date/time of the final duration span
|
|
3479
3767
|
var lastStartsAtInBaseTimezone = dateFns.addHours(startsAtInUtc, numberOfDayBlocks * 24 + daylightSavingsOffset); // use addHours instead of addDays, since addDays will take into account a daylight savings change if the system time changes
|
|
3480
3768
|
var lastStartInTarget = normalInstance.targetDateToBaseDate(lastStartsAtInBaseTimezone);
|
|
@@ -3552,11 +3840,12 @@ function _type_of$5(obj) {
|
|
|
3552
3840
|
* @param input - value to check
|
|
3553
3841
|
* @returns whether the input matches the DateCellTiming shape
|
|
3554
3842
|
*/ function isDateCellTiming(input) {
|
|
3843
|
+
var result = false;
|
|
3555
3844
|
if ((typeof input === "undefined" ? "undefined" : _type_of$5(input)) === 'object') {
|
|
3556
3845
|
var asTiming = input;
|
|
3557
|
-
|
|
3846
|
+
result = isDate(asTiming.startsAt) && isDate(asTiming.end) && typeof asTiming.timezone === 'string' && typeof asTiming.duration === 'number';
|
|
3558
3847
|
}
|
|
3559
|
-
return
|
|
3848
|
+
return result;
|
|
3560
3849
|
}
|
|
3561
3850
|
/**
|
|
3562
3851
|
* Type guard that checks whether the input has the shape of a {@link FullDateCellTiming} (includes `start` field plus all DateCellTiming fields).
|
|
@@ -3566,11 +3855,12 @@ function _type_of$5(obj) {
|
|
|
3566
3855
|
* @param input - value to check
|
|
3567
3856
|
* @returns whether the input matches the FullDateCellTiming shape
|
|
3568
3857
|
*/ function isFullDateCellTiming(input) {
|
|
3858
|
+
var result = false;
|
|
3569
3859
|
if ((typeof input === "undefined" ? "undefined" : _type_of$5(input)) === 'object') {
|
|
3570
3860
|
var asTiming = input;
|
|
3571
|
-
|
|
3861
|
+
result = isDate(asTiming.start) && isDateCellTiming(asTiming);
|
|
3572
3862
|
}
|
|
3573
|
-
return
|
|
3863
|
+
return result;
|
|
3574
3864
|
}
|
|
3575
3865
|
/**
|
|
3576
3866
|
* Derives a {@link DateCellTimingDateRange} from a timing, using midnight in the timing's timezone as the start and the event's end time as the end.
|
|
@@ -3732,8 +4022,16 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3732
4022
|
var normalInstance = dateTimezoneUtcNormal(timezone);
|
|
3733
4023
|
var startsAtInUtcNormal = normalInstance.baseDateToTargetDate(startsAt); // convert to UTC normal
|
|
3734
4024
|
var endInUtcNormal = normalInstance.baseDateToTargetDate(end);
|
|
3735
|
-
var _normalInstance_safeMirroredConvertDate = normalInstance.safeMirroredConvertDate(
|
|
3736
|
-
|
|
4025
|
+
var _normalInstance_safeMirroredConvertDate = normalInstance.safeMirroredConvertDate({
|
|
4026
|
+
baseDate: startsAtInUtcNormal,
|
|
4027
|
+
originalContextDate: startsAt,
|
|
4028
|
+
contextType: 'target'
|
|
4029
|
+
}), startDaylightSavingsOffset = _normalInstance_safeMirroredConvertDate.daylightSavingsOffset;
|
|
4030
|
+
var _normalInstance_safeMirroredConvertDate1 = normalInstance.safeMirroredConvertDate({
|
|
4031
|
+
baseDate: endInUtcNormal,
|
|
4032
|
+
originalContextDate: end,
|
|
4033
|
+
contextType: 'target'
|
|
4034
|
+
}), endDaylightSavingsOffset = _normalInstance_safeMirroredConvertDate1.daylightSavingsOffset;
|
|
3737
4035
|
if (startDaylightSavingsOffset) {
|
|
3738
4036
|
startsAtInUtcNormal = dateFns.addHours(startsAtInUtcNormal, startDaylightSavingsOffset);
|
|
3739
4037
|
}
|
|
@@ -3819,7 +4117,7 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3819
4117
|
isExpectedValidEnd = expectedDuration === duration; // should be the expected duration
|
|
3820
4118
|
isValid = isExpectedValidEnd;
|
|
3821
4119
|
}
|
|
3822
|
-
|
|
4120
|
+
return {
|
|
3823
4121
|
isValid: isValid,
|
|
3824
4122
|
endIsAfterTheStartsAtTime: endIsAfterTheStartsAtTime,
|
|
3825
4123
|
durationGreaterThanZero: durationGreaterThanZero,
|
|
@@ -3828,7 +4126,6 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3828
4126
|
isExpectedValidEnd: isExpectedValidEnd,
|
|
3829
4127
|
normalInstance: normalInstance
|
|
3830
4128
|
};
|
|
3831
|
-
return result;
|
|
3832
4129
|
}
|
|
3833
4130
|
/**
|
|
3834
4131
|
* Returns true if the {@link DateCellTiming} passes all validation checks.
|
|
@@ -3893,13 +4190,13 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3893
4190
|
return isValid;
|
|
3894
4191
|
}
|
|
3895
4192
|
|
|
3896
|
-
function _array_like_to_array$
|
|
4193
|
+
function _array_like_to_array$6(arr, len) {
|
|
3897
4194
|
if (len == null || len > arr.length) len = arr.length;
|
|
3898
4195
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
3899
4196
|
return arr2;
|
|
3900
4197
|
}
|
|
3901
|
-
function _array_without_holes$
|
|
3902
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
4198
|
+
function _array_without_holes$4(arr) {
|
|
4199
|
+
if (Array.isArray(arr)) return _array_like_to_array$6(arr);
|
|
3903
4200
|
}
|
|
3904
4201
|
function _define_property$c(obj, key, value) {
|
|
3905
4202
|
if (key in obj) {
|
|
@@ -3914,10 +4211,10 @@ function _define_property$c(obj, key, value) {
|
|
|
3914
4211
|
}
|
|
3915
4212
|
return obj;
|
|
3916
4213
|
}
|
|
3917
|
-
function _iterable_to_array$
|
|
4214
|
+
function _iterable_to_array$4(iter) {
|
|
3918
4215
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3919
4216
|
}
|
|
3920
|
-
function _non_iterable_spread$
|
|
4217
|
+
function _non_iterable_spread$4() {
|
|
3921
4218
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
3922
4219
|
}
|
|
3923
4220
|
function _object_spread$a(target) {
|
|
@@ -3954,20 +4251,20 @@ function _object_spread_props$8(target, source) {
|
|
|
3954
4251
|
}
|
|
3955
4252
|
return target;
|
|
3956
4253
|
}
|
|
3957
|
-
function _to_consumable_array$
|
|
3958
|
-
return _array_without_holes$
|
|
4254
|
+
function _to_consumable_array$4(arr) {
|
|
4255
|
+
return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$4();
|
|
3959
4256
|
}
|
|
3960
4257
|
function _type_of$4(obj) {
|
|
3961
4258
|
"@swc/helpers - typeof";
|
|
3962
4259
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
3963
4260
|
}
|
|
3964
|
-
function _unsupported_iterable_to_array$
|
|
4261
|
+
function _unsupported_iterable_to_array$6(o, minLen) {
|
|
3965
4262
|
if (!o) return;
|
|
3966
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
4263
|
+
if (typeof o === "string") return _array_like_to_array$6(o, minLen);
|
|
3967
4264
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3968
4265
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3969
4266
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
3970
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
4267
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
|
|
3971
4268
|
}
|
|
3972
4269
|
/**
|
|
3973
4270
|
* Returns true if the input is a DateCellRange.
|
|
@@ -3975,6 +4272,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
3975
4272
|
* Does not check validity. Use {@link isValidDateCellRange} for that.
|
|
3976
4273
|
*
|
|
3977
4274
|
* @param input - value to check
|
|
4275
|
+
* @returns true if the input is a DateCellRange
|
|
3978
4276
|
*/ function isDateCellRange(input) {
|
|
3979
4277
|
return (typeof input === "undefined" ? "undefined" : _type_of$4(input)) === 'object' ? Number.isInteger(input.i) && input.to === undefined || Number.isInteger(input.to) : false;
|
|
3980
4278
|
}
|
|
@@ -3985,6 +4283,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
3985
4283
|
* that is greater than or equal to `i`.
|
|
3986
4284
|
*
|
|
3987
4285
|
* @param input - range to validate
|
|
4286
|
+
* @returns true if the range has valid non-negative indexes and `to` (when defined) is greater than or equal to `i`
|
|
3988
4287
|
*/ function isValidDateCellRange(input) {
|
|
3989
4288
|
var i = input.i, to = input.to;
|
|
3990
4289
|
if (!isValidDateCellIndex(i)) {
|
|
@@ -4000,6 +4299,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4000
4299
|
* Validates that each range is individually valid and that no ranges overlap or appear out of order.
|
|
4001
4300
|
*
|
|
4002
4301
|
* @param input - array of ranges to validate as a non-overlapping ascending series
|
|
4302
|
+
* @returns true if the array is sorted in ascending order with no overlapping or duplicate indexes
|
|
4003
4303
|
*/ function isValidDateCellRangeSeries(input) {
|
|
4004
4304
|
if (!Array.isArray(input)) {
|
|
4005
4305
|
return false;
|
|
@@ -4011,13 +4311,30 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4011
4311
|
return false;
|
|
4012
4312
|
}
|
|
4013
4313
|
var greatestIndex = -1;
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4314
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4315
|
+
try {
|
|
4316
|
+
for(var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4317
|
+
var range = _step.value;
|
|
4318
|
+
if (range.i <= greatestIndex) {
|
|
4319
|
+
return false;
|
|
4320
|
+
} else {
|
|
4321
|
+
var _range_to;
|
|
4322
|
+
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.
|
|
4323
|
+
greatestIndex = nextGreatestIndex;
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
} catch (err) {
|
|
4327
|
+
_didIteratorError = true;
|
|
4328
|
+
_iteratorError = err;
|
|
4329
|
+
} finally{
|
|
4330
|
+
try {
|
|
4331
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4332
|
+
_iterator.return();
|
|
4333
|
+
}
|
|
4334
|
+
} finally{
|
|
4335
|
+
if (_didIteratorError) {
|
|
4336
|
+
throw _iteratorError;
|
|
4337
|
+
}
|
|
4021
4338
|
}
|
|
4022
4339
|
}
|
|
4023
4340
|
return true;
|
|
@@ -4028,6 +4345,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4028
4345
|
* The input range is not expected to be sorted.
|
|
4029
4346
|
*
|
|
4030
4347
|
* @param input - unsorted array of date cell ranges to scan
|
|
4348
|
+
* @returns the smallest starting index found, or 0 if the input is empty
|
|
4031
4349
|
*/ function getLeastDateCellIndexInDateCellRanges(input) {
|
|
4032
4350
|
var _ref;
|
|
4033
4351
|
var _getLeastAndGreatestDateCellIndexInDateCellRanges;
|
|
@@ -4039,6 +4357,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4039
4357
|
* The input range is not expected to be sorted.
|
|
4040
4358
|
*
|
|
4041
4359
|
* @param input - unsorted array of date cell ranges to scan
|
|
4360
|
+
* @returns the largest ending index found, or 0 if the input is empty
|
|
4042
4361
|
*/ function getGreatestDateCellIndexInDateCellRanges(input) {
|
|
4043
4362
|
var _ref;
|
|
4044
4363
|
var _getLeastAndGreatestDateCellIndexInDateCellRanges;
|
|
@@ -4050,6 +4369,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4050
4369
|
* The input range is not expected to be sorted.
|
|
4051
4370
|
*
|
|
4052
4371
|
* @param input - unsorted array of date cell ranges to scan
|
|
4372
|
+
* @returns an object with the least and greatest indexes and their source items, or null if the input is empty
|
|
4053
4373
|
*/ function getLeastAndGreatestDateCellIndexInDateCellRanges(input) {
|
|
4054
4374
|
if (!input.length) {
|
|
4055
4375
|
return null;
|
|
@@ -4058,17 +4378,34 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4058
4378
|
var greatestIndex = 0;
|
|
4059
4379
|
var leastIndexItem = input[0];
|
|
4060
4380
|
var greatestIndexItem = input[0];
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
var
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4381
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
4382
|
+
try {
|
|
4383
|
+
for(var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
4384
|
+
var range = _step.value;
|
|
4385
|
+
var _range_to;
|
|
4386
|
+
var leastRangeIndex = range.i;
|
|
4387
|
+
var greatestRangeIndex = (_range_to = range.to) !== null && _range_to !== void 0 ? _range_to : range.i;
|
|
4388
|
+
if (leastRangeIndex < leastIndex) {
|
|
4389
|
+
leastIndex = leastRangeIndex;
|
|
4390
|
+
leastIndexItem = range;
|
|
4391
|
+
}
|
|
4392
|
+
if (greatestRangeIndex > greatestIndex) {
|
|
4393
|
+
greatestIndex = greatestRangeIndex;
|
|
4394
|
+
greatestIndexItem = range;
|
|
4395
|
+
}
|
|
4068
4396
|
}
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4397
|
+
} catch (err) {
|
|
4398
|
+
_didIteratorError = true;
|
|
4399
|
+
_iteratorError = err;
|
|
4400
|
+
} finally{
|
|
4401
|
+
try {
|
|
4402
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
4403
|
+
_iterator.return();
|
|
4404
|
+
}
|
|
4405
|
+
} finally{
|
|
4406
|
+
if (_didIteratorError) {
|
|
4407
|
+
throw _iteratorError;
|
|
4408
|
+
}
|
|
4072
4409
|
}
|
|
4073
4410
|
}
|
|
4074
4411
|
return {
|
|
@@ -4084,6 +4421,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4084
4421
|
*
|
|
4085
4422
|
* @param i - starting cell index
|
|
4086
4423
|
* @param to - ending cell index (inclusive); defaults to `i`
|
|
4424
|
+
* @returns a DateCellRangeWithRange spanning from `i` to `to`
|
|
4087
4425
|
*/ function dateCellRange(i, to) {
|
|
4088
4426
|
return {
|
|
4089
4427
|
i: i,
|
|
@@ -4094,6 +4432,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4094
4432
|
* Creates a single-cell {@link DateCellRangeWithRange} where both `i` and `to` equal the given index.
|
|
4095
4433
|
*
|
|
4096
4434
|
* @param dateCellIndex - the index for both start and end of the range
|
|
4435
|
+
* @returns a DateCellRangeWithRange where `i` and `to` both equal the given index
|
|
4097
4436
|
*/ function dateCellRangeWithRangeFromIndex(dateCellIndex) {
|
|
4098
4437
|
return dateCellRange(dateCellIndex, dateCellIndex);
|
|
4099
4438
|
}
|
|
@@ -4102,6 +4441,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4102
4441
|
* ensuring the result always has an explicit `to` value.
|
|
4103
4442
|
*
|
|
4104
4443
|
* @param input - index, cell, or range to normalize
|
|
4444
|
+
* @returns a DateCellRangeWithRange with an explicit `to` value
|
|
4105
4445
|
*/ function dateCellRangeWithRange(input) {
|
|
4106
4446
|
if (typeof input === 'number') {
|
|
4107
4447
|
return dateCellRangeWithRangeFromIndex(input);
|
|
@@ -4114,12 +4454,12 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4114
4454
|
* fully contains the configured `inputRange`.
|
|
4115
4455
|
*
|
|
4116
4456
|
* @param inputRange - the range that must be fully included
|
|
4457
|
+
* @returns a function that returns true when its argument fully contains `inputRange`
|
|
4117
4458
|
*/ function dateCellRangeIncludedByRangeFunction(inputRange) {
|
|
4118
4459
|
var _dateCellRangeWithRange = dateCellRangeWithRange(inputRange), i = _dateCellRangeWithRange.i, to = _dateCellRangeWithRange.to;
|
|
4119
4460
|
return function(input) {
|
|
4120
|
-
var _ref;
|
|
4121
4461
|
var range = dateCellRangeWithRange(input);
|
|
4122
|
-
return range.i <= i &&
|
|
4462
|
+
return range.i <= i && range.to >= to;
|
|
4123
4463
|
};
|
|
4124
4464
|
}
|
|
4125
4465
|
/**
|
|
@@ -4127,12 +4467,12 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4127
4467
|
* has any overlap with the configured `inputRange`.
|
|
4128
4468
|
*
|
|
4129
4469
|
* @param inputRange - the range to test for overlap against
|
|
4470
|
+
* @returns a function that returns true when its argument overlaps with `inputRange`
|
|
4130
4471
|
*/ function dateCellRangeOverlapsRangeFunction(inputRange) {
|
|
4131
4472
|
var _dateCellRangeWithRange = dateCellRangeWithRange(inputRange), i = _dateCellRangeWithRange.i, to = _dateCellRangeWithRange.to;
|
|
4132
4473
|
return function(input) {
|
|
4133
|
-
var _ref;
|
|
4134
4474
|
var range = dateCellRangeWithRange(input);
|
|
4135
|
-
return range.i <= to &&
|
|
4475
|
+
return range.i <= to && range.to >= i;
|
|
4136
4476
|
};
|
|
4137
4477
|
}
|
|
4138
4478
|
/**
|
|
@@ -4140,6 +4480,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4140
4480
|
*
|
|
4141
4481
|
* @param rangeA - first range to compare
|
|
4142
4482
|
* @param rangeB - second range to compare
|
|
4483
|
+
* @returns true if the two ranges share at least one common index
|
|
4143
4484
|
*/ function dateCellRangeOverlapsRange(rangeA, rangeB) {
|
|
4144
4485
|
return dateCellRangeOverlapsRangeFunction(rangeA)(rangeB);
|
|
4145
4486
|
}
|
|
@@ -4147,6 +4488,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4147
4488
|
* Returns a sort comparator that orders ranges first by starting index (`i`), then by ending index (`to`).
|
|
4148
4489
|
*
|
|
4149
4490
|
* In many cases {@link sortAscendingIndexNumberRefFunction} may be preferential when `to` ordering is not needed.
|
|
4491
|
+
*
|
|
4492
|
+
* @returns a comparator function that sorts ranges by `i` then by `to`
|
|
4150
4493
|
*/ function sortDateCellRangeAndSizeFunction() {
|
|
4151
4494
|
return function(a, b) {
|
|
4152
4495
|
var _a_to, _b_to;
|
|
@@ -4157,6 +4500,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4157
4500
|
* Sorts the input date ranges in-place by ascending index using {@link sortAscendingIndexNumberRefFunction}.
|
|
4158
4501
|
*
|
|
4159
4502
|
* @param input - array of ranges to sort (mutated in place)
|
|
4503
|
+
* @returns the same array, sorted in ascending index order
|
|
4160
4504
|
*/ function sortDateCellRanges(input) {
|
|
4161
4505
|
return input.sort(util.sortAscendingIndexNumberRefFunction());
|
|
4162
4506
|
}
|
|
@@ -4167,6 +4511,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4167
4511
|
* The input is sorted internally before grouping.
|
|
4168
4512
|
*
|
|
4169
4513
|
* @param input - cells or ranges to merge into contiguous groups
|
|
4514
|
+
* @returns an array of non-overlapping contiguous DateCellRangeWithRange values
|
|
4170
4515
|
*
|
|
4171
4516
|
* @example
|
|
4172
4517
|
* ```ts
|
|
@@ -4214,6 +4559,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4214
4559
|
* Returns an array containing every individual index in the given date cell range (inclusive of both `i` and `to`).
|
|
4215
4560
|
*
|
|
4216
4561
|
* @param input - range to expand into individual indexes
|
|
4562
|
+
* @returns an array of every DateCellIndex from `i` to `to` inclusive
|
|
4217
4563
|
*/ function allIndexesInDateCellRange(input) {
|
|
4218
4564
|
return input.to != null ? util.range(input.i, input.to + 1) : [
|
|
4219
4565
|
input.i
|
|
@@ -4223,6 +4569,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4223
4569
|
* Flattens an array of indexes and/or ranges into a single array of individual {@link DateCellIndex} values.
|
|
4224
4570
|
*
|
|
4225
4571
|
* @param input - mix of raw indexes and ranges to flatten
|
|
4572
|
+
* @returns a flat array of all individual DateCellIndex values
|
|
4226
4573
|
*/ function allIndexesInDateCellRangesToArray(input) {
|
|
4227
4574
|
var result = [];
|
|
4228
4575
|
input.forEach(function(x) {
|
|
@@ -4239,6 +4586,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4239
4586
|
* Returns a deduplicated {@link Set} of all indexes within the input ranges.
|
|
4240
4587
|
*
|
|
4241
4588
|
* @param input - mix of raw indexes and ranges to collect
|
|
4589
|
+
* @returns a Set containing every unique DateCellIndex from the input
|
|
4242
4590
|
*/ function allIndexesInDateCellRanges(input) {
|
|
4243
4591
|
return new Set(allIndexesInDateCellRangesToArray(input));
|
|
4244
4592
|
}
|
|
@@ -4247,6 +4595,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4247
4595
|
*
|
|
4248
4596
|
* @param blocks - cells or ranges to filter
|
|
4249
4597
|
* @param range - bounding range that blocks must fall within
|
|
4598
|
+
* @returns only the blocks that fall entirely within the given range
|
|
4250
4599
|
*/ function filterDateCellsInDateCellRange(blocks, range) {
|
|
4251
4600
|
var dateCellIsWithinDateCellRange = isDateCellWithinDateCellRangeFunction(range);
|
|
4252
4601
|
return blocks.filter(dateCellIsWithinDateCellRange);
|
|
@@ -4256,6 +4605,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4256
4605
|
* is fully contained within `inputRange`.
|
|
4257
4606
|
*
|
|
4258
4607
|
* @param inputRange - the bounding range to test containment against
|
|
4608
|
+
* @returns a function that returns true when its argument is fully contained within `inputRange`
|
|
4259
4609
|
*/ function isDateCellWithinDateCellRangeFunction(inputRange) {
|
|
4260
4610
|
var range = dateCellRangeWithRange(inputRange);
|
|
4261
4611
|
return function(input) {
|
|
@@ -4277,6 +4627,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4277
4627
|
*
|
|
4278
4628
|
* @param range - the outer bounding range
|
|
4279
4629
|
* @param contains - the cell or range to test for containment
|
|
4630
|
+
* @returns true if `contains` is fully within `range`
|
|
4280
4631
|
*/ function isDateCellWithinDateCellRange(range, contains) {
|
|
4281
4632
|
return isDateCellWithinDateCellRangeFunction(range)(dateCellRangeWithRange(contains));
|
|
4282
4633
|
}
|
|
@@ -4286,6 +4637,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4286
4637
|
* Internally groups overlapping ranges before counting so each index is counted only once.
|
|
4287
4638
|
*
|
|
4288
4639
|
* @param inputDateCellRange - one or more cells/ranges to analyze
|
|
4640
|
+
* @returns count, total, and average statistics for the given ranges
|
|
4289
4641
|
*/ function dateCellRangeBlocksCountInfo(inputDateCellRange) {
|
|
4290
4642
|
var group = groupToDateCellRanges(util.asArray(inputDateCellRange));
|
|
4291
4643
|
var count = 0;
|
|
@@ -4308,6 +4660,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4308
4660
|
* Shorthand for `dateCellRangeBlocksCountInfo(input).count`.
|
|
4309
4661
|
*
|
|
4310
4662
|
* @param inputDateCellRange - one or more cells/ranges to count
|
|
4663
|
+
* @returns the total number of individual cell indexes
|
|
4311
4664
|
*
|
|
4312
4665
|
* @example
|
|
4313
4666
|
* ```ts
|
|
@@ -4322,13 +4675,14 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4322
4675
|
* grouped range from `ranges` fully covers a given input range.
|
|
4323
4676
|
*
|
|
4324
4677
|
* @param ranges - the covering ranges to test against
|
|
4678
|
+
* @returns a function that returns true when any single grouped range fully covers the input range
|
|
4325
4679
|
*/ function dateCellRangesFullyCoverDateCellRangeFunction(ranges) {
|
|
4326
4680
|
var groupedRanges = Array.isArray(ranges) ? groupToDateCellRanges(ranges) : [
|
|
4327
4681
|
dateCellRangeWithRange(ranges)
|
|
4328
4682
|
];
|
|
4329
4683
|
return function(inputRange) {
|
|
4330
4684
|
var fn = dateCellRangeIncludedByRangeFunction(inputRange);
|
|
4331
|
-
return groupedRanges.
|
|
4685
|
+
return groupedRanges.some(fn);
|
|
4332
4686
|
};
|
|
4333
4687
|
}
|
|
4334
4688
|
/**
|
|
@@ -4339,6 +4693,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4339
4693
|
* nearest future range's starting index is used.
|
|
4340
4694
|
*
|
|
4341
4695
|
* @param input - the current index and ranges to evaluate
|
|
4696
|
+
* @returns classification of ranges as past/present/future and the next upcoming index
|
|
4342
4697
|
*
|
|
4343
4698
|
* @example
|
|
4344
4699
|
* ```ts
|
|
@@ -4395,6 +4750,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4395
4750
|
*
|
|
4396
4751
|
* @param range - the date cell range to classify
|
|
4397
4752
|
* @param nowIndex - the reference index representing "now"
|
|
4753
|
+
* @returns 'past', 'present', or 'future' depending on the range's position relative to `nowIndex`
|
|
4398
4754
|
*/ function dateRelativeStateForDateCellRangeComparedToIndex(range, nowIndex) {
|
|
4399
4755
|
var _dateCellRange = dateCellRange(range.i, range.to), i = _dateCellRange.i, to = _dateCellRange.to;
|
|
4400
4756
|
var state;
|
|
@@ -4412,6 +4768,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4412
4768
|
* from `i` to `to` (inclusive). Each copy retains all properties of the original block.
|
|
4413
4769
|
*
|
|
4414
4770
|
* @param block - the range to expand
|
|
4771
|
+
* @returns an array of single-cell copies, one per index from `i` to `to`
|
|
4415
4772
|
*
|
|
4416
4773
|
* @example
|
|
4417
4774
|
* ```ts
|
|
@@ -4430,6 +4787,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4430
4787
|
* Returns true if the input spans more than one cell (i.e., has a `to` value strictly greater than `i`).
|
|
4431
4788
|
*
|
|
4432
4789
|
* @param input - range or cell to check
|
|
4790
|
+
* @returns true if `to` is defined and strictly greater than `i`
|
|
4433
4791
|
*/ function dateCellRangeHasRange(input) {
|
|
4434
4792
|
return input.to != null && input.to > input.i;
|
|
4435
4793
|
}
|
|
@@ -4437,6 +4795,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4437
4795
|
* Returns the effective ending index of a range: `to` if defined, otherwise `i`.
|
|
4438
4796
|
*
|
|
4439
4797
|
* @param input - range or cell to read
|
|
4798
|
+
* @returns the `to` index if defined, otherwise `i`
|
|
4440
4799
|
*/ function dateCellEndIndex(input) {
|
|
4441
4800
|
var _input_to;
|
|
4442
4801
|
return (_input_to = input.to) !== null && _input_to !== void 0 ? _input_to : input.i;
|
|
@@ -4447,8 +4806,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4447
4806
|
* and `to` is the maximum ending index across all blocks.
|
|
4448
4807
|
*
|
|
4449
4808
|
* @param input - cells or ranges to group
|
|
4809
|
+
* @returns a UniqueDateCellRangeGroup containing the sorted blocks with `i` at 0
|
|
4450
4810
|
*/ function groupUniqueDateCells(input) {
|
|
4451
|
-
var blocks = sortDateCellRanges(_to_consumable_array$
|
|
4811
|
+
var blocks = sortDateCellRanges(_to_consumable_array$4(input));
|
|
4452
4812
|
var i = 0;
|
|
4453
4813
|
var to;
|
|
4454
4814
|
if (blocks.length === 0) {
|
|
@@ -4469,6 +4829,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4469
4829
|
* according to the provided configuration. Handles overlap resolution, gap filling, and boundary clamping.
|
|
4470
4830
|
*
|
|
4471
4831
|
* @param config - controls start/end bounds, fill strategy, and overlap retention behavior
|
|
4832
|
+
* @returns a function that merges, fills, and resolves overlaps in date cell range arrays
|
|
4472
4833
|
*
|
|
4473
4834
|
* @example
|
|
4474
4835
|
* ```ts
|
|
@@ -4486,9 +4847,10 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4486
4847
|
var retainOnOverlap = inputRetainOnOverlap !== null && inputRetainOnOverlap !== void 0 ? inputRetainOnOverlap : 'next';
|
|
4487
4848
|
var maxAllowedIndex = endAtIndex !== null && endAtIndex !== void 0 ? endAtIndex : Number.MAX_SAFE_INTEGER;
|
|
4488
4849
|
var fillFactory = inputFillFactory;
|
|
4489
|
-
if (!
|
|
4850
|
+
if (!inputFillFactory && fill === 'fill') {
|
|
4490
4851
|
throw new Error('fillFactory is required when fillOption is "fill".');
|
|
4491
4852
|
}
|
|
4853
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
4492
4854
|
return function(input, newBlocks) {
|
|
4493
4855
|
var addBlockWithRange = function addBlockWithRange(inputBlock, i) {
|
|
4494
4856
|
var inputTo = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : i;
|
|
@@ -4526,7 +4888,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4526
4888
|
to: to
|
|
4527
4889
|
};
|
|
4528
4890
|
var block = fillFactory(dateCellRange);
|
|
4529
|
-
addBlockWithRange(block, i, to
|
|
4891
|
+
addBlockWithRange(block, i, to);
|
|
4530
4892
|
} else if (fill === 'empty') ; else if (blocks.length > 0) {
|
|
4531
4893
|
// only extend if one or more blocks have been pushed
|
|
4532
4894
|
var blockToExtend = util.lastValue(blocks);
|
|
@@ -4547,6 +4909,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4547
4909
|
};
|
|
4548
4910
|
var shouldRetainCurrentOverNext = /**
|
|
4549
4911
|
* Used to determine how to handle two neighboring objects.
|
|
4912
|
+
*
|
|
4913
|
+
* @returns true if the current block should be retained over the next block
|
|
4550
4914
|
*/ function shouldRetainCurrentOverNext() {
|
|
4551
4915
|
if (current.priority === next.priority) {
|
|
4552
4916
|
return retainOnOverlap === 'current';
|
|
@@ -4587,6 +4951,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4587
4951
|
priority: priority
|
|
4588
4952
|
} : sorted[i];
|
|
4589
4953
|
next = sorted[i + 1];
|
|
4954
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- next may be undefined when sorted[i+1] is out of bounds
|
|
4590
4955
|
if (next) {
|
|
4591
4956
|
nextStartIndex = next.block.i;
|
|
4592
4957
|
// complete loop once past the max allowed index
|
|
@@ -4703,6 +5068,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4703
5068
|
}
|
|
4704
5069
|
}
|
|
4705
5070
|
}
|
|
5071
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- current may be undefined when sorted is empty
|
|
4706
5072
|
if (current != null) {
|
|
4707
5073
|
// if current != null, then atleast one block was input/remaining.
|
|
4708
5074
|
var lastStartIndex = current.block.i;
|
|
@@ -4717,12 +5083,11 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4717
5083
|
} else if (fill === 'fill') {
|
|
4718
5084
|
completeBlocks();
|
|
4719
5085
|
}
|
|
4720
|
-
|
|
5086
|
+
return {
|
|
4721
5087
|
i: 0,
|
|
4722
5088
|
blocks: blocks,
|
|
4723
5089
|
discarded: discarded
|
|
4724
5090
|
};
|
|
4725
|
-
return result;
|
|
4726
5091
|
};
|
|
4727
5092
|
}
|
|
4728
5093
|
|
|
@@ -4785,6 +5150,9 @@ function _type_of$3(obj) {
|
|
|
4785
5150
|
* When `limitToCompletedIndexes` is true, only indexes whose timing duration has fully elapsed are included,
|
|
4786
5151
|
* with the max boundary lazily refreshed as time passes.
|
|
4787
5152
|
*
|
|
5153
|
+
* @param config - Configuration specifying the timing, range fit, and completion constraints.
|
|
5154
|
+
* @returns A factory function that produces a clamped {@link DateCellRangeWithRange} from optional start/end input.
|
|
5155
|
+
*
|
|
4788
5156
|
* @example
|
|
4789
5157
|
* ```ts
|
|
4790
5158
|
* const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
|
|
@@ -4860,6 +5228,10 @@ function _type_of$3(obj) {
|
|
|
4860
5228
|
* Computes a {@link DateCellRangeWithRange} from a timing and optional start/end input.
|
|
4861
5229
|
*
|
|
4862
5230
|
* Shorthand for creating a {@link dateCellRangeOfTimingFactory} and immediately invoking it.
|
|
5231
|
+
*
|
|
5232
|
+
* @param config - A {@link DateCellTiming} or full factory configuration.
|
|
5233
|
+
* @param input - Optional start/end boundaries for the range.
|
|
5234
|
+
* @returns A clamped {@link DateCellRangeWithRange} derived from the timing and input.
|
|
4863
5235
|
*/ function dateCellRangeOfTiming(config, input) {
|
|
4864
5236
|
return dateCellRangeOfTimingFactory(isDateCellTiming(config) ? {
|
|
4865
5237
|
timing: config
|
|
@@ -4870,6 +5242,10 @@ function _type_of$3(obj) {
|
|
|
4870
5242
|
* of the timing schedule. Useful for determining which days have already finished.
|
|
4871
5243
|
*
|
|
4872
5244
|
* By default fitToTimingRange is true.
|
|
5245
|
+
*
|
|
5246
|
+
* @param timing - The timing schedule to evaluate.
|
|
5247
|
+
* @param config - Optional configuration for the current time reference and range fitting.
|
|
5248
|
+
* @returns A {@link DateCellRangeWithRange} covering only the completed day indexes.
|
|
4873
5249
|
*/ function dateCellTimingCompletedTimeRange(timing, config) {
|
|
4874
5250
|
var _ref;
|
|
4875
5251
|
return dateCellRangeOfTiming({
|
|
@@ -4883,6 +5259,10 @@ function _type_of$3(obj) {
|
|
|
4883
5259
|
* Returns the latest completed day index for a {@link DateCellTiming}.
|
|
4884
5260
|
*
|
|
4885
5261
|
* Returns -1 if no days have been completed yet.
|
|
5262
|
+
*
|
|
5263
|
+
* @param timing - The timing schedule to evaluate.
|
|
5264
|
+
* @param now - Optional reference time; defaults to the current time.
|
|
5265
|
+
* @returns The zero-based index of the last fully completed day, or -1 if none.
|
|
4886
5266
|
*/ function dateCellTimingLatestCompletedIndex(timing, now) {
|
|
4887
5267
|
return dateCellTimingCompletedTimeRange(timing, {
|
|
4888
5268
|
now: now
|
|
@@ -4890,6 +5270,9 @@ function _type_of$3(obj) {
|
|
|
4890
5270
|
}
|
|
4891
5271
|
/**
|
|
4892
5272
|
* Converts a {@link DateCellRange} (inclusive `to`) to a {@link DateCellIndexRange} (exclusive `maxIndex`).
|
|
5273
|
+
*
|
|
5274
|
+
* @param range - The inclusive date cell range to convert.
|
|
5275
|
+
* @returns A {@link DateCellIndexRange} with exclusive `maxIndex`.
|
|
4893
5276
|
*/ function dateCellRangeToDateCellIndexRange(range) {
|
|
4894
5277
|
var _range_to;
|
|
4895
5278
|
return {
|
|
@@ -4899,6 +5282,9 @@ function _type_of$3(obj) {
|
|
|
4899
5282
|
}
|
|
4900
5283
|
/**
|
|
4901
5284
|
* Converts a {@link DateCellIndexRange} (exclusive `maxIndex`) back to a {@link DateCellRangeWithRange} (inclusive `to`).
|
|
5285
|
+
*
|
|
5286
|
+
* @param range - The exclusive date cell index range to convert.
|
|
5287
|
+
* @returns A {@link DateCellRangeWithRange} with inclusive `to`.
|
|
4902
5288
|
*/ function dateCellIndexRangeToDateCellRange(range) {
|
|
4903
5289
|
return {
|
|
4904
5290
|
i: range.minIndex,
|
|
@@ -4910,6 +5296,11 @@ function _type_of$3(obj) {
|
|
|
4910
5296
|
*
|
|
4911
5297
|
* An arbitrary limit can also be applied. When `fitToTimingRange` is true (default),
|
|
4912
5298
|
* the limit is intersected with the timing's own range; otherwise the limit is used as-is.
|
|
5299
|
+
*
|
|
5300
|
+
* @param timing - The timing schedule to derive the range from.
|
|
5301
|
+
* @param limit - Optional range input to constrain the output.
|
|
5302
|
+
* @param fitToTimingRange - Whether to intersect the limit with the timing's own range. Defaults to true.
|
|
5303
|
+
* @returns A {@link DateCellIndexRange} representing the computed index bounds.
|
|
4913
5304
|
*/ function dateCellIndexRange(timing, limit) {
|
|
4914
5305
|
var fitToTimingRange = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
4915
5306
|
var indexFactory = dateCellTimingRelativeIndexFactory(timing);
|
|
@@ -4938,6 +5329,9 @@ function _type_of$3(obj) {
|
|
|
4938
5329
|
* by combining its timing and blocks.
|
|
4939
5330
|
*
|
|
4940
5331
|
* Shorthand for calling {@link expandDateCellTiming} with `collection.timing` and `collection.blocks`.
|
|
5332
|
+
*
|
|
5333
|
+
* @param collection - The date cell collection containing timing and blocks to expand.
|
|
5334
|
+
* @returns An array of {@link DateCellDurationSpan} values with concrete start times and durations.
|
|
4941
5335
|
*/ function expandDateCellCollection(collection) {
|
|
4942
5336
|
return expandDateCellTiming(collection.timing, collection.blocks);
|
|
4943
5337
|
}
|
|
@@ -4945,6 +5339,10 @@ function _type_of$3(obj) {
|
|
|
4945
5339
|
* Expands the given blocks into {@link DateCellDurationSpan} values using the provided timing.
|
|
4946
5340
|
*
|
|
4947
5341
|
* Shorthand for creating a {@link dateCellTimingExpansionFactory} and immediately invoking it.
|
|
5342
|
+
*
|
|
5343
|
+
* @param timing - The timing schedule providing start times and duration.
|
|
5344
|
+
* @param blocks - The date cell blocks to expand into duration spans.
|
|
5345
|
+
* @returns An array of {@link DateCellDurationSpan} values with concrete start times.
|
|
4948
5346
|
*/ function expandDateCellTiming(timing, blocks) {
|
|
4949
5347
|
return dateCellTimingExpansionFactory({
|
|
4950
5348
|
timing: timing
|
|
@@ -4958,6 +5356,9 @@ function _type_of$3(obj) {
|
|
|
4958
5356
|
* Filtering is applied both at the block level and at the computed duration span level,
|
|
4959
5357
|
* and evaluation can be capped for performance with large datasets.
|
|
4960
5358
|
*
|
|
5359
|
+
* @param config - Configuration specifying the timing, range limits, filters, and output caps.
|
|
5360
|
+
* @returns A factory function that expands date cell blocks into {@link DateCellDurationSpan} arrays.
|
|
5361
|
+
*
|
|
4961
5362
|
* @example
|
|
4962
5363
|
* ```ts
|
|
4963
5364
|
* const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
|
|
@@ -5055,6 +5456,9 @@ function _type_of$3(obj) {
|
|
|
5055
5456
|
* const dateInfo = infoFactory(someDate);
|
|
5056
5457
|
* console.log(dateInfo.dayIndex); // which day index this date falls on
|
|
5057
5458
|
* ```
|
|
5459
|
+
*
|
|
5460
|
+
* @param config - Configuration providing the timing and optional range limit.
|
|
5461
|
+
* @returns A factory that computes {@link DateCellDayTimingInfo} for any date or day index.
|
|
5058
5462
|
*/ function dateCellDayTimingInfoFactory(config) {
|
|
5059
5463
|
var timing = config.timing, rangeLimit = config.rangeLimit;
|
|
5060
5464
|
var duration = timing.duration;
|
|
@@ -5119,8 +5523,11 @@ function _type_of$3(obj) {
|
|
|
5119
5523
|
* Type guard that returns true if the input is a {@link DateCellTimingRelativeIndexFactory}.
|
|
5120
5524
|
*
|
|
5121
5525
|
* Checks for the presence of `_timing` and `_normalInstance` properties on a function.
|
|
5526
|
+
*
|
|
5527
|
+
* @param input - The value to check.
|
|
5528
|
+
* @returns True if the input is a {@link DateCellTimingRelativeIndexFactory}.
|
|
5122
5529
|
*/ function isDateCellTimingRelativeIndexFactory(input) {
|
|
5123
|
-
return typeof input === 'function' &&
|
|
5530
|
+
return typeof input === 'function' && '_timing' in input && '_normalInstance' in input;
|
|
5124
5531
|
}
|
|
5125
5532
|
/**
|
|
5126
5533
|
* Creates a {@link DateCellTimingRelativeIndexFactory} that converts dates, ISO8601 day strings,
|
|
@@ -5148,6 +5555,9 @@ function _type_of$3(obj) {
|
|
|
5148
5555
|
* indexFactory._timing; // the original timing
|
|
5149
5556
|
* indexFactory._normalInstance; // timezone normalizer
|
|
5150
5557
|
* ```
|
|
5558
|
+
*
|
|
5559
|
+
* @param input - A timing configuration or an existing factory (returned as-is).
|
|
5560
|
+
* @returns A factory that converts dates, ISO8601 day strings, or indexes to zero-based day offsets.
|
|
5151
5561
|
*/ function dateCellTimingRelativeIndexFactory(input) {
|
|
5152
5562
|
if (isDateCellTimingRelativeIndexFactory(input)) {
|
|
5153
5563
|
return input;
|
|
@@ -5186,6 +5596,9 @@ function _type_of$3(obj) {
|
|
|
5186
5596
|
* dates, date ranges, and cell ranges into a flat array of day indexes.
|
|
5187
5597
|
*
|
|
5188
5598
|
* Date ranges and cell ranges are expanded to include every index within the range.
|
|
5599
|
+
*
|
|
5600
|
+
* @param indexFactory - The relative index factory used for date-to-index conversion.
|
|
5601
|
+
* @returns A factory that flattens mixed date/range arrays into day index arrays.
|
|
5189
5602
|
*/ function dateCellTimingRelativeIndexArrayFactory(indexFactory) {
|
|
5190
5603
|
var factory = function factory(input) {
|
|
5191
5604
|
var inputAsArray = util.asArray(input);
|
|
@@ -5227,6 +5640,10 @@ function _type_of$3(obj) {
|
|
|
5227
5640
|
* // Get the index for a specific date
|
|
5228
5641
|
* const index = getRelativeIndexForDateCellTiming(timing, someDate);
|
|
5229
5642
|
* ```
|
|
5643
|
+
*
|
|
5644
|
+
* @param timing - The timing providing the start date and timezone context.
|
|
5645
|
+
* @param date - A date or index to convert; defaults to the current date/time.
|
|
5646
|
+
* @returns The zero-based day index relative to the timing's start.
|
|
5230
5647
|
*/ function getRelativeIndexForDateCellTiming(timing) {
|
|
5231
5648
|
var date = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Date();
|
|
5232
5649
|
return dateCellTimingRelativeIndexFactory(timing)(date);
|
|
@@ -5253,6 +5670,9 @@ function _type_of$3(obj) {
|
|
|
5253
5670
|
* // Convert index 3 to a date with a specific reference time
|
|
5254
5671
|
* const dateForDay3AtNoon = dateFactory(3, noonDate);
|
|
5255
5672
|
* ```
|
|
5673
|
+
*
|
|
5674
|
+
* @param timing - The timing providing the start date and timezone context.
|
|
5675
|
+
* @returns A factory that maps day indexes to calendar dates preserving the current time-of-day.
|
|
5256
5676
|
*/ function dateCellTimingDateFactory(timing) {
|
|
5257
5677
|
var _dateCellTimingStartPair = dateCellTimingStartPair(timing), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
|
|
5258
5678
|
var utcStartDate = normalInstance.baseDateToTargetDate(start);
|
|
@@ -5268,8 +5688,8 @@ function _type_of$3(obj) {
|
|
|
5268
5688
|
if (startUtcHours > nowHours) {
|
|
5269
5689
|
input += 1;
|
|
5270
5690
|
}
|
|
5271
|
-
|
|
5272
|
-
return
|
|
5691
|
+
// add days to apply the correct offset to the target index
|
|
5692
|
+
return dateFns.addHours(utcStartDateWithNowTime, input * util.HOURS_IN_DAY);
|
|
5273
5693
|
}
|
|
5274
5694
|
};
|
|
5275
5695
|
factory._timing = timing;
|
|
@@ -5286,6 +5706,9 @@ function _type_of$3(obj) {
|
|
|
5286
5706
|
* const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
|
|
5287
5707
|
* const lastIndex = dateCellTimingEndIndex(timing); // 4 (zero-based, 5 days)
|
|
5288
5708
|
* ```
|
|
5709
|
+
*
|
|
5710
|
+
* @param input - A timing or an existing relative index factory.
|
|
5711
|
+
* @returns The zero-based index of the last day in the schedule.
|
|
5289
5712
|
*/ function dateCellTimingEndIndex(input) {
|
|
5290
5713
|
var factory = dateCellTimingRelativeIndexFactory(input);
|
|
5291
5714
|
return factory(factory._timing.end);
|
|
@@ -5295,6 +5718,9 @@ function _type_of$3(obj) {
|
|
|
5295
5718
|
* for any day index relative to the timing's start.
|
|
5296
5719
|
*
|
|
5297
5720
|
* The returned date represents the beginning of the day in the timing's timezone context.
|
|
5721
|
+
*
|
|
5722
|
+
* @param input - A timing or an existing relative index factory.
|
|
5723
|
+
* @returns A factory that maps day indexes to the start-of-day date in the timing's timezone.
|
|
5298
5724
|
*/ function dateCellTimingStartDateFactory(input) {
|
|
5299
5725
|
var indexFactory = dateCellTimingRelativeIndexFactory(input);
|
|
5300
5726
|
var _dateCellTimingStartPair = dateCellTimingStartPair(indexFactory._timing), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
|
|
@@ -5332,6 +5758,10 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5332
5758
|
/**
|
|
5333
5759
|
* Convenience function that returns the calendar date for a given day index or date
|
|
5334
5760
|
* relative to the timing. Shorthand for creating a {@link dateCellTimingDateFactory} and invoking it.
|
|
5761
|
+
*
|
|
5762
|
+
* @param timing - The timing providing the start date and timezone context.
|
|
5763
|
+
* @param input - A date or day index to convert.
|
|
5764
|
+
* @returns The calendar date corresponding to the input, preserving current time-of-day.
|
|
5335
5765
|
*/ function getRelativeDateForDateCellTiming(timing, input) {
|
|
5336
5766
|
return dateCellTimingDateFactory(timing)(input);
|
|
5337
5767
|
}
|
|
@@ -5357,6 +5787,9 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5357
5787
|
* });
|
|
5358
5788
|
* // result has the same start day and end day, but new time-of-day and 90-minute duration
|
|
5359
5789
|
* ```
|
|
5790
|
+
*
|
|
5791
|
+
* @param input - Configuration specifying the timing to update, the event source, and which aspects to replace.
|
|
5792
|
+
* @returns A new {@link FullDateCellTiming} with the requested aspects replaced.
|
|
5360
5793
|
*/ function updateDateCellTimingWithDateCellTimingEvent(input) {
|
|
5361
5794
|
var timing = input.timing, event = input.event, replaceStartDay = input.replaceStartDay, replaceStartsAt = input.replaceStartsAt, startDateDay = input.startDayDate, endOnEvent = input.endOnEvent, replaceDuration = input.replaceDuration;
|
|
5362
5795
|
var timezone = timing.timezone;
|
|
@@ -5373,7 +5806,8 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5373
5806
|
var _dateCellTimingStartPair = dateCellTimingStartPair({
|
|
5374
5807
|
startsAt: event.startsAt,
|
|
5375
5808
|
timezone: timezone
|
|
5376
|
-
}),
|
|
5809
|
+
}), initialEventStartDate = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
|
|
5810
|
+
var eventStartDate = initialEventStartDate;
|
|
5377
5811
|
if (startDateDay != null) {
|
|
5378
5812
|
var startDateFactory = dateCellTimingStartDateFactory(timing);
|
|
5379
5813
|
eventStartDate = startDateFactory(startDateDay);
|
|
@@ -5437,6 +5871,9 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5437
5871
|
* isInRange(6); // false - index 6 is outside [2, 5]
|
|
5438
5872
|
* isInRange(someDate); // converts date to index, then checks containment
|
|
5439
5873
|
* ```
|
|
5874
|
+
*
|
|
5875
|
+
* @param config - Configuration specifying the reference range and optional timezone context.
|
|
5876
|
+
* @returns A predicate function that checks containment within the configured range.
|
|
5440
5877
|
*/ function isDateWithinDateCellRangeFunction(config) {
|
|
5441
5878
|
var inputStartsAt = config.startsAt, inputRange = config.range;
|
|
5442
5879
|
var startsAt = inputStartsAt;
|
|
@@ -5457,13 +5894,11 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5457
5894
|
} else {
|
|
5458
5895
|
rangeInput = inputRange;
|
|
5459
5896
|
}
|
|
5460
|
-
if (!inputStartsAt) {
|
|
5461
|
-
|
|
5462
|
-
startsAt
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
};
|
|
5466
|
-
}
|
|
5897
|
+
if (!inputStartsAt && dateRange && isDateInput) {
|
|
5898
|
+
startsAt = {
|
|
5899
|
+
startsAt: inputRange,
|
|
5900
|
+
timezone: guessCurrentTimezone()
|
|
5901
|
+
};
|
|
5467
5902
|
}
|
|
5468
5903
|
if (!startsAt) {
|
|
5469
5904
|
throw new Error('Invalid isDateWithinDateCellRangeFunction() config. StartsAt date info could not be determined from input.');
|
|
@@ -5616,6 +6051,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5616
6051
|
* Useful for identifying events or blocks that have already begun relative to a point in time.
|
|
5617
6052
|
*
|
|
5618
6053
|
* @param now - Reference time to compare against. Defaults to the current time.
|
|
6054
|
+
* @returns a filter function that returns true for spans whose start time is at or before the reference time
|
|
5619
6055
|
*
|
|
5620
6056
|
* @example
|
|
5621
6057
|
* ```ts
|
|
@@ -5634,6 +6070,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5634
6070
|
* The inverse of {@link dateCellDurationSpanHasStartedFilterFunction}. Useful for finding upcoming or future events.
|
|
5635
6071
|
*
|
|
5636
6072
|
* @param now - Reference time to compare against. Defaults to the current time.
|
|
6073
|
+
* @returns a filter function that returns true for spans whose start time is strictly after the reference time
|
|
5637
6074
|
*
|
|
5638
6075
|
* @example
|
|
5639
6076
|
* ```ts
|
|
@@ -5653,6 +6090,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5653
6090
|
* Useful for identifying completed events.
|
|
5654
6091
|
*
|
|
5655
6092
|
* @param now - Reference time to compare against. Defaults to the current time.
|
|
6093
|
+
* @returns a filter function that returns true for spans whose computed end time is at or before the reference time
|
|
5656
6094
|
*
|
|
5657
6095
|
* @example
|
|
5658
6096
|
* ```ts
|
|
@@ -5673,6 +6111,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5673
6111
|
* still in progress or have not yet occurred.
|
|
5674
6112
|
*
|
|
5675
6113
|
* @param now - Reference time to compare against. Defaults to the current time.
|
|
6114
|
+
* @returns a filter function that returns true for spans whose computed end time is strictly after the reference time
|
|
5676
6115
|
*
|
|
5677
6116
|
* @example
|
|
5678
6117
|
* ```ts
|
|
@@ -5694,6 +6133,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5694
6133
|
* indices clamped to the range boundaries. Non-overlapping cells are excluded entirely.
|
|
5695
6134
|
*
|
|
5696
6135
|
* @param range - The target range to fit cells into.
|
|
6136
|
+
* @returns a reusable function that clamps or filters date cells to the configured range
|
|
5697
6137
|
*
|
|
5698
6138
|
* @example
|
|
5699
6139
|
* ```ts
|
|
@@ -5734,6 +6174,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5734
6174
|
*
|
|
5735
6175
|
* @param range - The target range to fit cells into.
|
|
5736
6176
|
* @param input - The date cells to clamp or filter.
|
|
6177
|
+
* @returns an array of date cells clamped to the range, with non-overlapping cells removed
|
|
5737
6178
|
*
|
|
5738
6179
|
* @example
|
|
5739
6180
|
* ```ts
|
|
@@ -5748,6 +6189,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5748
6189
|
*
|
|
5749
6190
|
* @param range - The target range to fit the cell into.
|
|
5750
6191
|
* @param input - The single date cell to clamp or exclude.
|
|
6192
|
+
* @returns the clamped date cell, or `undefined` if it does not overlap the range
|
|
5751
6193
|
*
|
|
5752
6194
|
* @example
|
|
5753
6195
|
* ```ts
|
|
@@ -5762,7 +6204,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5762
6204
|
])[0];
|
|
5763
6205
|
}
|
|
5764
6206
|
|
|
5765
|
-
function _array_like_to_array$
|
|
6207
|
+
function _array_like_to_array$5(arr, len) {
|
|
5766
6208
|
if (len == null || len > arr.length) len = arr.length;
|
|
5767
6209
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5768
6210
|
return arr2;
|
|
@@ -5770,6 +6212,9 @@ function _array_like_to_array$4(arr, len) {
|
|
|
5770
6212
|
function _array_with_holes$2(arr) {
|
|
5771
6213
|
if (Array.isArray(arr)) return arr;
|
|
5772
6214
|
}
|
|
6215
|
+
function _array_without_holes$3(arr) {
|
|
6216
|
+
if (Array.isArray(arr)) return _array_like_to_array$5(arr);
|
|
6217
|
+
}
|
|
5773
6218
|
function _instanceof(left, right) {
|
|
5774
6219
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
5775
6220
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -5777,6 +6222,9 @@ function _instanceof(left, right) {
|
|
|
5777
6222
|
return left instanceof right;
|
|
5778
6223
|
}
|
|
5779
6224
|
}
|
|
6225
|
+
function _iterable_to_array$3(iter) {
|
|
6226
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
6227
|
+
}
|
|
5780
6228
|
function _iterable_to_array_limit$2(arr, i) {
|
|
5781
6229
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
5782
6230
|
if (_i == null) return;
|
|
@@ -5804,16 +6252,22 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
5804
6252
|
function _non_iterable_rest$2() {
|
|
5805
6253
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5806
6254
|
}
|
|
6255
|
+
function _non_iterable_spread$3() {
|
|
6256
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6257
|
+
}
|
|
5807
6258
|
function _sliced_to_array$2(arr, i) {
|
|
5808
|
-
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$
|
|
6259
|
+
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$2();
|
|
5809
6260
|
}
|
|
5810
|
-
function
|
|
6261
|
+
function _to_consumable_array$3(arr) {
|
|
6262
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$3();
|
|
6263
|
+
}
|
|
6264
|
+
function _unsupported_iterable_to_array$5(o, minLen) {
|
|
5811
6265
|
if (!o) return;
|
|
5812
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
6266
|
+
if (typeof o === "string") return _array_like_to_array$5(o, minLen);
|
|
5813
6267
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5814
6268
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5815
6269
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
5816
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
6270
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
|
|
5817
6271
|
}
|
|
5818
6272
|
/**
|
|
5819
6273
|
* Used for default YearWeekCode values
|
|
@@ -5901,15 +6355,15 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
5901
6355
|
* yearWeekCodeFromDate(new Date('2024-04-15')); // 202416
|
|
5902
6356
|
* ```
|
|
5903
6357
|
*/ function yearWeekCodeFromDate(date, timezone) {
|
|
6358
|
+
var result;
|
|
5904
6359
|
if (timezone) {
|
|
5905
|
-
|
|
5906
|
-
return yearWeekCodeFactory({
|
|
6360
|
+
result = yearWeekCodeFactory({
|
|
5907
6361
|
timezone: timezone
|
|
5908
6362
|
})(date);
|
|
5909
6363
|
} else {
|
|
5910
|
-
|
|
5911
|
-
return yearWeekCodeFromPair(yearWeekCodePairFromDate(date));
|
|
6364
|
+
result = yearWeekCodeFromPair(yearWeekCodePairFromDate(date));
|
|
5912
6365
|
}
|
|
6366
|
+
return result;
|
|
5913
6367
|
}
|
|
5914
6368
|
/**
|
|
5915
6369
|
* Resolves a timezone input into a {@link DateTimezoneUtcNormalInstance} for use with YearWeekCode calculations.
|
|
@@ -5919,8 +6373,7 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
5919
6373
|
* @param input - timezone string, config, or instance
|
|
5920
6374
|
* @returns the resolved normal instance
|
|
5921
6375
|
*/ function yearWeekCodeDateTimezoneInstance(input) {
|
|
5922
|
-
|
|
5923
|
-
return normal;
|
|
6376
|
+
return input ? _instanceof(input, DateTimezoneUtcNormalInstance) ? input : dateTimezoneUtcNormal(input) : SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE;
|
|
5924
6377
|
}
|
|
5925
6378
|
function yearWeekCode(dateOrYear, inputWeek) {
|
|
5926
6379
|
return yearWeekCodeFactory({
|
|
@@ -5972,6 +6425,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
5972
6425
|
*
|
|
5973
6426
|
* @param dateRange - the range to compute week codes for
|
|
5974
6427
|
* @param dateRangeTimezone - the timezone context for accurate week boundary calculation
|
|
6428
|
+
* @returns an array of YearWeekCode values covering the range
|
|
5975
6429
|
*/ function yearWeekCodeForDateRangeInTimezone(dateRange, dateRangeTimezone) {
|
|
5976
6430
|
return yearWeekCodeForDateRangeFactory(yearWeekCodeFactory({
|
|
5977
6431
|
timezone: dateRangeTimezone
|
|
@@ -6004,6 +6458,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6004
6458
|
* Returns all {@link YearWeekCode} values for the calendar month containing the given date, using the system timezone.
|
|
6005
6459
|
*
|
|
6006
6460
|
* @param date - a date within the target month
|
|
6461
|
+
* @returns an array of YearWeekCode values for the month
|
|
6007
6462
|
*/ function yearWeekCodeForCalendarMonth(date) {
|
|
6008
6463
|
return yearWeekCodeForCalendarMonthFactory(yearWeekCodeFactory({
|
|
6009
6464
|
timezone: SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE
|
|
@@ -6047,8 +6502,8 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6047
6502
|
var utcYearDate = new Date(Date.UTC(pair.year, 0, 1, 0, 0, 0, 0));
|
|
6048
6503
|
var systemYearDate = normal.systemDateToBaseDate(utcYearDate); // convert to system before using system date functions
|
|
6049
6504
|
var date = dateFns.startOfWeek(dateFns.setWeek(systemYearDate, pair.week));
|
|
6050
|
-
|
|
6051
|
-
return
|
|
6505
|
+
// back to timezone
|
|
6506
|
+
return normal.targetDateToSystemDate(date);
|
|
6052
6507
|
};
|
|
6053
6508
|
}
|
|
6054
6509
|
/**
|
|
@@ -6102,10 +6557,10 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6102
6557
|
}
|
|
6103
6558
|
return yearWeekCode;
|
|
6104
6559
|
});
|
|
6105
|
-
var groups =
|
|
6560
|
+
var groups = _to_consumable_array$3(map.entries()).map(function(param) {
|
|
6106
6561
|
var _param = _sliced_to_array$2(param, 2), week = _param[0], _$items = _param[1];
|
|
6107
6562
|
return {
|
|
6108
|
-
week: week
|
|
6563
|
+
week: week !== null && week !== void 0 ? week : 0,
|
|
6109
6564
|
items: _$items
|
|
6110
6565
|
};
|
|
6111
6566
|
});
|
|
@@ -6144,8 +6599,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6144
6599
|
var normalInstance = startDateFactory._indexFactory._normalInstance;
|
|
6145
6600
|
return function(indexOrDate) {
|
|
6146
6601
|
var dateInSystemTimezone = normalInstance.systemDateToTargetDate(startDateFactory(indexOrDate));
|
|
6147
|
-
|
|
6148
|
-
return yearWeekCode;
|
|
6602
|
+
return yearWeekCodeFromDate(dateInSystemTimezone);
|
|
6149
6603
|
};
|
|
6150
6604
|
}
|
|
6151
6605
|
/**
|
|
@@ -6156,21 +6610,20 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6156
6610
|
*/ function dateCellIndexYearWeekCodeGroupFactory(config) {
|
|
6157
6611
|
var dateCellIndexReader = config.dateCellIndexReader, inputDateCellIndexYearWeekCodeFactory = config.dateCellIndexYearWeekCodeFactory;
|
|
6158
6612
|
var dateCellIndexYearWeekCode = typeof inputDateCellIndexYearWeekCodeFactory === 'function' ? inputDateCellIndexYearWeekCodeFactory : dateCellIndexYearWeekCodeFactory(inputDateCellIndexYearWeekCodeFactory);
|
|
6159
|
-
|
|
6613
|
+
return yearWeekCodeGroupFactory({
|
|
6160
6614
|
yearWeekCodeFactory: dateCellIndexYearWeekCode,
|
|
6161
6615
|
yearWeekCodeReader: dateCellIndexYearWeekCode,
|
|
6162
6616
|
dateReader: dateCellIndexReader
|
|
6163
6617
|
});
|
|
6164
|
-
return factory;
|
|
6165
6618
|
}
|
|
6166
6619
|
|
|
6167
|
-
function _array_like_to_array$
|
|
6620
|
+
function _array_like_to_array$4(arr, len) {
|
|
6168
6621
|
if (len == null || len > arr.length) len = arr.length;
|
|
6169
6622
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
6170
6623
|
return arr2;
|
|
6171
6624
|
}
|
|
6172
|
-
function _array_without_holes$
|
|
6173
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
6625
|
+
function _array_without_holes$2(arr) {
|
|
6626
|
+
if (Array.isArray(arr)) return _array_like_to_array$4(arr);
|
|
6174
6627
|
}
|
|
6175
6628
|
function _define_property$9(obj, key, value) {
|
|
6176
6629
|
if (key in obj) {
|
|
@@ -6185,10 +6638,10 @@ function _define_property$9(obj, key, value) {
|
|
|
6185
6638
|
}
|
|
6186
6639
|
return obj;
|
|
6187
6640
|
}
|
|
6188
|
-
function _iterable_to_array$
|
|
6641
|
+
function _iterable_to_array$2(iter) {
|
|
6189
6642
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
6190
6643
|
}
|
|
6191
|
-
function _non_iterable_spread$
|
|
6644
|
+
function _non_iterable_spread$2() {
|
|
6192
6645
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6193
6646
|
}
|
|
6194
6647
|
function _object_spread$7(target) {
|
|
@@ -6225,20 +6678,20 @@ function _object_spread_props$5(target, source) {
|
|
|
6225
6678
|
}
|
|
6226
6679
|
return target;
|
|
6227
6680
|
}
|
|
6228
|
-
function _to_consumable_array$
|
|
6229
|
-
return _array_without_holes$
|
|
6681
|
+
function _to_consumable_array$2(arr) {
|
|
6682
|
+
return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$2();
|
|
6230
6683
|
}
|
|
6231
6684
|
function _type_of$2(obj) {
|
|
6232
6685
|
"@swc/helpers - typeof";
|
|
6233
6686
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
6234
6687
|
}
|
|
6235
|
-
function _unsupported_iterable_to_array$
|
|
6688
|
+
function _unsupported_iterable_to_array$4(o, minLen) {
|
|
6236
6689
|
if (!o) return;
|
|
6237
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
6690
|
+
if (typeof o === "string") return _array_like_to_array$4(o, minLen);
|
|
6238
6691
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
6239
6692
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
6240
6693
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
6241
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
6694
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
|
|
6242
6695
|
}
|
|
6243
6696
|
/**
|
|
6244
6697
|
* Encodes days of the week as numeric codes for use in schedule filtering.
|
|
@@ -6303,7 +6756,7 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
6303
6756
|
* @param input - schedule day codes to convert (WEEKDAY/WEEKEND shorthand codes are expanded)
|
|
6304
6757
|
* @returns an EnabledDays object with boolean flags for each day
|
|
6305
6758
|
*/ function enabledDaysFromDateCellScheduleDayCodes(input) {
|
|
6306
|
-
var days = expandDateCellScheduleDayCodesToDayOfWeekSet(
|
|
6759
|
+
var days = expandDateCellScheduleDayCodesToDayOfWeekSet(_to_consumable_array$2(new Set(input)));
|
|
6307
6760
|
return util.enabledDaysFromDaysOfWeek(days);
|
|
6308
6761
|
}
|
|
6309
6762
|
/**
|
|
@@ -6380,7 +6833,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6380
6833
|
* simplifyDateCellScheduleDayCodes([2, 4]);
|
|
6381
6834
|
* // Returns [DateCellScheduleDayCode.MONDAY, DateCellScheduleDayCode.WEDNESDAY] // [2, 4]
|
|
6382
6835
|
* ```
|
|
6383
|
-
*/
|
|
6836
|
+
*/ // eslint-disable-next-line sonarjs/cognitive-complexity
|
|
6837
|
+
function simplifyDateCellScheduleDayCodes(codes) {
|
|
6384
6838
|
var codesSet = new Set(codes);
|
|
6385
6839
|
var result = [];
|
|
6386
6840
|
if (codesSet.size >= 2) {
|
|
@@ -6451,7 +6905,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6451
6905
|
* @param input - day codes to expand
|
|
6452
6906
|
* @returns sorted array of individual day codes (1-7 only, no shorthand)
|
|
6453
6907
|
*/ function expandDateCellScheduleDayCodes(input) {
|
|
6454
|
-
return
|
|
6908
|
+
return _to_consumable_array$2(expandDateCellScheduleDayCodesToDayCodesSet(input)).sort(util.sortNumbersAscendingFunction);
|
|
6455
6909
|
}
|
|
6456
6910
|
/**
|
|
6457
6911
|
* Expands the input DateCellScheduleDayCodesInput to a Set of individual DateCellScheduleDayCode values (1-7), expanding shorthand codes like WEEKDAY and WEEKEND.
|
|
@@ -6462,6 +6916,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6462
6916
|
var codes = rawDateCellScheduleDayCodes(input);
|
|
6463
6917
|
var days = new Set();
|
|
6464
6918
|
codes.forEach(function(code) {
|
|
6919
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
6465
6920
|
switch(code){
|
|
6466
6921
|
case 0:
|
|
6467
6922
|
break;
|
|
@@ -6487,9 +6942,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6487
6942
|
* @returns raw array of day codes with NONE values removed
|
|
6488
6943
|
*/ function rawDateCellScheduleDayCodes(input) {
|
|
6489
6944
|
var dayCodes;
|
|
6945
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
6490
6946
|
switch(typeof input === "undefined" ? "undefined" : _type_of$2(input)){
|
|
6491
6947
|
case 'string':
|
|
6492
|
-
dayCodes =
|
|
6948
|
+
dayCodes = _to_consumable_array$2(new Set(input)).map(function(x) {
|
|
6493
6949
|
return Number(x);
|
|
6494
6950
|
});
|
|
6495
6951
|
break;
|
|
@@ -6499,7 +6955,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6499
6955
|
];
|
|
6500
6956
|
break;
|
|
6501
6957
|
default:
|
|
6502
|
-
dayCodes =
|
|
6958
|
+
dayCodes = _to_consumable_array$2(input);
|
|
6503
6959
|
break;
|
|
6504
6960
|
}
|
|
6505
6961
|
return dayCodes.filter(function(x) {
|
|
@@ -6608,7 +7064,6 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6608
7064
|
var timezone = inputTimezone !== null && inputTimezone !== void 0 ? inputTimezone : requireCurrentTimezone(); // treat input as the current timezone
|
|
6609
7065
|
var normalInstance = dateTimezoneUtcNormal(timezone);
|
|
6610
7066
|
var start;
|
|
6611
|
-
var end;
|
|
6612
7067
|
// either start or startsAt is provided
|
|
6613
7068
|
if (inputStart != null) {
|
|
6614
7069
|
var startInSystemTimezone = normalInstance.systemDateToTargetDate(inputStart); // start needs to be in the system timezone normal before processing.
|
|
@@ -6625,7 +7080,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6625
7080
|
}
|
|
6626
7081
|
}
|
|
6627
7082
|
// set the end value
|
|
6628
|
-
end = inputEnd !== null && inputEnd !== void 0 ? inputEnd : dateFns.addMinutes(start, 1); // default the end to one minute after the start
|
|
7083
|
+
var end = inputEnd !== null && inputEnd !== void 0 ? inputEnd : dateFns.addMinutes(start, 1); // default the end to one minute after the start
|
|
6629
7084
|
return {
|
|
6630
7085
|
w: w,
|
|
6631
7086
|
ex: ex,
|
|
@@ -6827,11 +7282,12 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6827
7282
|
* filter(5); // false (Saturday Jan 11)
|
|
6828
7283
|
* ```
|
|
6829
7284
|
*/ function dateCellScheduleDateFilter(config) {
|
|
7285
|
+
var _ref;
|
|
6830
7286
|
var w = config.w, inputStart = config.start, inputStartsAt = config.startsAt, inputEnd = config.end, inputTimezone = config.timezone, _config_setStartAsMinDate = config.setStartAsMinDate, setStartAsMinDate = _config_setStartAsMinDate === void 0 ? true : _config_setStartAsMinDate, minMaxDateRange = config.minMaxDateRange;
|
|
6831
7287
|
var timezone = inputTimezone !== null && inputTimezone !== void 0 ? inputTimezone : requireCurrentTimezone(); // if the timezone is not provided, assume the startsAt is a system timezone normal.
|
|
6832
7288
|
var normalInstance = dateTimezoneUtcNormal(timezone);
|
|
6833
7289
|
// derive the startsAt time for the range. If not provided, defaults to inputStart, or midnight today in the target timezone.
|
|
6834
|
-
var startsAt = inputStartsAt
|
|
7290
|
+
var startsAt = (_ref = inputStartsAt !== null && inputStartsAt !== void 0 ? inputStartsAt : inputStart) !== null && _ref !== void 0 ? _ref : normalInstance.startOfDayInTargetTimezone();
|
|
6835
7291
|
var allowedDays = expandDateCellScheduleDayCodesToDayOfWeekSet(w);
|
|
6836
7292
|
var startsAtInSystem = normalInstance.systemDateToTargetDate(startsAt); // convert to the system date
|
|
6837
7293
|
var firstDateDay = dateFns.getDay(startsAtInSystem);
|
|
@@ -6857,15 +7313,13 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6857
7313
|
var excludedIndexes = new Set(config.ex);
|
|
6858
7314
|
var fn = function fn(input) {
|
|
6859
7315
|
var i;
|
|
6860
|
-
var day;
|
|
6861
7316
|
if (typeof input === 'number') {
|
|
6862
7317
|
i = input;
|
|
6863
7318
|
} else {
|
|
6864
7319
|
i = _dateCellTimingRelativeIndexFactory(input);
|
|
6865
7320
|
}
|
|
6866
|
-
day = dayForIndex(i);
|
|
6867
|
-
|
|
6868
|
-
return result;
|
|
7321
|
+
var day = dayForIndex(i);
|
|
7322
|
+
return i >= minAllowedIndex && i <= maxAllowedIndex && allowedDays.has(day) && !excludedIndexes.has(i) || includedIndexes.has(i);
|
|
6869
7323
|
};
|
|
6870
7324
|
fn._dateCellTimingRelativeIndexFactory = _dateCellTimingRelativeIndexFactory;
|
|
6871
7325
|
return fn;
|
|
@@ -6919,6 +7373,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6919
7373
|
* Creates a DateCellScheduleDateCellTimingFilter that tests whether a DateCell block's index is allowed by the schedule within the given timing.
|
|
6920
7374
|
*
|
|
6921
7375
|
* @param config - timing and schedule to build the filter from
|
|
7376
|
+
* @param config.timing - the DateCellTiming that defines the date range and event times for the filter
|
|
7377
|
+
* @param config.schedule - the DateCellSchedule that controls which day codes and indices are included or excluded
|
|
6922
7378
|
* @returns a decision function returning true for allowed blocks
|
|
6923
7379
|
*/ function dateCellScheduleDateCellTimingFilter(param) {
|
|
6924
7380
|
var timing = param.timing, schedule = param.schedule;
|
|
@@ -6942,7 +7398,6 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6942
7398
|
* @returns an expansion factory that converts DateCellRange arrays into filtered DateCellDurationSpan arrays
|
|
6943
7399
|
*/ function expandDateCellScheduleFactory(config) {
|
|
6944
7400
|
var _config_invertSchedule = config.invertSchedule, invertSchedule = _config_invertSchedule === void 0 ? false : _config_invertSchedule, now = config.now, onlyBlocksThatHaveEnded = config.onlyBlocksThatHaveEnded, onlyBlocksThatHaveStarted = config.onlyBlocksThatHaveStarted, onlyBlocksNotYetEnded = config.onlyBlocksNotYetEnded, onlyBlocksNotYetStarted = config.onlyBlocksNotYetStarted, maxDateCellsToReturn = config.maxDateCellsToReturn, inputDurationSpanFilter = config.durationSpanFilter;
|
|
6945
|
-
var durationSpanFilter;
|
|
6946
7401
|
var durationSpanFilters = [];
|
|
6947
7402
|
if (inputDurationSpanFilter) {
|
|
6948
7403
|
durationSpanFilters.push(inputDurationSpanFilter);
|
|
@@ -6959,14 +7414,13 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6959
7414
|
durationSpanFilters.push(dateCellDurationSpanHasNotEndedFilterFunction(now));
|
|
6960
7415
|
}
|
|
6961
7416
|
}
|
|
6962
|
-
durationSpanFilter = util.mergeFilterFunctions.apply(void 0, _to_consumable_array$
|
|
6963
|
-
|
|
7417
|
+
var durationSpanFilter = util.mergeFilterFunctions.apply(void 0, _to_consumable_array$2(durationSpanFilters));
|
|
7418
|
+
return dateCellTimingExpansionFactory({
|
|
6964
7419
|
timing: config.timing,
|
|
6965
7420
|
filter: util.invertFilter(dateCellScheduleDateCellTimingFilter(config), invertSchedule),
|
|
6966
7421
|
durationSpanFilter: durationSpanFilter,
|
|
6967
7422
|
maxDateCellsToReturn: maxDateCellsToReturn
|
|
6968
7423
|
});
|
|
6969
|
-
return expansionFactory;
|
|
6970
7424
|
}
|
|
6971
7425
|
/**
|
|
6972
7426
|
* Expands a DateCellTiming and DateCellSchedule into concrete DateCellDurationSpan values representing each active block in the event.
|
|
@@ -7052,26 +7506,165 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7052
7506
|
});
|
|
7053
7507
|
}
|
|
7054
7508
|
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7509
|
+
function _define_property$8(obj, key, value) {
|
|
7510
|
+
if (key in obj) {
|
|
7511
|
+
Object.defineProperty(obj, key, {
|
|
7512
|
+
value: value,
|
|
7513
|
+
enumerable: true,
|
|
7514
|
+
configurable: true,
|
|
7515
|
+
writable: true
|
|
7516
|
+
});
|
|
7517
|
+
} else {
|
|
7518
|
+
obj[key] = value;
|
|
7519
|
+
}
|
|
7520
|
+
return obj;
|
|
7521
|
+
}
|
|
7522
|
+
function _object_spread$6(target) {
|
|
7523
|
+
for(var i = 1; i < arguments.length; i++){
|
|
7524
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
7525
|
+
var ownKeys = Object.keys(source);
|
|
7526
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
7527
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
7528
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
7529
|
+
}));
|
|
7530
|
+
}
|
|
7531
|
+
ownKeys.forEach(function(key) {
|
|
7532
|
+
_define_property$8(target, key, source[key]);
|
|
7533
|
+
});
|
|
7534
|
+
}
|
|
7535
|
+
return target;
|
|
7065
7536
|
}
|
|
7066
7537
|
/**
|
|
7067
|
-
*
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7538
|
+
* Distinguishes between time-based calendar events and all-day/multi-day events.
|
|
7539
|
+
*/ exports.CalendarDateType = void 0;
|
|
7540
|
+
(function(CalendarDateType) {
|
|
7541
|
+
/**
|
|
7542
|
+
* Event starts at a specific time and lasts for a certain duration.
|
|
7543
|
+
*/ CalendarDateType["TIME"] = "time";
|
|
7544
|
+
/**
|
|
7545
|
+
* Event is specifically for a number of days. Duration is still tracked in minutes.
|
|
7546
|
+
*/ CalendarDateType["DAYS"] = "days";
|
|
7547
|
+
})(exports.CalendarDateType || (exports.CalendarDateType = {}));
|
|
7548
|
+
/**
|
|
7549
|
+
* Creates a {@link CalendarDateFactory} that produces all-day calendar events with timezone-aware start times.
|
|
7550
|
+
*
|
|
7551
|
+
* The factory converts an ISO 8601 day string to a UTC date, then applies timezone normalization
|
|
7552
|
+
* so the resulting `startsAt` represents the correct moment for the target timezone.
|
|
7553
|
+
*
|
|
7554
|
+
* @param config - optional timezone configuration
|
|
7555
|
+
* @returns a factory function that creates CalendarDate objects
|
|
7556
|
+
*
|
|
7557
|
+
* @example
|
|
7558
|
+
* ```ts
|
|
7559
|
+
* const factory = calendarDateFactory({ timezone: 'America/Denver' });
|
|
7560
|
+
* const event = factory('2024-01-15', 3);
|
|
7561
|
+
* // event.type === CalendarDateType.DAYS
|
|
7562
|
+
* // event.duration === daysToMinutes(3)
|
|
7563
|
+
* ```
|
|
7564
|
+
*/ function calendarDateFactory(config) {
|
|
7565
|
+
var normalConfig = (config === null || config === void 0 ? void 0 : config.timezone) === undefined ? {
|
|
7566
|
+
useSystemTimezone: true
|
|
7567
|
+
} : {
|
|
7568
|
+
timezone: config.timezone ? config.timezone : undefined
|
|
7569
|
+
};
|
|
7570
|
+
var normal = dateTimezoneUtcNormal(normalConfig);
|
|
7571
|
+
return function(day, days) {
|
|
7572
|
+
var date = util.parseISO8601DayStringToUTCDate(day);
|
|
7573
|
+
var startsAt = normal.targetDateToBaseDate(date);
|
|
7574
|
+
return {
|
|
7575
|
+
type: exports.CalendarDateType.DAYS,
|
|
7576
|
+
startsAt: startsAt,
|
|
7577
|
+
duration: daysToMinutes(days)
|
|
7578
|
+
};
|
|
7579
|
+
};
|
|
7580
|
+
}
|
|
7581
|
+
/**
|
|
7582
|
+
* Convenience function that creates a single all-day {@link CalendarDate} with optional timezone.
|
|
7583
|
+
*
|
|
7584
|
+
* Shorthand for creating a factory and immediately invoking it.
|
|
7585
|
+
*
|
|
7586
|
+
* @param day - ISO 8601 day string (e.g. '2024-01-15')
|
|
7587
|
+
* @param days - number of days the event spans
|
|
7588
|
+
* @param timezone - IANA timezone string, false for UTC, or undefined for system timezone
|
|
7589
|
+
* @returns a CalendarDate with type DAYS
|
|
7590
|
+
*
|
|
7591
|
+
* @example
|
|
7592
|
+
* ```ts
|
|
7593
|
+
* const event = calendarDate('2024-01-15', 1, 'America/Denver');
|
|
7594
|
+
* // event.type === CalendarDateType.DAYS
|
|
7595
|
+
* ```
|
|
7596
|
+
*/ function calendarDate(day, days, timezone) {
|
|
7597
|
+
return calendarDateFactory({
|
|
7598
|
+
timezone: timezone
|
|
7599
|
+
})(day, days);
|
|
7600
|
+
}
|
|
7601
|
+
/**
|
|
7602
|
+
* Wraps an existing {@link DateDurationSpan} as a time-based {@link CalendarDate}.
|
|
7603
|
+
*
|
|
7604
|
+
* @param dateDurationSpan - the duration span to wrap
|
|
7605
|
+
* @returns a CalendarDate with type TIME
|
|
7606
|
+
*
|
|
7607
|
+
* @example
|
|
7608
|
+
* ```ts
|
|
7609
|
+
* const span: DateDurationSpan = { startsAt: new Date(), duration: 60 };
|
|
7610
|
+
* const event = calendarDateForDateDurationSpan(span);
|
|
7611
|
+
* // event.type === CalendarDateType.TIME
|
|
7612
|
+
* ```
|
|
7613
|
+
*/ function calendarDateForDateDurationSpan(dateDurationSpan) {
|
|
7614
|
+
return _object_spread$6({
|
|
7615
|
+
type: exports.CalendarDateType.TIME
|
|
7616
|
+
}, dateDurationSpan);
|
|
7617
|
+
}
|
|
7618
|
+
|
|
7619
|
+
function _array_like_to_array$3(arr, len) {
|
|
7620
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
7621
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
7622
|
+
return arr2;
|
|
7623
|
+
}
|
|
7624
|
+
function _array_without_holes$1(arr) {
|
|
7625
|
+
if (Array.isArray(arr)) return _array_like_to_array$3(arr);
|
|
7626
|
+
}
|
|
7627
|
+
function _iterable_to_array$1(iter) {
|
|
7628
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
7629
|
+
}
|
|
7630
|
+
function _non_iterable_spread$1() {
|
|
7631
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
7632
|
+
}
|
|
7633
|
+
function _to_consumable_array$1(arr) {
|
|
7634
|
+
return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$3(arr) || _non_iterable_spread$1();
|
|
7635
|
+
}
|
|
7636
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
7637
|
+
if (!o) return;
|
|
7638
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
7639
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
7640
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
7641
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
7642
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
7643
|
+
}
|
|
7644
|
+
/**
|
|
7645
|
+
* Returns all recognized IANA timezone strings, including the explicit UTC entry.
|
|
7646
|
+
*
|
|
7647
|
+
* @returns all known IANA timezone strings plus UTC
|
|
7648
|
+
*
|
|
7649
|
+
* @example
|
|
7650
|
+
* ```ts
|
|
7651
|
+
* const zones = allTimezoneStrings();
|
|
7652
|
+
* // ['Africa/Abidjan', ..., 'UTC']
|
|
7653
|
+
* ```
|
|
7654
|
+
*/ function allTimezoneStrings() {
|
|
7655
|
+
return _to_consumable_array$1(tzdb.timeZonesNames).concat([
|
|
7656
|
+
util.UTC_TIMEZONE_STRING
|
|
7657
|
+
]);
|
|
7658
|
+
}
|
|
7659
|
+
/**
|
|
7660
|
+
* Lazily-computed set of all known timezone strings for O(1) membership checks.
|
|
7661
|
+
*
|
|
7662
|
+
* @example
|
|
7663
|
+
* ```ts
|
|
7664
|
+
* allKnownTimezoneStrings().has('America/New_York'); // true
|
|
7665
|
+
* ```
|
|
7666
|
+
*/ var allKnownTimezoneStrings = util.cachedGetter(function() {
|
|
7667
|
+
return new Set(allTimezoneStrings());
|
|
7075
7668
|
});
|
|
7076
7669
|
/**
|
|
7077
7670
|
* Lazily-computed array of {@link TimezoneInfo} for every known timezone.
|
|
@@ -7087,6 +7680,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7087
7680
|
/**
|
|
7088
7681
|
* Returns the {@link TimezoneInfo} for the current system timezone, falling back to UTC.
|
|
7089
7682
|
*
|
|
7683
|
+
* @returns timezone info for the current system timezone
|
|
7684
|
+
*
|
|
7090
7685
|
* @example
|
|
7091
7686
|
* ```ts
|
|
7092
7687
|
* const info = timezoneInfoForSystem();
|
|
@@ -7102,6 +7697,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7102
7697
|
* The date matters because abbreviations change with DST transitions.
|
|
7103
7698
|
* Returns `"UKNOWN"` if no timezone is provided.
|
|
7104
7699
|
*
|
|
7700
|
+
* @param timezone - the IANA timezone string (or UTC abbreviation) to get the abbreviation for
|
|
7701
|
+
* @param date - the date at which to evaluate the abbreviation (defaults to now)
|
|
7702
|
+
* @returns the short timezone abbreviation
|
|
7703
|
+
*
|
|
7105
7704
|
* @example
|
|
7106
7705
|
* ```ts
|
|
7107
7706
|
* getTimezoneAbbreviation('America/New_York'); // 'EST' or 'EDT'
|
|
@@ -7115,6 +7714,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7115
7714
|
*
|
|
7116
7715
|
* Returns `"Unknown Timezone"` if no timezone is provided.
|
|
7117
7716
|
*
|
|
7717
|
+
* @param timezone - the IANA timezone string to get the long name for
|
|
7718
|
+
* @param date - the date at which to evaluate the name (defaults to now)
|
|
7719
|
+
* @returns the full timezone display name
|
|
7720
|
+
*
|
|
7118
7721
|
* @example
|
|
7119
7722
|
* ```ts
|
|
7120
7723
|
* getTimezoneLongName('America/New_York'); // 'Eastern Standard Time'
|
|
@@ -7126,6 +7729,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7126
7729
|
/**
|
|
7127
7730
|
* Builds a {@link TimezoneInfo} for the given timezone, computing abbreviation and search variants.
|
|
7128
7731
|
*
|
|
7732
|
+
* @param timezone - the IANA timezone string to build info for
|
|
7733
|
+
* @param date - the date at which to evaluate the abbreviation (defaults to now)
|
|
7734
|
+
* @returns the computed TimezoneInfo
|
|
7735
|
+
*
|
|
7129
7736
|
* @example
|
|
7130
7737
|
* ```ts
|
|
7131
7738
|
* const info = timezoneStringToTimezoneInfo('America/Chicago');
|
|
@@ -7135,14 +7742,13 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7135
7742
|
*/ function timezoneStringToTimezoneInfo(timezone) {
|
|
7136
7743
|
var date = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Date();
|
|
7137
7744
|
var abbreviation = getTimezoneAbbreviation(timezone, date);
|
|
7138
|
-
|
|
7745
|
+
return {
|
|
7139
7746
|
timezone: timezone,
|
|
7140
7747
|
search: timezoneStringToSearchableString(timezone),
|
|
7141
7748
|
lowercase: timezone.toLowerCase(),
|
|
7142
7749
|
abbreviation: abbreviation,
|
|
7143
7750
|
lowercaseAbbreviation: abbreviation.toLowerCase()
|
|
7144
7751
|
};
|
|
7145
|
-
return result;
|
|
7146
7752
|
}
|
|
7147
7753
|
/**
|
|
7148
7754
|
* Filters timezone infos by a search string, matching against the searchable name,
|
|
@@ -7150,6 +7756,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7150
7756
|
*
|
|
7151
7757
|
* For queries longer than 2 characters, substring matching on the searchable name is also used.
|
|
7152
7758
|
*
|
|
7759
|
+
* @param search - the search query string
|
|
7760
|
+
* @param infos - the array of TimezoneInfo objects to filter
|
|
7761
|
+
* @returns the matching TimezoneInfo entries
|
|
7762
|
+
*
|
|
7153
7763
|
* @example
|
|
7154
7764
|
* ```ts
|
|
7155
7765
|
* const results = searchTimezoneInfos('eastern', allTimezoneInfos());
|
|
@@ -7172,6 +7782,9 @@ var timezoneStringToSearchableStringReplace = util.replaceStringsFunction({
|
|
|
7172
7782
|
*
|
|
7173
7783
|
* Replaces `/` and `_` with spaces (e.g., `"America/New_York"` becomes `"america new york"`).
|
|
7174
7784
|
*
|
|
7785
|
+
* @param timezone - the IANA timezone string to convert
|
|
7786
|
+
* @returns the searchable lowercase string
|
|
7787
|
+
*
|
|
7175
7788
|
* @example
|
|
7176
7789
|
* ```ts
|
|
7177
7790
|
* timezoneStringToSearchableString('America/New_York'); // 'america new york'
|
|
@@ -7184,6 +7797,9 @@ var timezoneStringToSearchableStringReplace = util.replaceStringsFunction({
|
|
|
7184
7797
|
*
|
|
7185
7798
|
* Uses the cached set from {@link allKnownTimezoneStrings} for O(1) lookup.
|
|
7186
7799
|
*
|
|
7800
|
+
* @param input - the string to check
|
|
7801
|
+
* @returns whether the input is a known timezone
|
|
7802
|
+
*
|
|
7187
7803
|
* @example
|
|
7188
7804
|
* ```ts
|
|
7189
7805
|
* isKnownTimezone('America/New_York'); // true
|
|
@@ -7193,116 +7809,6 @@ var timezoneStringToSearchableStringReplace = util.replaceStringsFunction({
|
|
|
7193
7809
|
return allKnownTimezoneStrings().has(input);
|
|
7194
7810
|
}
|
|
7195
7811
|
|
|
7196
|
-
function _define_property$8(obj, key, value) {
|
|
7197
|
-
if (key in obj) {
|
|
7198
|
-
Object.defineProperty(obj, key, {
|
|
7199
|
-
value: value,
|
|
7200
|
-
enumerable: true,
|
|
7201
|
-
configurable: true,
|
|
7202
|
-
writable: true
|
|
7203
|
-
});
|
|
7204
|
-
} else {
|
|
7205
|
-
obj[key] = value;
|
|
7206
|
-
}
|
|
7207
|
-
return obj;
|
|
7208
|
-
}
|
|
7209
|
-
function _object_spread$6(target) {
|
|
7210
|
-
for(var i = 1; i < arguments.length; i++){
|
|
7211
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
7212
|
-
var ownKeys = Object.keys(source);
|
|
7213
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
7214
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
7215
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
7216
|
-
}));
|
|
7217
|
-
}
|
|
7218
|
-
ownKeys.forEach(function(key) {
|
|
7219
|
-
_define_property$8(target, key, source[key]);
|
|
7220
|
-
});
|
|
7221
|
-
}
|
|
7222
|
-
return target;
|
|
7223
|
-
}
|
|
7224
|
-
/**
|
|
7225
|
-
* Distinguishes between time-based calendar events and all-day/multi-day events.
|
|
7226
|
-
*/ exports.CalendarDateType = void 0;
|
|
7227
|
-
(function(CalendarDateType) {
|
|
7228
|
-
/**
|
|
7229
|
-
* Event starts at a specific time and lasts for a certain duration.
|
|
7230
|
-
*/ CalendarDateType["TIME"] = "time";
|
|
7231
|
-
/**
|
|
7232
|
-
* Event is specifically for a number of days. Duration is still tracked in minutes.
|
|
7233
|
-
*/ CalendarDateType["DAYS"] = "days";
|
|
7234
|
-
})(exports.CalendarDateType || (exports.CalendarDateType = {}));
|
|
7235
|
-
/**
|
|
7236
|
-
* Creates a {@link CalendarDateFactory} that produces all-day calendar events with timezone-aware start times.
|
|
7237
|
-
*
|
|
7238
|
-
* The factory converts an ISO 8601 day string to a UTC date, then applies timezone normalization
|
|
7239
|
-
* so the resulting `startsAt` represents the correct moment for the target timezone.
|
|
7240
|
-
*
|
|
7241
|
-
* @param config - optional timezone configuration
|
|
7242
|
-
* @returns a factory function that creates CalendarDate objects
|
|
7243
|
-
*
|
|
7244
|
-
* @example
|
|
7245
|
-
* ```ts
|
|
7246
|
-
* const factory = calendarDateFactory({ timezone: 'America/Denver' });
|
|
7247
|
-
* const event = factory('2024-01-15', 3);
|
|
7248
|
-
* // event.type === CalendarDateType.DAYS
|
|
7249
|
-
* // event.duration === daysToMinutes(3)
|
|
7250
|
-
* ```
|
|
7251
|
-
*/ function calendarDateFactory(config) {
|
|
7252
|
-
var normalConfig = (config === null || config === void 0 ? void 0 : config.timezone) === undefined ? {
|
|
7253
|
-
useSystemTimezone: true
|
|
7254
|
-
} : {
|
|
7255
|
-
timezone: config.timezone ? config.timezone : undefined
|
|
7256
|
-
};
|
|
7257
|
-
var normal = dateTimezoneUtcNormal(normalConfig);
|
|
7258
|
-
return function(day, days) {
|
|
7259
|
-
var date = util.parseISO8601DayStringToUTCDate(day);
|
|
7260
|
-
var startsAt = normal.targetDateToBaseDate(date);
|
|
7261
|
-
return {
|
|
7262
|
-
type: exports.CalendarDateType.DAYS,
|
|
7263
|
-
startsAt: startsAt,
|
|
7264
|
-
duration: daysToMinutes(days)
|
|
7265
|
-
};
|
|
7266
|
-
};
|
|
7267
|
-
}
|
|
7268
|
-
/**
|
|
7269
|
-
* Convenience function that creates a single all-day {@link CalendarDate} with optional timezone.
|
|
7270
|
-
*
|
|
7271
|
-
* Shorthand for creating a factory and immediately invoking it.
|
|
7272
|
-
*
|
|
7273
|
-
* @param day - ISO 8601 day string (e.g. '2024-01-15')
|
|
7274
|
-
* @param days - number of days the event spans
|
|
7275
|
-
* @param timezone - IANA timezone string, false for UTC, or undefined for system timezone
|
|
7276
|
-
* @returns a CalendarDate with type DAYS
|
|
7277
|
-
*
|
|
7278
|
-
* @example
|
|
7279
|
-
* ```ts
|
|
7280
|
-
* const event = calendarDate('2024-01-15', 1, 'America/Denver');
|
|
7281
|
-
* // event.type === CalendarDateType.DAYS
|
|
7282
|
-
* ```
|
|
7283
|
-
*/ function calendarDate(day, days, timezone) {
|
|
7284
|
-
return calendarDateFactory({
|
|
7285
|
-
timezone: timezone
|
|
7286
|
-
})(day, days);
|
|
7287
|
-
}
|
|
7288
|
-
/**
|
|
7289
|
-
* Wraps an existing {@link DateDurationSpan} as a time-based {@link CalendarDate}.
|
|
7290
|
-
*
|
|
7291
|
-
* @param dateDurationSpan - the duration span to wrap
|
|
7292
|
-
* @returns a CalendarDate with type TIME
|
|
7293
|
-
*
|
|
7294
|
-
* @example
|
|
7295
|
-
* ```ts
|
|
7296
|
-
* const span: DateDurationSpan = { startsAt: new Date(), duration: 60 };
|
|
7297
|
-
* const event = calendarDateForDateDurationSpan(span);
|
|
7298
|
-
* // event.type === CalendarDateType.TIME
|
|
7299
|
-
* ```
|
|
7300
|
-
*/ function calendarDateForDateDurationSpan(dateDurationSpan) {
|
|
7301
|
-
return _object_spread$6({
|
|
7302
|
-
type: exports.CalendarDateType.TIME
|
|
7303
|
-
}, dateDurationSpan);
|
|
7304
|
-
}
|
|
7305
|
-
|
|
7306
7812
|
function _array_like_to_array$2(arr, len) {
|
|
7307
7813
|
if (len == null || len > arr.length) len = arr.length;
|
|
7308
7814
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -7342,7 +7848,7 @@ var _type, _type1;
|
|
|
7342
7848
|
* const result = knownTimezoneType('America/Denver');
|
|
7343
7849
|
* ```
|
|
7344
7850
|
*/ var knownTimezoneType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
7345
|
-
return
|
|
7851
|
+
return isKnownTimezone(val) || ctx.mustBe('a known timezone');
|
|
7346
7852
|
});
|
|
7347
7853
|
// MARK: DateDurationSpan
|
|
7348
7854
|
/**
|
|
@@ -7456,21 +7962,21 @@ var _type, _type1;
|
|
|
7456
7962
|
* Accepts both Date objects and date strings (parsed via `string.date.parse`), then validates the resulting timing
|
|
7457
7963
|
* using {@link isValidDateCellTiming}.
|
|
7458
7964
|
*/ var validDateCellTimingType = dateCellTimingType.narrow(function(val, ctx) {
|
|
7459
|
-
return
|
|
7965
|
+
return isValidDateCellTiming(val) || ctx.mustBe('a valid DateCellTiming');
|
|
7460
7966
|
});
|
|
7461
7967
|
/**
|
|
7462
7968
|
* ArkType DTO schema that validates a value is a valid {@link DateCellRange} (non-negative indexes, `to >= i`).
|
|
7463
7969
|
*
|
|
7464
7970
|
* Validates cell range data from JSON/DTO input.
|
|
7465
7971
|
*/ var validDateCellRangeType = dateCellRangeType.narrow(function(val, ctx) {
|
|
7466
|
-
return
|
|
7972
|
+
return isValidDateCellRange(val) || ctx.mustBe('a valid DateCellRange');
|
|
7467
7973
|
});
|
|
7468
7974
|
/**
|
|
7469
7975
|
* ArkType DTO schema that validates a value is a sorted array of non-overlapping {@link DateCellRange} values.
|
|
7470
7976
|
*
|
|
7471
7977
|
* Validates cell range series data from JSON/DTO input.
|
|
7472
7978
|
*/ var validDateCellRangeSeriesType = arktype.type(dateCellRangeType.array()).narrow(function(val, ctx) {
|
|
7473
|
-
return
|
|
7979
|
+
return isValidDateCellRangeSeries(val) || ctx.mustBe('a valid DateCellRange series with items sorted in ascending order and no repeat indexes');
|
|
7474
7980
|
});
|
|
7475
7981
|
|
|
7476
7982
|
function _assert_this_initialized$1(self) {
|
|
@@ -7750,7 +8256,7 @@ function _object_spread_props$4(target, source) {
|
|
|
7750
8256
|
logicalDate = 'now';
|
|
7751
8257
|
}
|
|
7752
8258
|
var intervalPeriod = period !== null && period !== void 0 ? period : util.MS_IN_SECOND;
|
|
7753
|
-
var factory = inputFactory ? inputFactory : util.protectedFactory(logicalDateStringCodeDateFactory(logicalDate));
|
|
8259
|
+
var factory = inputFactory !== null && inputFactory !== void 0 ? inputFactory : util.protectedFactory(logicalDateStringCodeDateFactory(logicalDate));
|
|
7754
8260
|
var obs = rxjs.interval(intervalPeriod, scheduler).pipe(rxjs.startWith(-1), rxjs.map(factory));
|
|
7755
8261
|
if (emitAll !== true) {
|
|
7756
8262
|
obs = obs.pipe(rxjs.distinctUntilChanged(isSameDate));
|
|
@@ -7842,7 +8348,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7842
8348
|
{
|
|
7843
8349
|
key: "instant",
|
|
7844
8350
|
get: function get() {
|
|
7845
|
-
|
|
8351
|
+
var _this__config_instant;
|
|
8352
|
+
return (_this__config_instant = this._config.instant) !== null && _this__config_instant !== void 0 ? _this__config_instant : 'now';
|
|
7846
8353
|
}
|
|
7847
8354
|
},
|
|
7848
8355
|
{
|
|
@@ -7887,10 +8394,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7887
8394
|
var _this__config = this._config, _this__config_instant = _this__config.instant, instant = _this__config_instant === void 0 ? new Date() : _this__config_instant, _this__config_limits = _this__config.limits, limits = _this__config_limits === void 0 ? {} : _this__config_limits;
|
|
7888
8395
|
var isPast = limits.isPast, max = limits.max;
|
|
7889
8396
|
var limit = max;
|
|
7890
|
-
if (typeof max !== 'string' && isPast) {
|
|
7891
|
-
|
|
7892
|
-
limit = util.DATE_NOW_VALUE;
|
|
7893
|
-
}
|
|
8397
|
+
if (typeof max !== 'string' && isPast && (!max || dateFns.isBefore(max, instant))) {
|
|
8398
|
+
limit = util.DATE_NOW_VALUE;
|
|
7894
8399
|
}
|
|
7895
8400
|
return limit;
|
|
7896
8401
|
}
|
|
@@ -7905,6 +8410,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7905
8410
|
* const limiter = new LimitDateTimeInstance({ limits: { isFuture: true } });
|
|
7906
8411
|
* const range = limiter.dateRange(); // { start: <now>, end: undefined }
|
|
7907
8412
|
* ```
|
|
8413
|
+
*
|
|
8414
|
+
* @returns A partial {@link DateRange} with `start` and/or `end` derived from the limits.
|
|
7908
8415
|
*/ key: "dateRange",
|
|
7909
8416
|
value: function dateRange() {
|
|
7910
8417
|
var _this__config = this._config, _this__config_instant = _this__config.instant, instant = _this__config_instant === void 0 ? new Date() : _this__config_instant;
|
|
@@ -7917,6 +8424,7 @@ function _define_property$6(obj, key, value) {
|
|
|
7917
8424
|
* like "now" or relative future offsets to resolve against the given moment.
|
|
7918
8425
|
*
|
|
7919
8426
|
* @param instant - The reference point in time for resolving dynamic limits.
|
|
8427
|
+
* @returns A partial {@link DateRange} resolved against the given instant.
|
|
7920
8428
|
*/ key: "dateRangeForInstant",
|
|
7921
8429
|
value: function dateRangeForInstant(instant) {
|
|
7922
8430
|
var _this = this, min = _this.min, max = _this.max;
|
|
@@ -7940,6 +8448,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7940
8448
|
* });
|
|
7941
8449
|
* const safe = limiter.clamp(new Date()); // at least 30 minutes from now
|
|
7942
8450
|
* ```
|
|
8451
|
+
*
|
|
8452
|
+
* @returns The clamped date within the allowed range.
|
|
7943
8453
|
*/ key: "clamp",
|
|
7944
8454
|
value: function clamp(date) {
|
|
7945
8455
|
var result = date;
|
|
@@ -7977,6 +8487,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7977
8487
|
* const clamped = limiter.clampDateRange({ start: pastDate, end: futureDate });
|
|
7978
8488
|
* // clamped.start will be at least now
|
|
7979
8489
|
* ```
|
|
8490
|
+
*
|
|
8491
|
+
* @returns The date range clamped to the allowed limits.
|
|
7980
8492
|
*/ key: "clampDateRange",
|
|
7981
8493
|
value: function clampDateRange(dateRange) {
|
|
7982
8494
|
return clampDateRangeToDateRange(dateRange, this.dateRange());
|
|
@@ -7998,6 +8510,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7998
8510
|
* });
|
|
7999
8511
|
* const clamped = limiter.clamp(someDate);
|
|
8000
8512
|
* ```
|
|
8513
|
+
*
|
|
8514
|
+
* @returns A new {@link LimitDateTimeInstance}.
|
|
8001
8515
|
*/ function limitDateTimeInstance(config) {
|
|
8002
8516
|
return new LimitDateTimeInstance(config);
|
|
8003
8517
|
}
|
|
@@ -8089,14 +8603,14 @@ function _object_spread_props$3(target, source) {
|
|
|
8089
8603
|
function DateTimeMinuteInstance() {
|
|
8090
8604
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, dateOverride = arguments.length > 1 ? arguments[1] : void 0;
|
|
8091
8605
|
_class_call_check$5(this, DateTimeMinuteInstance);
|
|
8092
|
-
var _config_step;
|
|
8606
|
+
var _ref, _config_step;
|
|
8093
8607
|
_define_property$5(this, "_config", void 0);
|
|
8094
8608
|
_define_property$5(this, "_date", void 0);
|
|
8095
8609
|
_define_property$5(this, "_step", void 0);
|
|
8096
8610
|
_define_property$5(this, "_limit", void 0);
|
|
8097
8611
|
_define_property$5(this, "_dateFilter", void 0);
|
|
8098
8612
|
this._config = config;
|
|
8099
|
-
this._date = (dateOverride
|
|
8613
|
+
this._date = (_ref = dateOverride !== null && dateOverride !== void 0 ? dateOverride : config.date) !== null && _ref !== void 0 ? _ref : new Date();
|
|
8100
8614
|
this._step = (_config_step = config.step) !== null && _config_step !== void 0 ? _config_step : 1;
|
|
8101
8615
|
this._limit = new LimitDateTimeInstance(config);
|
|
8102
8616
|
this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
|
|
@@ -8130,6 +8644,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8130
8644
|
key: "limitInstance",
|
|
8131
8645
|
get: /**
|
|
8132
8646
|
* Returns the LimitDateTimeInstance. This does not take the schedule into consideration.
|
|
8647
|
+
*
|
|
8648
|
+
* @returns The underlying {@link LimitDateTimeInstance}.
|
|
8133
8649
|
*/ function get() {
|
|
8134
8650
|
return this._limit;
|
|
8135
8651
|
}
|
|
@@ -8152,6 +8668,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8152
8668
|
* // true if June 15 is a weekday and overlaps the limit range
|
|
8153
8669
|
* instance.dateDayContainsValidDateValue(new Date('2024-06-15'));
|
|
8154
8670
|
* ```
|
|
8671
|
+
*
|
|
8672
|
+
* @returns `true` if the day contains at least one valid date/time value.
|
|
8155
8673
|
*/ key: "dateDayContainsValidDateValue",
|
|
8156
8674
|
value: function dateDayContainsValidDateValue(date) {
|
|
8157
8675
|
var isInSchedule = this.dateIsInSchedule(date);
|
|
@@ -8190,6 +8708,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8190
8708
|
*
|
|
8191
8709
|
* instance.isInValidRange(new Date('2024-06-15T10:00:00')); // true if a weekday
|
|
8192
8710
|
* ```
|
|
8711
|
+
*
|
|
8712
|
+
* @returns `true` if the date is within the min/max limits and on a scheduled day.
|
|
8193
8713
|
*/ key: "isInValidRange",
|
|
8194
8714
|
value: function isInValidRange(date) {
|
|
8195
8715
|
var result = this.getStatus(date);
|
|
@@ -8212,6 +8732,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8212
8732
|
*
|
|
8213
8733
|
* instance.isValid(new Date('2099-03-15T10:00:00')); // true if all constraints pass
|
|
8214
8734
|
* ```
|
|
8735
|
+
*
|
|
8736
|
+
* @returns `true` if the date passes all configured constraints.
|
|
8215
8737
|
*/ key: "isValid",
|
|
8216
8738
|
value: function isValid(date) {
|
|
8217
8739
|
var result = this.getStatus(date);
|
|
@@ -8235,6 +8757,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8235
8757
|
* // status.isAfterMinimum === false (before min)
|
|
8236
8758
|
* // status.inFuture === false (if date is in the past)
|
|
8237
8759
|
* ```
|
|
8760
|
+
*
|
|
8761
|
+
* @returns A {@link DateTimeMinuteDateStatus} snapshot for the given date.
|
|
8238
8762
|
*/ key: "getStatus",
|
|
8239
8763
|
value: function getStatus() {
|
|
8240
8764
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date;
|
|
@@ -8293,6 +8817,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8293
8817
|
*
|
|
8294
8818
|
* instance.dateIsInSchedule(new Date('2024-06-15')); // true (Saturday = false)
|
|
8295
8819
|
* ```
|
|
8820
|
+
*
|
|
8821
|
+
* @returns `true` if the date is on a scheduled day or no schedule is configured.
|
|
8296
8822
|
*/ key: "dateIsInSchedule",
|
|
8297
8823
|
value: function dateIsInSchedule() {
|
|
8298
8824
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date;
|
|
@@ -8317,6 +8843,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8317
8843
|
* instance.round({ roundToSteps: true }); // 2024-06-15T09:00:00
|
|
8318
8844
|
* instance.round({ roundToSteps: true, roundToBound: true }); // clamped to min if below
|
|
8319
8845
|
* ```
|
|
8846
|
+
*
|
|
8847
|
+
* @returns The rounded (and optionally clamped) date.
|
|
8320
8848
|
*/ key: "round",
|
|
8321
8849
|
value: function round(round) {
|
|
8322
8850
|
var _round_step;
|
|
@@ -8346,6 +8874,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8346
8874
|
*
|
|
8347
8875
|
* instance.clamp(new Date('2024-05-25')); // clamped to min, then nearest weekday
|
|
8348
8876
|
* ```
|
|
8877
|
+
*
|
|
8878
|
+
* @returns The date clamped to both the limits and the schedule.
|
|
8349
8879
|
*/ key: "clamp",
|
|
8350
8880
|
value: function clamp() {
|
|
8351
8881
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date, maxClampDistance = arguments.length > 1 ? arguments[1] : void 0;
|
|
@@ -8366,6 +8896,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8366
8896
|
*
|
|
8367
8897
|
* instance.clampToLimit(new Date('2025-03-01')); // returns max (2024-12-31)
|
|
8368
8898
|
* ```
|
|
8899
|
+
*
|
|
8900
|
+
* @returns The date clamped to the configured min/max limits.
|
|
8369
8901
|
*/ key: "clampToLimit",
|
|
8370
8902
|
value: function clampToLimit() {
|
|
8371
8903
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date;
|
|
@@ -8390,7 +8922,10 @@ function _object_spread_props$3(target, source) {
|
|
|
8390
8922
|
* // If June 15, 2024 is a Saturday, returns the next Monday
|
|
8391
8923
|
* instance.clampToSchedule(new Date('2024-06-15'));
|
|
8392
8924
|
* ```
|
|
8393
|
-
|
|
8925
|
+
*
|
|
8926
|
+
* @returns The nearest valid scheduled date, or the input date if already valid or no schedule is configured.
|
|
8927
|
+
*/ // eslint-disable-next-line sonarjs/cognitive-complexity
|
|
8928
|
+
key: "clampToSchedule",
|
|
8394
8929
|
value: function clampToSchedule() {
|
|
8395
8930
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date, maxClampDistance = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 370;
|
|
8396
8931
|
var nextAvailableDate;
|
|
@@ -8424,9 +8959,7 @@ function _object_spread_props$3(target, source) {
|
|
|
8424
8959
|
}
|
|
8425
8960
|
}
|
|
8426
8961
|
// set a default from the given input if applicable
|
|
8427
|
-
|
|
8428
|
-
nextAvailableDate = this.clampToLimit(date);
|
|
8429
|
-
}
|
|
8962
|
+
nextAvailableDate !== null && nextAvailableDate !== void 0 ? nextAvailableDate : nextAvailableDate = this.clampToLimit(date);
|
|
8430
8963
|
}
|
|
8431
8964
|
}
|
|
8432
8965
|
return nextAvailableDate !== null && nextAvailableDate !== void 0 ? nextAvailableDate : date;
|
|
@@ -8451,6 +8984,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8451
8984
|
* // Find the next weekday after a Saturday
|
|
8452
8985
|
* instance.findNextAvailableDayInSchedule(new Date('2024-06-15'), 'future');
|
|
8453
8986
|
* ```
|
|
8987
|
+
*
|
|
8988
|
+
* @returns The next valid schedule date, or `undefined` if none found within the max distance.
|
|
8454
8989
|
*/ key: "findNextAvailableDayInSchedule",
|
|
8455
8990
|
value: function findNextAvailableDayInSchedule(date, direction) {
|
|
8456
8991
|
var maxDistance = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 370;
|
|
@@ -8486,6 +9021,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8486
9021
|
* instance.isInSchedule(new Date('2024-06-17')); // true (Monday)
|
|
8487
9022
|
* instance.isInSchedule(new Date('2024-06-16')); // false (Sunday)
|
|
8488
9023
|
* ```
|
|
9024
|
+
*
|
|
9025
|
+
* @returns `true` if the date is on a scheduled day or no schedule is configured.
|
|
8489
9026
|
*/ key: "isInSchedule",
|
|
8490
9027
|
value: function isInSchedule(date) {
|
|
8491
9028
|
return this._dateFilter ? this._dateFilter(date) : true;
|
|
@@ -8545,6 +9082,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8545
9082
|
*
|
|
8546
9083
|
* isValid(new Date('2024-06-17T10:00:00')); // true if future weekday after min
|
|
8547
9084
|
* ```
|
|
9085
|
+
*
|
|
9086
|
+
* @returns A decision function that returns `true` for valid dates.
|
|
8548
9087
|
*/ function dateTimeMinuteDecisionFunction(config) {
|
|
8549
9088
|
var instance = new DateTimeMinuteInstance(config, null);
|
|
8550
9089
|
return function(date) {
|
|
@@ -8577,6 +9116,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8577
9116
|
* // true only if both 00:00 and 23:59 on June 15 pass all constraints
|
|
8578
9117
|
* isFullDayValid(new Date('2024-06-15'));
|
|
8579
9118
|
* ```
|
|
9119
|
+
*
|
|
9120
|
+
* @returns A decision function that returns `true` for valid days.
|
|
8580
9121
|
*/ function dateTimeMinuteWholeDayDecisionFunction(config) {
|
|
8581
9122
|
var startAndEndOfDayMustBeValid = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
8582
9123
|
var instance = new DateTimeMinuteInstance(config, null);
|
|
@@ -8661,6 +9202,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8661
9202
|
* guaranteeing that `raw` and `result` are defined.
|
|
8662
9203
|
*
|
|
8663
9204
|
* @param result - The parse result to check.
|
|
9205
|
+
* @returns `true` if the result is valid, narrowing the type to {@link ValidDateFromTimestringResult}.
|
|
8664
9206
|
*
|
|
8665
9207
|
* @example
|
|
8666
9208
|
* ```ts
|
|
@@ -8704,6 +9246,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8704
9246
|
*
|
|
8705
9247
|
* @param date - The date to check. Defaults to now.
|
|
8706
9248
|
* @param timezone - Overrides the instance's configured timezone for this call.
|
|
9249
|
+
* @returns {@link TimeAM.AM} or {@link TimeAM.PM} depending on the time of day.
|
|
8707
9250
|
*
|
|
8708
9251
|
* @example
|
|
8709
9252
|
* ```ts
|
|
@@ -8723,6 +9266,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8723
9266
|
*
|
|
8724
9267
|
* @param date - The date to format.
|
|
8725
9268
|
* @param timezone - Overrides the instance's configured timezone for this call.
|
|
9269
|
+
* @returns The formatted time string (e.g., "1:30PM").
|
|
8726
9270
|
*
|
|
8727
9271
|
* @example
|
|
8728
9272
|
* ```ts
|
|
@@ -8755,20 +9299,20 @@ function _object_spread_props$2(target, source) {
|
|
|
8755
9299
|
*/ key: "parseTimeString",
|
|
8756
9300
|
value: function parseTimeString(input, config) {
|
|
8757
9301
|
var timestringResult = this._timeStringToDate(input, config);
|
|
9302
|
+
var result;
|
|
8758
9303
|
if (isValidDateFromTimestringResult(timestringResult)) {
|
|
8759
|
-
var
|
|
9304
|
+
var dateResult = timestringResult.result, raw = timestringResult.raw;
|
|
8760
9305
|
// Use minutes since start of day. Since differenceInMinutes uses system time, we convert the raw to system time first.
|
|
8761
9306
|
var inSystemTime = systemNormalDateToBaseDate(raw);
|
|
8762
9307
|
var minutesSinceStartOfDay = dateFns.differenceInMinutes(inSystemTime, dateFns.startOfDay(inSystemTime));
|
|
8763
|
-
|
|
9308
|
+
result = {
|
|
8764
9309
|
utc: raw,
|
|
8765
|
-
date:
|
|
9310
|
+
date: dateResult,
|
|
8766
9311
|
minutesSinceStartOfDay: minutesSinceStartOfDay,
|
|
8767
9312
|
am: minutesSinceStartOfDay < 720 ? util.TimeAM.AM : util.TimeAM.PM
|
|
8768
9313
|
};
|
|
8769
|
-
} else {
|
|
8770
|
-
return undefined;
|
|
8771
9314
|
}
|
|
9315
|
+
return result;
|
|
8772
9316
|
}
|
|
8773
9317
|
},
|
|
8774
9318
|
{
|
|
@@ -8791,11 +9335,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8791
9335
|
*/ key: "timeStringToDate",
|
|
8792
9336
|
value: function timeStringToDate(input, config) {
|
|
8793
9337
|
var _this__timeStringToDate = this._timeStringToDate(input, config), result = _this__timeStringToDate.result, valid = _this__timeStringToDate.valid;
|
|
8794
|
-
|
|
8795
|
-
return result;
|
|
8796
|
-
} else {
|
|
8797
|
-
return undefined;
|
|
8798
|
-
}
|
|
9338
|
+
return valid ? result : undefined;
|
|
8799
9339
|
}
|
|
8800
9340
|
},
|
|
8801
9341
|
{
|
|
@@ -8821,18 +9361,35 @@ function _object_spread_props$2(target, source) {
|
|
|
8821
9361
|
'h:mm',
|
|
8822
9362
|
'HH:mm' // 01:20
|
|
8823
9363
|
];
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
9364
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
9365
|
+
try {
|
|
9366
|
+
// tslint:disable-next-line: prefer-for-of
|
|
9367
|
+
for(var _iterator = formats[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
9368
|
+
var format = _step.value;
|
|
9369
|
+
systemParsedDateTime = dateFns.parse(input, format, relativeDate);
|
|
9370
|
+
if (dateFns.isValid(systemParsedDateTime)) {
|
|
9371
|
+
valid = true;
|
|
9372
|
+
break; // Use time.
|
|
9373
|
+
}
|
|
9374
|
+
}
|
|
9375
|
+
} catch (err) {
|
|
9376
|
+
_didIteratorError = true;
|
|
9377
|
+
_iteratorError = err;
|
|
9378
|
+
} finally{
|
|
9379
|
+
try {
|
|
9380
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
9381
|
+
_iterator.return();
|
|
9382
|
+
}
|
|
9383
|
+
} finally{
|
|
9384
|
+
if (_didIteratorError) {
|
|
9385
|
+
throw _iteratorError;
|
|
9386
|
+
}
|
|
8830
9387
|
}
|
|
8831
9388
|
}
|
|
8832
9389
|
var removedPm = false;
|
|
8833
9390
|
function removeAmPm(inputString) {
|
|
8834
9391
|
inputString = inputString.toLowerCase();
|
|
8835
|
-
removedPm = inputString.
|
|
9392
|
+
removedPm = inputString.includes('pm');
|
|
8836
9393
|
inputString = inputString.replace(/am|pm/g, '');
|
|
8837
9394
|
return inputString;
|
|
8838
9395
|
}
|
|
@@ -8864,6 +9421,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8864
9421
|
case 6:
|
|
8865
9422
|
// 1212AM
|
|
8866
9423
|
removeAmPm(input);
|
|
9424
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- removedPm is set via closure side effect in removeAmPm()
|
|
8867
9425
|
if (removedPm) {
|
|
8868
9426
|
removedPm = input[0] !== '2'; // If 2, ignore the PM part.
|
|
8869
9427
|
}
|
|
@@ -8932,6 +9490,8 @@ function _object_spread_props$2(target, source) {
|
|
|
8932
9490
|
/**
|
|
8933
9491
|
* Creates a {@link DateTimeUtilityInstance} configured for UTC.
|
|
8934
9492
|
*
|
|
9493
|
+
* @returns A new {@link DateTimeUtilityInstance} using the UTC timezone.
|
|
9494
|
+
*
|
|
8935
9495
|
* @example
|
|
8936
9496
|
* ```ts
|
|
8937
9497
|
* const utcInstance = dateTimeInstanceUtc();
|
|
@@ -8945,6 +9505,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8945
9505
|
* Defaults to UTC when no timezone is provided.
|
|
8946
9506
|
*
|
|
8947
9507
|
* @param timezone - The IANA timezone identifier (e.g., 'America/New_York').
|
|
9508
|
+
* @returns A new {@link DateTimeUtilityInstance} for the specified timezone.
|
|
8948
9509
|
*
|
|
8949
9510
|
* @example
|
|
8950
9511
|
* ```ts
|
|
@@ -8959,6 +9520,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8959
9520
|
*
|
|
8960
9521
|
* @param date - The date to check. Defaults to now.
|
|
8961
9522
|
* @param timezone - The IANA timezone to evaluate in. Defaults to UTC.
|
|
9523
|
+
* @returns {@link TimeAM.AM} or {@link TimeAM.PM} depending on the time of day.
|
|
8962
9524
|
*
|
|
8963
9525
|
* @example
|
|
8964
9526
|
* ```ts
|
|
@@ -8976,6 +9538,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8976
9538
|
* unlike {@link toReadableTimeString} which defaults to UTC.
|
|
8977
9539
|
*
|
|
8978
9540
|
* @param date - The date to format.
|
|
9541
|
+
* @returns The formatted time string in the system's local timezone.
|
|
8979
9542
|
*
|
|
8980
9543
|
* @example
|
|
8981
9544
|
* ```ts
|
|
@@ -8989,6 +9552,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8989
9552
|
*
|
|
8990
9553
|
* @param date - The date to format.
|
|
8991
9554
|
* @param timezone - The IANA timezone to format in. Defaults to UTC.
|
|
9555
|
+
* @returns The formatted time string (e.g., "10:30AM").
|
|
8992
9556
|
*
|
|
8993
9557
|
* @example
|
|
8994
9558
|
* ```ts
|
|
@@ -9004,6 +9568,7 @@ function _object_spread_props$2(target, source) {
|
|
|
9004
9568
|
*
|
|
9005
9569
|
* @param input - A time string such as "1:30PM", "13:30", or "1PM".
|
|
9006
9570
|
* @param config - Optional configuration specifying the timezone and reference date.
|
|
9571
|
+
* @returns The parsed time string result, or `undefined` if parsing failed.
|
|
9007
9572
|
*
|
|
9008
9573
|
* @example
|
|
9009
9574
|
* ```ts
|
|
@@ -9022,6 +9587,7 @@ function _object_spread_props$2(target, source) {
|
|
|
9022
9587
|
*
|
|
9023
9588
|
* @param input - A time string such as "1:30PM" or "13:30".
|
|
9024
9589
|
* @param config - Optional configuration specifying the timezone and reference date.
|
|
9590
|
+
* @returns The resolved date, or `undefined` if the input could not be parsed.
|
|
9025
9591
|
*
|
|
9026
9592
|
* @example
|
|
9027
9593
|
* ```ts
|
|
@@ -9035,6 +9601,7 @@ function _object_spread_props$2(target, source) {
|
|
|
9035
9601
|
* Creates a {@link LimitDateTimeInstance} for clamping and constraining dates to a configured range.
|
|
9036
9602
|
*
|
|
9037
9603
|
* @param config - The limit configuration specifying min/max bounds, future requirements, etc.
|
|
9604
|
+
* @returns A new {@link LimitDateTimeInstance} configured with the given bounds.
|
|
9038
9605
|
*
|
|
9039
9606
|
* @example
|
|
9040
9607
|
* ```ts
|
|
@@ -9144,6 +9711,7 @@ function _object_spread_props$1(target, source) {
|
|
|
9144
9711
|
date: dateFnsTz.toZonedTime(find.range.date, find.timezone)
|
|
9145
9712
|
}) : find.range;
|
|
9146
9713
|
var dates = dateRange(range);
|
|
9714
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
9147
9715
|
switch(range.type){
|
|
9148
9716
|
case exports.DateRangeType.DAY:
|
|
9149
9717
|
case exports.DateRangeType.WEEK:
|
|
@@ -9339,13 +9907,12 @@ function _object_spread$1(target) {
|
|
|
9339
9907
|
// A single field that manages start/end will start and end at the same instant (end = start)
|
|
9340
9908
|
// so we merge the gte/lte values.
|
|
9341
9909
|
var merged = mergeMongoDBLikeRangeFilters(startsAt, endsAt);
|
|
9342
|
-
startsAtFilter =
|
|
9910
|
+
startsAtFilter = _define_property$2({}, fields.start, merged);
|
|
9343
9911
|
} else {
|
|
9344
9912
|
startsAtFilter = startsAt ? _define_property$2({}, fields.start, startsAt) : undefined;
|
|
9345
9913
|
endsAtFilter = endsAt && fields.end ? _define_property$2({}, fields.end, endsAt) : undefined;
|
|
9346
9914
|
}
|
|
9347
|
-
|
|
9348
|
-
return filter;
|
|
9915
|
+
return _object_spread$1({}, startsAtFilter, endsAtFilter);
|
|
9349
9916
|
}
|
|
9350
9917
|
};
|
|
9351
9918
|
}
|
|
@@ -9468,6 +10035,8 @@ function _is_native_reflect_construct() {
|
|
|
9468
10035
|
* const rule = new DateRRule({ freq: RRule.DAILY, count: 5, dtstart: startDate });
|
|
9469
10036
|
* const lastDate = rule.last(); // fifth occurrence
|
|
9470
10037
|
* ```
|
|
10038
|
+
*
|
|
10039
|
+
* @returns The last occurrence date, or `undefined` if there are none.
|
|
9471
10040
|
*/ key: "last",
|
|
9472
10041
|
value: function last() {
|
|
9473
10042
|
return this._iter(new LastIterResult());
|
|
@@ -9482,6 +10051,9 @@ function _is_native_reflect_construct() {
|
|
|
9482
10051
|
* const rule = new DateRRule({ freq: RRule.WEEKLY, dtstart: startDate });
|
|
9483
10052
|
* const nextDate = rule.next(new Date());
|
|
9484
10053
|
* ```
|
|
10054
|
+
*
|
|
10055
|
+
* @param minDate - The earliest date to consider.
|
|
10056
|
+
* @returns The first occurrence on or after `minDate`, or `undefined` if none.
|
|
9485
10057
|
*/ key: "next",
|
|
9486
10058
|
value: function next(minDate) {
|
|
9487
10059
|
return this._iter(new NextIterResult(minDate));
|
|
@@ -9496,6 +10068,11 @@ function _is_native_reflect_construct() {
|
|
|
9496
10068
|
* const rule = new DateRRule({ freq: RRule.DAILY, dtstart: startDate });
|
|
9497
10069
|
* const exists = rule.any({ minDate: rangeStart, maxDate: rangeEnd });
|
|
9498
10070
|
* ```
|
|
10071
|
+
*
|
|
10072
|
+
* @param filter - Optional date bounds with `minDate` and `maxDate`.
|
|
10073
|
+
* @param filter.minDate - Optional minimum date bound.
|
|
10074
|
+
* @param filter.maxDate - Optional maximum date bound.
|
|
10075
|
+
* @returns `true` if at least one recurrence falls within the bounds.
|
|
9499
10076
|
*/ key: "any",
|
|
9500
10077
|
value: function any() {
|
|
9501
10078
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -9553,13 +10130,15 @@ function _is_native_reflect_construct() {
|
|
|
9553
10130
|
value: function accept(date) {
|
|
9554
10131
|
++this.total;
|
|
9555
10132
|
var tooLate = date > this.maxDate;
|
|
10133
|
+
var result;
|
|
9556
10134
|
if (tooLate) {
|
|
9557
|
-
|
|
10135
|
+
result = false;
|
|
9558
10136
|
} else {
|
|
9559
10137
|
this.add(date);
|
|
9560
10138
|
var maxIterationReached = this.total >= this._maxIterationsAllowed;
|
|
9561
|
-
|
|
10139
|
+
result = !maxIterationReached;
|
|
9562
10140
|
}
|
|
10141
|
+
return result;
|
|
9563
10142
|
}
|
|
9564
10143
|
},
|
|
9565
10144
|
{
|
|
@@ -9599,13 +10178,15 @@ function _is_native_reflect_construct() {
|
|
|
9599
10178
|
value: function accept(date) {
|
|
9600
10179
|
this.total += 1;
|
|
9601
10180
|
var tooEarly = this.minDate > date;
|
|
10181
|
+
var result;
|
|
9602
10182
|
if (tooEarly) {
|
|
9603
10183
|
var maxIterationReached = this.total >= this.maxIterationsAllowed;
|
|
9604
|
-
|
|
10184
|
+
result = !maxIterationReached;
|
|
9605
10185
|
} else {
|
|
9606
10186
|
this.add(date);
|
|
9607
|
-
|
|
10187
|
+
result = false;
|
|
9608
10188
|
}
|
|
10189
|
+
return result;
|
|
9609
10190
|
}
|
|
9610
10191
|
},
|
|
9611
10192
|
{
|
|
@@ -9648,18 +10229,20 @@ function _is_native_reflect_construct() {
|
|
|
9648
10229
|
value: function accept(date) {
|
|
9649
10230
|
++this.total;
|
|
9650
10231
|
var tooEarly = this.minDate != null && this.minDate > date;
|
|
10232
|
+
var result;
|
|
9651
10233
|
if (tooEarly) {
|
|
9652
10234
|
var maxIterationReached = this.total >= this.maxIterationsAllowed;
|
|
9653
|
-
|
|
10235
|
+
result = !maxIterationReached;
|
|
9654
10236
|
} else {
|
|
9655
10237
|
var tooLate = this.maxDate != null && this.maxDate < date;
|
|
9656
10238
|
if (tooLate) {
|
|
9657
|
-
|
|
10239
|
+
result = true;
|
|
9658
10240
|
} else {
|
|
9659
10241
|
this.add(date);
|
|
9660
|
-
|
|
10242
|
+
result = false;
|
|
9661
10243
|
}
|
|
9662
10244
|
}
|
|
10245
|
+
return result;
|
|
9663
10246
|
}
|
|
9664
10247
|
},
|
|
9665
10248
|
{
|
|
@@ -9749,7 +10332,11 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9749
10332
|
}
|
|
9750
10333
|
/**
|
|
9751
10334
|
* Delimiter separating the property name/params from values in an RRule line.
|
|
9752
|
-
*/ var
|
|
10335
|
+
*/ var RRULE_STRING_SPLITTER = ':';
|
|
10336
|
+
/**
|
|
10337
|
+
* @deprecated use RRULE_STRING_SPLITTER instead.
|
|
10338
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10339
|
+
var RRuleStringSplitter = RRULE_STRING_SPLITTER;
|
|
9753
10340
|
/**
|
|
9754
10341
|
* Utility class for parsing and manipulating RFC 5545 RRule strings.
|
|
9755
10342
|
*
|
|
@@ -9780,6 +10367,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9780
10367
|
* // result.basic = ['RRULE:FREQ=DAILY']
|
|
9781
10368
|
* // result.exdates contains the parsed exclusion dates
|
|
9782
10369
|
* ```
|
|
10370
|
+
*
|
|
10371
|
+
* @param input - The RRule string line set to separate.
|
|
10372
|
+
* @returns The separated basic rules and parsed EXDATE exclusion dates.
|
|
9783
10373
|
*/ function separateRRuleStringSetValues(input) {
|
|
9784
10374
|
var basic = [];
|
|
9785
10375
|
var exdateRules = [];
|
|
@@ -9809,6 +10399,8 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9809
10399
|
/**
|
|
9810
10400
|
* Parses an EXDATE line into its timezone and date components.
|
|
9811
10401
|
*
|
|
10402
|
+
* @param line - The raw EXDATE line string to parse.
|
|
10403
|
+
* @returns The parsed EXDATE attribute with timezone and dates.
|
|
9812
10404
|
* @throws Error if the line is not an EXDATE property.
|
|
9813
10405
|
*/ function parseExdateAttributeFromLine(line) {
|
|
9814
10406
|
var property = this.parseProperty(line);
|
|
@@ -9820,6 +10412,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9820
10412
|
key: "parseExdateAttributeFromProperty",
|
|
9821
10413
|
value: /**
|
|
9822
10414
|
* Extracts timezone and UTC-normalized dates from an already-parsed EXDATE property.
|
|
10415
|
+
*
|
|
10416
|
+
* @param property - The parsed EXDATE property to extract from.
|
|
10417
|
+
* @returns The EXDATE attribute containing timezone and UTC-normalized dates.
|
|
9823
10418
|
*/ function parseExdateAttributeFromProperty(property) {
|
|
9824
10419
|
var _property_params_find;
|
|
9825
10420
|
var timezone = (_property_params_find = property.params.find(function(x) {
|
|
@@ -9843,6 +10438,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9843
10438
|
value: /**
|
|
9844
10439
|
* Convenience wrapper that creates a timezone converter and delegates to {@link parseDateTimeString}.
|
|
9845
10440
|
*
|
|
10441
|
+
* @param rfcDateString - The RFC 5545 date or date-time string to parse.
|
|
10442
|
+
* @param timezone - Optional timezone for non-UTC date strings.
|
|
10443
|
+
* @returns The parsed JavaScript Date.
|
|
9846
10444
|
* @throws Error if the date string is not UTC and no timezone is provided.
|
|
9847
10445
|
*/ function parseDateTimeStringWithTimezone(rfcDateString, timezone) {
|
|
9848
10446
|
return DateRRuleParseUtility.parseDateTimeString(rfcDateString, timezone ? new DateTimezoneUtcNormalInstance({
|
|
@@ -9858,6 +10456,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9858
10456
|
* If the string does not end in `Z` (indicating UTC), the converter is used to normalize
|
|
9859
10457
|
* the local date representation to its true UTC equivalent.
|
|
9860
10458
|
*
|
|
10459
|
+
* @param rfcDateString - The RFC 5545 date or date-time string to parse.
|
|
10460
|
+
* @param converter - Optional timezone converter for non-UTC date strings.
|
|
10461
|
+
* @returns The parsed JavaScript Date.
|
|
9861
10462
|
* @throws Error if the string cannot be parsed or a non-UTC string lacks a converter.
|
|
9862
10463
|
*/ function parseDateTimeString(rfcDateString, converter) {
|
|
9863
10464
|
var RFC5545_DATE_TIME_FORMAT = /^((\d{4})(\d{2})(\d{2}))(T(\d{2})(\d{2})(\d{2})Z?)?$/;
|
|
@@ -9901,6 +10502,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9901
10502
|
* DateRRuleParseUtility.formatDateTimeString(new Date('2021-06-11T11:00:00Z'));
|
|
9902
10503
|
* // => '20210611T110000Z'
|
|
9903
10504
|
* ```
|
|
10505
|
+
*
|
|
10506
|
+
* @param date - The date to format.
|
|
10507
|
+
* @returns The RFC 5545 UTC date-time string representation.
|
|
9904
10508
|
*/ function formatDateTimeString(date) {
|
|
9905
10509
|
return dateFnsTz.format(date, "yyyyMMdd'T'HHmmss'Z'");
|
|
9906
10510
|
}
|
|
@@ -9909,6 +10513,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9909
10513
|
key: "parseProperty",
|
|
9910
10514
|
value: /**
|
|
9911
10515
|
* Parses a full RRule line string into a structured {@link RRuleProperty}.
|
|
10516
|
+
*
|
|
10517
|
+
* @param line - The raw RRule line string to parse.
|
|
10518
|
+
* @returns The structured property with type, params, and values.
|
|
9912
10519
|
*/ function parseProperty(line) {
|
|
9913
10520
|
var rawLine = DateRRuleParseUtility.parseRawLine(line);
|
|
9914
10521
|
return DateRRuleParseUtility.propertyFromRawLine(rawLine);
|
|
@@ -9918,6 +10525,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9918
10525
|
key: "propertyFromRawLine",
|
|
9919
10526
|
value: /**
|
|
9920
10527
|
* Converts an {@link RRuleRawLine} into a structured {@link RRuleProperty} by splitting the type and params.
|
|
10528
|
+
*
|
|
10529
|
+
* @param rawLine - The raw line to convert.
|
|
10530
|
+
* @returns The structured property with separated type, params, and values.
|
|
9921
10531
|
*/ function propertyFromRawLine(rawLine) {
|
|
9922
10532
|
var typeAndParams = rawLine.params.split(';');
|
|
9923
10533
|
var type = typeAndParams[0].toUpperCase();
|
|
@@ -9933,6 +10543,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9933
10543
|
key: "parseRawParam",
|
|
9934
10544
|
value: /**
|
|
9935
10545
|
* Splits a raw param string (e.g., `"TZID=America/New_York"`) into key-value form.
|
|
10546
|
+
*
|
|
10547
|
+
* @param param - The raw param string to split.
|
|
10548
|
+
* @returns The parsed key-value param.
|
|
9936
10549
|
*/ function parseRawParam(param) {
|
|
9937
10550
|
var _splitJoinRemainder = _sliced_to_array$1(util.splitJoinRemainder(param, '=', 2), 2), key = _splitJoinRemainder[0], value = _splitJoinRemainder[1];
|
|
9938
10551
|
return {
|
|
@@ -9946,19 +10559,24 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9946
10559
|
value: /**
|
|
9947
10560
|
* Splits a raw line at the colon delimiter into params and values portions.
|
|
9948
10561
|
* Falls back to treating a single-segment line as an RRULE value.
|
|
10562
|
+
*
|
|
10563
|
+
* @param line - The raw RRule line string to split.
|
|
10564
|
+
* @returns The raw line with separated params and values.
|
|
9949
10565
|
*/ function parseRawLine(line) {
|
|
9950
|
-
var _splitJoinRemainder = _sliced_to_array$1(util.splitJoinRemainder(line,
|
|
10566
|
+
var _splitJoinRemainder = _sliced_to_array$1(util.splitJoinRemainder(line, RRULE_STRING_SPLITTER, 2), 2), params = _splitJoinRemainder[0], values = _splitJoinRemainder[1];
|
|
10567
|
+
var result;
|
|
9951
10568
|
if (line.length === 1) {
|
|
9952
|
-
|
|
10569
|
+
result = {
|
|
9953
10570
|
params: 'RRULE',
|
|
9954
10571
|
values: params
|
|
9955
10572
|
};
|
|
9956
10573
|
} else {
|
|
9957
|
-
|
|
10574
|
+
result = {
|
|
9958
10575
|
params: params,
|
|
9959
10576
|
values: values
|
|
9960
10577
|
};
|
|
9961
10578
|
}
|
|
10579
|
+
return result;
|
|
9962
10580
|
}
|
|
9963
10581
|
},
|
|
9964
10582
|
{
|
|
@@ -9966,6 +10584,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9966
10584
|
value: // MARK: String
|
|
9967
10585
|
/**
|
|
9968
10586
|
* Splits a newline-delimited RRule string into individual line strings.
|
|
10587
|
+
*
|
|
10588
|
+
* @param lines - The newline-delimited RRule string to split.
|
|
10589
|
+
* @returns An array of individual RRule line strings.
|
|
9969
10590
|
*/ function toRRuleStringSet(lines) {
|
|
9970
10591
|
return lines.split('\n');
|
|
9971
10592
|
}
|
|
@@ -9974,6 +10595,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9974
10595
|
key: "toRRuleLines",
|
|
9975
10596
|
value: /**
|
|
9976
10597
|
* Joins an array of RRule line strings into a single newline-delimited string.
|
|
10598
|
+
*
|
|
10599
|
+
* @param rruleStringSet - The array of RRule line strings to join.
|
|
10600
|
+
* @returns A single newline-delimited RRule string.
|
|
9977
10601
|
*/ function toRRuleLines(rruleStringSet) {
|
|
9978
10602
|
return rruleStringSet.join('\n');
|
|
9979
10603
|
}
|
|
@@ -9984,6 +10608,8 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9984
10608
|
/**
|
|
9985
10609
|
* Asserts that the property has the expected type, throwing if it does not match.
|
|
9986
10610
|
*
|
|
10611
|
+
* @param type - The expected property type.
|
|
10612
|
+
* @param property - The property to check.
|
|
9987
10613
|
* @throws Error if the property type does not match the expected type.
|
|
9988
10614
|
*/ function assertPropertyType(type, property) {
|
|
9989
10615
|
if (property.type !== type) {
|
|
@@ -10124,7 +10750,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
10124
10750
|
this.options = options;
|
|
10125
10751
|
var tzid = rrule.origOptions.tzid;
|
|
10126
10752
|
var dtstart = rrule.origOptions.dtstart;
|
|
10127
|
-
var timezone = tzid
|
|
10753
|
+
var timezone = tzid !== null && tzid !== void 0 ? tzid : options.timezone;
|
|
10128
10754
|
/**
|
|
10129
10755
|
* The normal instance for DateRRuleInstance is used backwards in most cases because DateRRule always
|
|
10130
10756
|
* parses dates as UTC, so we handle all input dates as base dates, an
|
|
@@ -10175,8 +10801,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
10175
10801
|
var from = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
10176
10802
|
var baseFrom = this.normalInstance.baseDateToTargetDate(from);
|
|
10177
10803
|
var rawNext = this.rrule.next(baseFrom);
|
|
10178
|
-
|
|
10179
|
-
return next;
|
|
10804
|
+
return rawNext ? this.normalInstance.targetDateToBaseDate(rawNext) : undefined;
|
|
10180
10805
|
}
|
|
10181
10806
|
},
|
|
10182
10807
|
{
|
|
@@ -10317,11 +10942,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
10317
10942
|
/**
|
|
10318
10943
|
* Returns `true` when the underlying RRule has neither a `count` nor an
|
|
10319
10944
|
* `until` constraint, meaning it recurs indefinitely.
|
|
10945
|
+
*
|
|
10946
|
+
* @returns `true` if the rule recurs indefinitely.
|
|
10320
10947
|
*/ key: "hasForeverRange",
|
|
10321
10948
|
value: function hasForeverRange() {
|
|
10322
10949
|
var options = this.rrule.options;
|
|
10323
|
-
|
|
10324
|
-
return forever;
|
|
10950
|
+
return !options.count && !options.until;
|
|
10325
10951
|
}
|
|
10326
10952
|
}
|
|
10327
10953
|
], [
|
|
@@ -10555,6 +11181,9 @@ Object.defineProperty(exports, "unixDateTimeSecondsNumberToDate", {
|
|
|
10555
11181
|
});
|
|
10556
11182
|
exports.AnyIterResult = AnyIterResult;
|
|
10557
11183
|
exports.DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX;
|
|
11184
|
+
exports.DATE_MONTH_DAY_STRING_FORMAT = DATE_MONTH_DAY_STRING_FORMAT;
|
|
11185
|
+
exports.DATE_SHORT_DATE_AND_TIME_STRING_FORMAT = DATE_SHORT_DATE_AND_TIME_STRING_FORMAT;
|
|
11186
|
+
exports.DATE_TIME_STRING_FORMAT = DATE_TIME_STRING_FORMAT;
|
|
10558
11187
|
exports.DATE_TODAY_END_VALUE = DATE_TODAY_END_VALUE;
|
|
10559
11188
|
exports.DATE_TODAY_START_VALUE = DATE_TODAY_START_VALUE;
|
|
10560
11189
|
exports.DATE_WEEK_END_VALUE = DATE_WEEK_END_VALUE;
|
|
@@ -10575,8 +11204,10 @@ exports.IterateDaysInDateRangeFunctionBailError = IterateDaysInDateRangeFunction
|
|
|
10575
11204
|
exports.LastIterResult = LastIterResult;
|
|
10576
11205
|
exports.LimitDateTimeInstance = LimitDateTimeInstance;
|
|
10577
11206
|
exports.MAX_FUTURE_DATE = MAX_FUTURE_DATE;
|
|
11207
|
+
exports.MONTH_DAY_SLASH_DATE_STRING_FORMAT = MONTH_DAY_SLASH_DATE_STRING_FORMAT;
|
|
10578
11208
|
exports.ModelRecurrenceInfoUtility = ModelRecurrenceInfoUtility;
|
|
10579
11209
|
exports.NextIterResult = NextIterResult;
|
|
11210
|
+
exports.RRULE_STRING_SPLITTER = RRULE_STRING_SPLITTER;
|
|
10580
11211
|
exports.RRuleStringSplitter = RRuleStringSplitter;
|
|
10581
11212
|
exports.SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE = SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE;
|
|
10582
11213
|
exports.UNKNOWN_YEAR_WEEK_CODE = UNKNOWN_YEAR_WEEK_CODE;
|