@dereekb/date 13.4.0 → 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 +916 -305
- package/index.esm.js +916 -305
- package/package.json +5 -5
- 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 +19 -0
- package/src/lib/date/date.format.d.ts +62 -8
- package/src/lib/date/date.range.d.ts +104 -1
- 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 +5 -0
- 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 +40 -1
- 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
|
*
|
|
@@ -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'));
|
|
@@ -1029,6 +1089,9 @@ exports.DateRangeType = void 0;
|
|
|
1029
1089
|
* Creates a {@link DateRange} from the given type and optional parameters. Supports many range
|
|
1030
1090
|
* strategies including fixed periods (day, week, month), directional ranges, and radii.
|
|
1031
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
|
|
1032
1095
|
* @throws Error if the type is not a recognized {@link DateRangeType}
|
|
1033
1096
|
*
|
|
1034
1097
|
* @example
|
|
@@ -1062,25 +1125,27 @@ exports.DateRangeType = void 0;
|
|
|
1062
1125
|
start = startOfFn(preStart);
|
|
1063
1126
|
end = endOfFn(preEnd);
|
|
1064
1127
|
}
|
|
1065
|
-
function calculateStartAndEndForBetween(
|
|
1066
|
-
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;
|
|
1067
1130
|
var preStart;
|
|
1068
1131
|
var preEnd;
|
|
1069
|
-
switch(
|
|
1132
|
+
switch(betweenDistance){
|
|
1070
1133
|
case 0:
|
|
1071
1134
|
preStart = date;
|
|
1072
1135
|
preEnd = date;
|
|
1073
1136
|
break;
|
|
1074
1137
|
default:
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
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;
|
|
1082
1148
|
}
|
|
1083
|
-
break;
|
|
1084
1149
|
}
|
|
1085
1150
|
start = startOfFn(preStart);
|
|
1086
1151
|
end = endOfFn(preEnd);
|
|
@@ -1102,19 +1167,44 @@ exports.DateRangeType = void 0;
|
|
|
1102
1167
|
calculateStartAndEndForDate(dateFns.startOfMinute, dateFns.endOfMinute);
|
|
1103
1168
|
break;
|
|
1104
1169
|
case exports.DateRangeType.MINUTES_RANGE:
|
|
1105
|
-
calculateStartAndEndForBetween(
|
|
1170
|
+
calculateStartAndEndForBetween({
|
|
1171
|
+
addFn: dateFns.addMinutes,
|
|
1172
|
+
distance: rawDistance,
|
|
1173
|
+
startOfFn: dateFns.startOfMinute,
|
|
1174
|
+
endOfFn: dateFns.endOfMinute
|
|
1175
|
+
});
|
|
1106
1176
|
break;
|
|
1107
1177
|
case exports.DateRangeType.HOURS_RANGE:
|
|
1108
|
-
calculateStartAndEndForBetween(
|
|
1178
|
+
calculateStartAndEndForBetween({
|
|
1179
|
+
addFn: dateFns.addHours,
|
|
1180
|
+
distance: rawDistance,
|
|
1181
|
+
startOfFn: dateFns.startOfHour,
|
|
1182
|
+
endOfFn: dateFns.endOfHour
|
|
1183
|
+
});
|
|
1109
1184
|
break;
|
|
1110
1185
|
case exports.DateRangeType.DAYS_RANGE:
|
|
1111
|
-
calculateStartAndEndForBetween(
|
|
1186
|
+
calculateStartAndEndForBetween({
|
|
1187
|
+
addFn: dateFns.addDays,
|
|
1188
|
+
distance: rawDistance,
|
|
1189
|
+
startOfFn: dateFns.startOfDay,
|
|
1190
|
+
endOfFn: dateFns.endOfDay
|
|
1191
|
+
});
|
|
1112
1192
|
break;
|
|
1113
1193
|
case exports.DateRangeType.WEEKS_RANGE:
|
|
1114
|
-
calculateStartAndEndForBetween(
|
|
1194
|
+
calculateStartAndEndForBetween({
|
|
1195
|
+
addFn: dateFns.addWeeks,
|
|
1196
|
+
distance: rawDistance,
|
|
1197
|
+
startOfFn: dateFns.startOfWeek,
|
|
1198
|
+
endOfFn: dateFns.endOfWeek
|
|
1199
|
+
});
|
|
1115
1200
|
break;
|
|
1116
1201
|
case exports.DateRangeType.MONTHS_RANGE:
|
|
1117
|
-
calculateStartAndEndForBetween(
|
|
1202
|
+
calculateStartAndEndForBetween({
|
|
1203
|
+
addFn: dateFns.addMonths,
|
|
1204
|
+
distance: rawDistance,
|
|
1205
|
+
startOfFn: dateFns.startOfMonth,
|
|
1206
|
+
endOfFn: dateFns.endOfMonth
|
|
1207
|
+
});
|
|
1118
1208
|
break;
|
|
1119
1209
|
case exports.DateRangeType.MINUTES_RADIUS:
|
|
1120
1210
|
distance = Math.abs(distance);
|
|
@@ -1137,10 +1227,12 @@ exports.DateRangeType = void 0;
|
|
|
1137
1227
|
end = dateFns.addDays(date, distance * 7);
|
|
1138
1228
|
break;
|
|
1139
1229
|
case exports.DateRangeType.CALENDAR_MONTH:
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1230
|
+
{
|
|
1231
|
+
var monthStart = dateFns.startOfMonth(dateFns.endOfWeek(date));
|
|
1232
|
+
start = dateFns.startOfWeek(monthStart);
|
|
1233
|
+
end = dateFns.endOfWeek(dateFns.endOfMonth(monthStart));
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1144
1236
|
default:
|
|
1145
1237
|
throw new Error("Unknown date range type: ".concat(type));
|
|
1146
1238
|
}
|
|
@@ -1153,6 +1245,9 @@ exports.DateRangeType = void 0;
|
|
|
1153
1245
|
* Returns a range spanning the full calendar day (first to last millisecond) of the given date.
|
|
1154
1246
|
* Convenience wrapper around {@link dateRange} with {@link DateRangeType.DAY}.
|
|
1155
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
|
+
*
|
|
1156
1251
|
* @example
|
|
1157
1252
|
* ```ts
|
|
1158
1253
|
* const range = dateRangeFromStartAndEndOfDay(new Date('2024-06-15T14:30:00'));
|
|
@@ -1191,6 +1286,8 @@ var DEFAULT_ITERATE_DAYS_IN_DATE_RANGE_MAX_ITERATIONS = 4000;
|
|
|
1191
1286
|
* Creates a reusable function that iterates over dates within a range using a configurable step function.
|
|
1192
1287
|
* Supports max iteration limits and early bail-out via {@link endItreateDaysInDateRangeEarly}.
|
|
1193
1288
|
*
|
|
1289
|
+
* @param input - configuration or a step function for advancing between dates
|
|
1290
|
+
* @returns a reusable iteration function
|
|
1194
1291
|
* @throws Error if max iterations is exceeded and throwErrorOnMaxIterations is true
|
|
1195
1292
|
*
|
|
1196
1293
|
* @example
|
|
@@ -1244,6 +1341,8 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1244
1341
|
* Creates a reusable function that expands a {@link DateRange} into an array of individual day dates.
|
|
1245
1342
|
* Includes a configurable safety limit to prevent accidental memory exhaustion from large ranges.
|
|
1246
1343
|
*
|
|
1344
|
+
* @param config - optional configuration for the max expansion size
|
|
1345
|
+
* @returns a function that expands a DateRange into an array of Dates
|
|
1247
1346
|
* @throws Error if the range spans more days than the configured maxExpansionSize
|
|
1248
1347
|
*
|
|
1249
1348
|
* @example
|
|
@@ -1273,6 +1372,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1273
1372
|
* Expands a {@link DateRange} into an array of one Date per day. Uses the default max expansion size.
|
|
1274
1373
|
* Convenience wrapper around {@link expandDaysForDateRangeFunction}.
|
|
1275
1374
|
*
|
|
1375
|
+
* @param range - the date range to expand
|
|
1376
|
+
* @returns an array of Dates, one per day in the range
|
|
1377
|
+
*
|
|
1276
1378
|
* @example
|
|
1277
1379
|
* ```ts
|
|
1278
1380
|
* const days = expandDaysForDateRange({ start: new Date('2024-01-01'), end: new Date('2024-01-03') });
|
|
@@ -1284,6 +1386,12 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1284
1386
|
/**
|
|
1285
1387
|
* Determines whether the current moment (or provided `now`) falls before, within, or after the given range.
|
|
1286
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
|
+
*
|
|
1287
1395
|
* @example
|
|
1288
1396
|
* ```ts
|
|
1289
1397
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1306,6 +1414,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1306
1414
|
/**
|
|
1307
1415
|
* Groups an array of date ranges into past, present, and future buckets based on the current moment (or provided `now`).
|
|
1308
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
|
+
*
|
|
1309
1421
|
* @example
|
|
1310
1422
|
* ```ts
|
|
1311
1423
|
* const ranges = [
|
|
@@ -1324,6 +1436,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1324
1436
|
* Checks whether a date falls within a (possibly partial) date range.
|
|
1325
1437
|
* Convenience wrapper around {@link isDateInDateRangeFunction}.
|
|
1326
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
|
+
*
|
|
1327
1443
|
* @example
|
|
1328
1444
|
* ```ts
|
|
1329
1445
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1338,6 +1454,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1338
1454
|
* Handles partial ranges: if only start is set, checks >= start; if only end, checks <= end;
|
|
1339
1455
|
* if neither, all dates are considered in range.
|
|
1340
1456
|
*
|
|
1457
|
+
* @param dateRange - the boundary range to test against
|
|
1458
|
+
* @returns a function that tests whether a date falls within the range
|
|
1459
|
+
*
|
|
1341
1460
|
* @example
|
|
1342
1461
|
* ```ts
|
|
1343
1462
|
* const isInQ1 = isDateInDateRangeFunction({
|
|
@@ -1372,7 +1491,7 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1372
1491
|
return time <= endTime1;
|
|
1373
1492
|
};
|
|
1374
1493
|
} else {
|
|
1375
|
-
fn = function fn(
|
|
1494
|
+
fn = function fn(_input) {
|
|
1376
1495
|
return true;
|
|
1377
1496
|
};
|
|
1378
1497
|
}
|
|
@@ -1383,6 +1502,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1383
1502
|
* Checks whether a date range is fully contained within another (possibly partial) date range.
|
|
1384
1503
|
* Convenience wrapper around {@link isDateRangeInDateRangeFunction}.
|
|
1385
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
|
+
*
|
|
1386
1509
|
* @example
|
|
1387
1510
|
* ```ts
|
|
1388
1511
|
* const outer = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1396,6 +1519,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1396
1519
|
* Creates a reusable function that tests whether a given date range is fully contained within
|
|
1397
1520
|
* the configured boundary range. Both start and end of the input must be within bounds.
|
|
1398
1521
|
*
|
|
1522
|
+
* @param dateRange - the boundary range
|
|
1523
|
+
* @returns a function that tests containment of other ranges
|
|
1524
|
+
*
|
|
1399
1525
|
* @example
|
|
1400
1526
|
* ```ts
|
|
1401
1527
|
* const isInYear = isDateRangeInDateRangeFunction({
|
|
@@ -1417,6 +1543,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1417
1543
|
* Checks whether two date ranges overlap in any way (partial or full).
|
|
1418
1544
|
* Convenience wrapper around {@link dateRangeOverlapsDateRangeFunction}.
|
|
1419
1545
|
*
|
|
1546
|
+
* @param compareDateRange - the range to test for overlap
|
|
1547
|
+
* @param dateRange - the reference range
|
|
1548
|
+
* @returns true if the ranges overlap
|
|
1549
|
+
*
|
|
1420
1550
|
* @example
|
|
1421
1551
|
* ```ts
|
|
1422
1552
|
* const a = { start: new Date('2024-01-01'), end: new Date('2024-06-30') };
|
|
@@ -1430,6 +1560,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1430
1560
|
* Creates a reusable function that tests whether input ranges overlap the configured boundary range.
|
|
1431
1561
|
* Two ranges overlap if one starts before the other ends, and vice versa.
|
|
1432
1562
|
*
|
|
1563
|
+
* @param dateRange - the boundary range to test overlap against
|
|
1564
|
+
* @returns a function that tests overlap of other ranges
|
|
1565
|
+
*
|
|
1433
1566
|
* @example
|
|
1434
1567
|
* ```ts
|
|
1435
1568
|
* const overlapsQ1 = dateRangeOverlapsDateRangeFunction({
|
|
@@ -1461,6 +1594,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1461
1594
|
*
|
|
1462
1595
|
* Operates in UTC, so daylight savings transitions are not considered.
|
|
1463
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
|
+
*
|
|
1464
1600
|
* @example
|
|
1465
1601
|
* ```ts
|
|
1466
1602
|
* // 10AM to 1PM across 3 days becomes same-day 10AM to 1PM
|
|
@@ -1488,6 +1624,9 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1488
1624
|
* Dates before start are clamped to start; dates after end are clamped to end.
|
|
1489
1625
|
* Partial ranges clamp only on the side that is defined.
|
|
1490
1626
|
*
|
|
1627
|
+
* @param dateRange - the boundary range for clamping
|
|
1628
|
+
* @returns a function that clamps dates to the range
|
|
1629
|
+
*
|
|
1491
1630
|
* @example
|
|
1492
1631
|
* ```ts
|
|
1493
1632
|
* const clamp = clampDateFunction({
|
|
@@ -1503,15 +1642,16 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1503
1642
|
var hasStartDate = dateRange.start != null;
|
|
1504
1643
|
var hasEndDate = dateRange.end != null;
|
|
1505
1644
|
if (hasStartDate || hasEndDate) {
|
|
1645
|
+
var _ref, _ref1;
|
|
1506
1646
|
var _dateRange_start, _dateRange_end;
|
|
1507
1647
|
// Start Clamp
|
|
1508
|
-
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;
|
|
1509
1649
|
var clampStart = function clampStart(input) {
|
|
1510
1650
|
var time = input.getTime();
|
|
1511
1651
|
return time >= startTime ? input : dateRange.start;
|
|
1512
1652
|
};
|
|
1513
1653
|
// End Clamp
|
|
1514
|
-
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;
|
|
1515
1655
|
var clampEnd = function clampEnd(input) {
|
|
1516
1656
|
var time = input.getTime();
|
|
1517
1657
|
return time <= endTime ? input : dateRange.end;
|
|
@@ -1541,6 +1681,10 @@ var DEFAULT_EXPAND_DAYS_FOR_DATE_RANGE_MAX_EXPANSION_SIZE = 1500;
|
|
|
1541
1681
|
* Clamps a single date to fall within the given range boundaries.
|
|
1542
1682
|
* Convenience wrapper around {@link clampDateFunction}.
|
|
1543
1683
|
*
|
|
1684
|
+
* @param date - the date to clamp
|
|
1685
|
+
* @param dateRange - the boundary range
|
|
1686
|
+
* @returns the clamped date
|
|
1687
|
+
*
|
|
1544
1688
|
* @example
|
|
1545
1689
|
* ```ts
|
|
1546
1690
|
* const range = { start: new Date('2024-01-01'), end: new Date('2024-12-31') };
|
|
@@ -1568,6 +1712,10 @@ function clampDateRangeFunction(dateRange) {
|
|
|
1568
1712
|
* Clamps a date range to fit within a boundary range.
|
|
1569
1713
|
* Convenience wrapper around {@link clampDateRangeFunction}.
|
|
1570
1714
|
*
|
|
1715
|
+
* @param inputDateRange - the date range to clamp
|
|
1716
|
+
* @param limitToDateRange - the boundary range
|
|
1717
|
+
* @returns the clamped date range
|
|
1718
|
+
*
|
|
1571
1719
|
* @example
|
|
1572
1720
|
* ```ts
|
|
1573
1721
|
* const input = { start: new Date('2023-06-01'), end: new Date('2024-06-30') };
|
|
@@ -1581,6 +1729,9 @@ function clampDateRangeFunction(dateRange) {
|
|
|
1581
1729
|
/**
|
|
1582
1730
|
* Creates a function that applies a date transformation to both start and end of a {@link DateRange}.
|
|
1583
1731
|
*
|
|
1732
|
+
* @param transform - the transformation to apply to both dates
|
|
1733
|
+
* @returns a function that transforms both dates of a DateRange
|
|
1734
|
+
*
|
|
1584
1735
|
* @example
|
|
1585
1736
|
* ```ts
|
|
1586
1737
|
* import { startOfHour } from 'date-fns';
|
|
@@ -1604,6 +1755,9 @@ function clampDateRangeFunction(dateRange) {
|
|
|
1604
1755
|
* Returns each unique day of the week present in the range, in the order they appear starting from
|
|
1605
1756
|
* the range's start day. For ranges spanning 7+ days, returns all days of the week.
|
|
1606
1757
|
*
|
|
1758
|
+
* @param dateRange - the date range to inspect
|
|
1759
|
+
* @returns an array of unique day-of-week values present in the range
|
|
1760
|
+
*
|
|
1607
1761
|
* @example
|
|
1608
1762
|
* ```ts
|
|
1609
1763
|
* // Wednesday through Friday
|
|
@@ -1767,8 +1921,11 @@ function _type_of$6(obj) {
|
|
|
1767
1921
|
* isValidDateTimezoneConversionConfig({ timezone: 'America/Chicago' }); // true
|
|
1768
1922
|
* isValidDateTimezoneConversionConfig({}); // false
|
|
1769
1923
|
* ```
|
|
1924
|
+
*
|
|
1925
|
+
* @param input - the conversion config to validate
|
|
1926
|
+
* @returns true if the config has at least one meaningful conversion property set
|
|
1770
1927
|
*/ function isValidDateTimezoneConversionConfig(input) {
|
|
1771
|
-
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;
|
|
1772
1929
|
}
|
|
1773
1930
|
/**
|
|
1774
1931
|
* Compares two configs for logical equivalence, accounting for the fact that
|
|
@@ -1779,12 +1936,16 @@ function _type_of$6(obj) {
|
|
|
1779
1936
|
* isSameDateTimezoneConversionConfig({ timezone: 'UTC' }, { timezone: undefined }); // true
|
|
1780
1937
|
* isSameDateTimezoneConversionConfig({ useSystemTimezone: true }, { timezone: 'America/Denver' }); // false
|
|
1781
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
|
|
1782
1943
|
*/ function isSameDateTimezoneConversionConfig(a, b) {
|
|
1783
1944
|
var isSame = false;
|
|
1784
1945
|
if (a.useSystemTimezone || b.useSystemTimezone || a.timezoneOffset || b.timezoneOffset) {
|
|
1785
1946
|
isSame = util.isSameNonNullValue(a.useSystemTimezone, b.useSystemTimezone) || util.isSameNonNullValue(a.timezoneOffset, b.timezoneOffset);
|
|
1786
1947
|
} else {
|
|
1787
|
-
isSame = util.isConsideredUtcTimezoneString(a.timezone) && util.isConsideredUtcTimezoneString(b.timezone) || a
|
|
1948
|
+
isSame = util.isConsideredUtcTimezoneString(a.timezone) && util.isConsideredUtcTimezoneString(b.timezone) || a === b;
|
|
1788
1949
|
}
|
|
1789
1950
|
return isSame;
|
|
1790
1951
|
}
|
|
@@ -1803,6 +1964,7 @@ function _type_of$6(obj) {
|
|
|
1803
1964
|
* ```
|
|
1804
1965
|
*
|
|
1805
1966
|
* @param date - required to determine the correct offset for that instant (DST-aware)
|
|
1967
|
+
* @returns the system timezone UTC offset in milliseconds
|
|
1806
1968
|
*/ function getCurrentSystemOffsetInMs(date) {
|
|
1807
1969
|
// Use native getTimezoneOffset() instead of calculateTimezoneOffset() to avoid
|
|
1808
1970
|
// a DST edge case where toZonedTime() creates an epoch that lands on the system's
|
|
@@ -1819,6 +1981,7 @@ function _type_of$6(obj) {
|
|
|
1819
1981
|
* ```
|
|
1820
1982
|
*
|
|
1821
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
|
|
1822
1985
|
*/ function getCurrentSystemOffsetInHours(date) {
|
|
1823
1986
|
return dateFns.millisecondsToHours(getCurrentSystemOffsetInMs(date));
|
|
1824
1987
|
}
|
|
@@ -1835,6 +1998,7 @@ function _type_of$6(obj) {
|
|
|
1835
1998
|
* ```
|
|
1836
1999
|
*
|
|
1837
2000
|
* @param date - required to determine the correct offset for that instant (DST-aware)
|
|
2001
|
+
* @returns the system timezone UTC offset in minutes
|
|
1838
2002
|
*/ function getCurrentSystemOffsetInMinutes(date) {
|
|
1839
2003
|
return dateFns.millisecondsToMinutes(getCurrentSystemOffsetInMs(date));
|
|
1840
2004
|
}
|
|
@@ -1855,6 +2019,7 @@ function _type_of$6(obj) {
|
|
|
1855
2019
|
*
|
|
1856
2020
|
* @param timezone - IANA timezone string (e.g. 'America/New_York')
|
|
1857
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
|
|
1858
2023
|
*/ function calculateTimezoneOffset(timezone, date) {
|
|
1859
2024
|
var tzOffset;
|
|
1860
2025
|
// UTC always has zero offset; skip toZonedTime which can produce wrong results
|
|
@@ -1881,7 +2046,15 @@ function _type_of$6(obj) {
|
|
|
1881
2046
|
}
|
|
1882
2047
|
return tzOffset;
|
|
1883
2048
|
}
|
|
1884
|
-
|
|
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) {
|
|
1885
2058
|
var map = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function(x) {
|
|
1886
2059
|
return x;
|
|
1887
2060
|
};
|
|
@@ -1908,6 +2081,9 @@ function calculateAllConversions(date, converter) {
|
|
|
1908
2081
|
* inverseDateTimezoneUtcNormalInstanceTransformType('targetDateToBaseDate'); // 'baseDateToTargetDate'
|
|
1909
2082
|
* inverseDateTimezoneUtcNormalInstanceTransformType('systemDateToTargetDate'); // 'targetDateToSystemDate'
|
|
1910
2083
|
* ```
|
|
2084
|
+
*
|
|
2085
|
+
* @param input - the transform type to invert
|
|
2086
|
+
* @returns the inverse transform type for round-trip conversion
|
|
1911
2087
|
*/ function inverseDateTimezoneUtcNormalInstanceTransformType(input) {
|
|
1912
2088
|
var result;
|
|
1913
2089
|
switch(input){
|
|
@@ -1929,6 +2105,8 @@ function calculateAllConversions(date, converter) {
|
|
|
1929
2105
|
case 'targetDateToSystemDate':
|
|
1930
2106
|
result = 'systemDateToTargetDate';
|
|
1931
2107
|
break;
|
|
2108
|
+
default:
|
|
2109
|
+
throw new Error("Unexpected transform type: ".concat(input));
|
|
1932
2110
|
}
|
|
1933
2111
|
return result;
|
|
1934
2112
|
}
|
|
@@ -1960,8 +2138,7 @@ function calculateAllConversions(date, converter) {
|
|
|
1960
2138
|
};
|
|
1961
2139
|
};
|
|
1962
2140
|
var calculateOffset = function calculateOffset(date) {
|
|
1963
|
-
|
|
1964
|
-
return offset;
|
|
2141
|
+
return getOffsetInMsFn(date);
|
|
1965
2142
|
};
|
|
1966
2143
|
var calculateSystemNormalDifference = function calculateSystemNormalDifference(date) {
|
|
1967
2144
|
var normalOffset = calculateOffset(date);
|
|
@@ -2070,12 +2247,11 @@ function calculateAllConversions(date, converter) {
|
|
|
2070
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.
|
|
2071
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.
|
|
2072
2249
|
*
|
|
2073
|
-
* @param
|
|
2074
|
-
* @
|
|
2075
|
-
* @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
|
|
2076
2252
|
*/ key: "safeMirroredConvertDate",
|
|
2077
|
-
value: function safeMirroredConvertDate(
|
|
2078
|
-
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;
|
|
2079
2255
|
if (contextType === 'base') {
|
|
2080
2256
|
return {
|
|
2081
2257
|
date: baseDate,
|
|
@@ -2238,7 +2414,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2238
2414
|
/**
|
|
2239
2415
|
* Returns true if the input is midnight in the target timezone.
|
|
2240
2416
|
*
|
|
2241
|
-
* @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
|
|
2242
2419
|
*/ key: "isStartOfDayInTargetTimezone",
|
|
2243
2420
|
value: function isStartOfDayInTargetTimezone(date) {
|
|
2244
2421
|
var utcNormal = this.baseDateToTargetDate(date);
|
|
@@ -2249,7 +2426,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2249
2426
|
/**
|
|
2250
2427
|
* Start of the given day in the target timezone.
|
|
2251
2428
|
*
|
|
2252
|
-
* @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
|
|
2253
2431
|
*/ key: "startOfDayInTargetTimezone",
|
|
2254
2432
|
value: function startOfDayInTargetTimezone(date) {
|
|
2255
2433
|
var baseDay = this.startOfDayInBaseDate(date);
|
|
@@ -2260,7 +2438,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2260
2438
|
/**
|
|
2261
2439
|
* Start of the given day in UTC.
|
|
2262
2440
|
*
|
|
2263
|
-
* @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
|
|
2264
2443
|
*/ key: "startOfDayInBaseDate",
|
|
2265
2444
|
value: function startOfDayInBaseDate(date) {
|
|
2266
2445
|
if (typeof date === 'string') {
|
|
@@ -2275,8 +2454,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2275
2454
|
/**
|
|
2276
2455
|
* End of the given day in UTC.
|
|
2277
2456
|
*
|
|
2278
|
-
* @param date
|
|
2279
|
-
* @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)
|
|
2280
2459
|
*/ key: "endOfDayInBaseDate",
|
|
2281
2460
|
value: function endOfDayInBaseDate(date) {
|
|
2282
2461
|
var result = this.startOfDayInBaseDate(date);
|
|
@@ -2288,8 +2467,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2288
2467
|
/**
|
|
2289
2468
|
* Start of the given day for the system.
|
|
2290
2469
|
*
|
|
2291
|
-
* @param date
|
|
2292
|
-
* @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
|
|
2293
2472
|
*/ key: "startOfDayInSystemDate",
|
|
2294
2473
|
value: function startOfDayInSystemDate(date) {
|
|
2295
2474
|
if (typeof date === 'string') {
|
|
@@ -2304,8 +2483,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2304
2483
|
/**
|
|
2305
2484
|
* End of the given day for the system.
|
|
2306
2485
|
*
|
|
2307
|
-
* @param date
|
|
2308
|
-
* @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
|
|
2309
2488
|
*/ key: "endOfDayInSystemDate",
|
|
2310
2489
|
value: function endOfDayInSystemDate(date) {
|
|
2311
2490
|
return dateFns.endOfDay(this.startOfDayInSystemDate(date));
|
|
@@ -2313,9 +2492,10 @@ function calculateAllConversions(date, converter) {
|
|
|
2313
2492
|
},
|
|
2314
2493
|
{
|
|
2315
2494
|
/**
|
|
2316
|
-
* Whether or not the
|
|
2495
|
+
* Whether or not the target timezone experiences daylight savings for the given year.
|
|
2317
2496
|
*
|
|
2318
|
-
* @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
|
|
2319
2499
|
*/ key: "targetTimezoneExperiencesDaylightSavings",
|
|
2320
2500
|
value: function targetTimezoneExperiencesDaylightSavings() {
|
|
2321
2501
|
var year = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
@@ -2372,6 +2552,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2372
2552
|
* const same = dateTimezoneUtcNormal(denver); // same reference
|
|
2373
2553
|
* ```
|
|
2374
2554
|
*
|
|
2555
|
+
* @param config - timezone input: an existing instance, timezone string, millisecond offset, or config object
|
|
2556
|
+
* @returns a DateTimezoneUtcNormalInstance for the given input
|
|
2375
2557
|
* @throws Error if the input type is not recognized
|
|
2376
2558
|
*/ function dateTimezoneUtcNormal(config) {
|
|
2377
2559
|
var instance;
|
|
@@ -2379,6 +2561,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2379
2561
|
instance = config;
|
|
2380
2562
|
} else {
|
|
2381
2563
|
var type = typeof config === "undefined" ? "undefined" : _type_of$6(config);
|
|
2564
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
2382
2565
|
switch(type){
|
|
2383
2566
|
case 'object':
|
|
2384
2567
|
instance = new DateTimezoneUtcNormalInstance(config);
|
|
@@ -2394,7 +2577,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2394
2577
|
});
|
|
2395
2578
|
break;
|
|
2396
2579
|
default:
|
|
2397
|
-
throw new Error('Invalid input passed to dateTimezoneUtcNormal()');
|
|
2580
|
+
throw new Error('Invalid input type "'.concat(type, '" passed to dateTimezoneUtcNormal()'));
|
|
2398
2581
|
}
|
|
2399
2582
|
}
|
|
2400
2583
|
return instance;
|
|
@@ -2417,6 +2600,8 @@ function calculateAllConversions(date, converter) {
|
|
|
2417
2600
|
*
|
|
2418
2601
|
* Prefer this over constructing a new instance when you need system-timezone conversions,
|
|
2419
2602
|
* as the singleton avoids unnecessary allocations.
|
|
2603
|
+
*
|
|
2604
|
+
* @returns the shared system-timezone DateTimezoneUtcNormalInstance singleton
|
|
2420
2605
|
*/ function systemDateTimezoneUtcNormal() {
|
|
2421
2606
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE;
|
|
2422
2607
|
}
|
|
@@ -2433,10 +2618,13 @@ function calculateAllConversions(date, converter) {
|
|
|
2433
2618
|
* const target = baseDateToTargetDate(base, 'America/Denver');
|
|
2434
2619
|
* // target is 2024-06-15T14:00:00.000-06:00 (2PM MDT)
|
|
2435
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
|
|
2436
2625
|
*/ function baseDateToTargetDate(date, timezone) {
|
|
2437
2626
|
var instance = new DateTimezoneUtcNormalInstance(timezone);
|
|
2438
|
-
|
|
2439
|
-
return result;
|
|
2627
|
+
return instance.baseDateToTargetDate(date);
|
|
2440
2628
|
}
|
|
2441
2629
|
/**
|
|
2442
2630
|
* Convenience function that strips the timezone offset from a target-timezone date,
|
|
@@ -2451,30 +2639,46 @@ function calculateAllConversions(date, converter) {
|
|
|
2451
2639
|
* const base = targetDateToBaseDate(target, 'America/Denver');
|
|
2452
2640
|
* // base is 2024-06-15T14:00:00.000Z — wall-clock 2PM preserved as UTC
|
|
2453
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
|
|
2454
2646
|
*/ function targetDateToBaseDate(date, timezone) {
|
|
2455
2647
|
return new DateTimezoneUtcNormalInstance(timezone).targetDateToBaseDate(date);
|
|
2456
2648
|
}
|
|
2457
2649
|
/**
|
|
2458
2650
|
* Converts a {@link BaseDateAsUTC} to a target date in the system's local timezone
|
|
2459
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
|
|
2460
2655
|
*/ function systemBaseDateToNormalDate(date) {
|
|
2461
2656
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.baseDateToTargetDate(date);
|
|
2462
2657
|
}
|
|
2463
2658
|
/**
|
|
2464
2659
|
* Converts a target date in the system's local timezone back to a {@link BaseDateAsUTC}
|
|
2465
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
|
|
2466
2664
|
*/ function systemNormalDateToBaseDate(date) {
|
|
2467
2665
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.targetDateToBaseDate(date);
|
|
2468
2666
|
}
|
|
2469
2667
|
/**
|
|
2470
2668
|
* Returns the millisecond offset needed to convert a {@link BaseDateAsUTC} to a target date
|
|
2471
2669
|
* in the system's local timezone.
|
|
2670
|
+
*
|
|
2671
|
+
* @param date - the date to compute the offset for
|
|
2672
|
+
* @returns the offset in milliseconds
|
|
2472
2673
|
*/ function systemBaseDateToNormalDateOffset(date) {
|
|
2473
2674
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.baseDateToTargetDateOffset(date);
|
|
2474
2675
|
}
|
|
2475
2676
|
/**
|
|
2476
2677
|
* Returns the millisecond offset needed to convert a target date in the system's
|
|
2477
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
|
|
2478
2682
|
*/ function systemNormalDateToBaseDateOffset(date) {
|
|
2479
2683
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.targetDateToBaseDateOffset(date);
|
|
2480
2684
|
}
|
|
@@ -2482,6 +2686,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2482
2686
|
* Returns whether the system's local timezone observes daylight saving time in the given year.
|
|
2483
2687
|
*
|
|
2484
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
|
|
2485
2692
|
*/ function systemExperiencesDaylightSavings(year) {
|
|
2486
2693
|
return SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE.targetTimezoneExperiencesDaylightSavings(year);
|
|
2487
2694
|
}
|
|
@@ -2497,7 +2704,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2497
2704
|
* const result = fn(someDate, (d) => startOfDay(d));
|
|
2498
2705
|
* ```
|
|
2499
2706
|
*
|
|
2707
|
+
* @param timezoneInput - timezone configuration for the conversion
|
|
2500
2708
|
* @param transformType - defaults to `'systemDateToTargetDate'`
|
|
2709
|
+
* @returns a function that transforms dates within the specified timezone normalization
|
|
2501
2710
|
*/ function transformDateInTimezoneNormalFunction(timezoneInput) {
|
|
2502
2711
|
var transformType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'systemDateToTargetDate';
|
|
2503
2712
|
var timezoneInstance = dateTimezoneUtcNormal(timezoneInput);
|
|
@@ -2516,7 +2725,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2516
2725
|
* Creates a {@link TransformDateRangeToTimezoneFunction} that converts both dates in
|
|
2517
2726
|
* a {@link DateRange} using the specified transform type.
|
|
2518
2727
|
*
|
|
2728
|
+
* @param timezoneInput - timezone configuration for the conversion
|
|
2519
2729
|
* @param transformType - defaults to `'systemDateToTargetDate'`
|
|
2730
|
+
* @returns a function that converts DateRange dates using the specified transform
|
|
2520
2731
|
*/ function transformDateRangeToTimezoneFunction(timezoneInput) {
|
|
2521
2732
|
var transformType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'systemDateToTargetDate';
|
|
2522
2733
|
var timezoneInstance = dateTimezoneUtcNormal(timezoneInput);
|
|
@@ -2529,7 +2740,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2529
2740
|
* Creates a {@link TransformDateRangeInTimezoneNormalFunction} that converts a date range
|
|
2530
2741
|
* into the specified date space, applies a user-provided range transformation, then converts back.
|
|
2531
2742
|
*
|
|
2743
|
+
* @param timezoneInput - timezone configuration for the conversion
|
|
2532
2744
|
* @param transformType - defaults to `'systemDateToTargetDate'`
|
|
2745
|
+
* @returns a function that transforms date ranges within the specified timezone normalization
|
|
2533
2746
|
*/ function transformDateRangeInTimezoneNormalFunction(timezoneInput) {
|
|
2534
2747
|
var transformType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'systemDateToTargetDate';
|
|
2535
2748
|
var timezoneInstance = dateTimezoneUtcNormal(timezoneInput);
|
|
@@ -2553,6 +2766,9 @@ function calculateAllConversions(date, converter) {
|
|
|
2553
2766
|
* const midnight = startOfDayInDenver('2024-06-15');
|
|
2554
2767
|
* // midnight is 2024-06-15T06:00:00.000Z (midnight MDT = 6AM UTC)
|
|
2555
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
|
|
2556
2772
|
*/ function startOfDayInTimezoneDayStringFactory(timezone) {
|
|
2557
2773
|
var timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
2558
2774
|
return function(day) {
|
|
@@ -2568,6 +2784,10 @@ function calculateAllConversions(date, converter) {
|
|
|
2568
2784
|
* ```ts
|
|
2569
2785
|
* const midnight = startOfDayInTimezoneFromISO8601DayString('2024-06-15', 'America/Denver');
|
|
2570
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
|
|
2571
2791
|
*/ function startOfDayInTimezoneFromISO8601DayString(day, timezone) {
|
|
2572
2792
|
return startOfDayInTimezoneDayStringFactory(timezone)(day);
|
|
2573
2793
|
}
|
|
@@ -2584,8 +2804,12 @@ function calculateAllConversions(date, converter) {
|
|
|
2584
2804
|
* const result = setOnDate({ date: someDate, hours: 14, minutes: 30, inputType: 'target' });
|
|
2585
2805
|
* // result is someDate with hours set to 14:30 in Denver time
|
|
2586
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
|
|
2587
2810
|
*/ function setOnDateWithTimezoneNormalFunction(timezone) {
|
|
2588
2811
|
var timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
2812
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
2589
2813
|
var fn = function fn(input) {
|
|
2590
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;
|
|
2591
2815
|
var DEFAULT_TYPE = 'target';
|
|
@@ -2601,7 +2825,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2601
2825
|
return roundDownToMinute ? roundDateDownTo(inputDate, 'minute') : inputDate;
|
|
2602
2826
|
}
|
|
2603
2827
|
if (inputType !== 'base') {
|
|
2604
|
-
copyFrom =
|
|
2828
|
+
copyFrom = timezoneInstance.convertDate(copyFrom, 'base', inputType);
|
|
2605
2829
|
}
|
|
2606
2830
|
}
|
|
2607
2831
|
// set baseDate
|
|
@@ -2650,6 +2874,7 @@ function calculateAllConversions(date, converter) {
|
|
|
2650
2874
|
*
|
|
2651
2875
|
* @param input - the date whose day is preserved
|
|
2652
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
|
|
2653
2878
|
*/ function copyHoursAndMinutesFromNowWithTimezoneNormal(input, timezone) {
|
|
2654
2879
|
return copyHoursAndMinutesFromDateWithTimezoneNormal(input, 'now', timezone);
|
|
2655
2880
|
}
|
|
@@ -2670,16 +2895,16 @@ function calculateAllConversions(date, converter) {
|
|
|
2670
2895
|
* @param input - the date whose day is preserved
|
|
2671
2896
|
* @param copyFrom - the date (or `'now'`) whose hours/minutes are copied
|
|
2672
2897
|
* @param timezone - the timezone context for interpreting both dates
|
|
2898
|
+
* @returns the input date with hours and minutes copied from the source
|
|
2673
2899
|
*/ function copyHoursAndMinutesFromDateWithTimezoneNormal(input, copyFrom, timezone) {
|
|
2674
2900
|
var timezoneInstance = dateTimezoneUtcNormal(timezone);
|
|
2675
|
-
|
|
2901
|
+
return timezoneInstance.setOnDate({
|
|
2676
2902
|
date: input,
|
|
2677
2903
|
copyFrom: copyFrom,
|
|
2678
2904
|
inputType: 'target',
|
|
2679
2905
|
copyHours: true,
|
|
2680
2906
|
copyMinutes: true
|
|
2681
2907
|
});
|
|
2682
|
-
return result;
|
|
2683
2908
|
}
|
|
2684
2909
|
|
|
2685
2910
|
function _define_property$e(obj, key, value) {
|
|
@@ -2740,6 +2965,7 @@ function _object_spread$c(target) {
|
|
|
2740
2965
|
*
|
|
2741
2966
|
* @param dateRange - the range to fit
|
|
2742
2967
|
* @param timezone - the timezone for day boundary calculation
|
|
2968
|
+
* @returns the date range fitted to a single day period
|
|
2743
2969
|
*/ function fitDateRangeToDayPeriod(dateRange, timezone) {
|
|
2744
2970
|
return fitDateRangeToDayPeriodFunction(timezone)(dateRange);
|
|
2745
2971
|
}
|
|
@@ -2750,6 +2976,7 @@ function _object_spread$c(target) {
|
|
|
2750
2976
|
* Useful when the same range formatting logic needs to be applied repeatedly with consistent settings.
|
|
2751
2977
|
*
|
|
2752
2978
|
* @param inputConfig - format function or full configuration
|
|
2979
|
+
* @returns a reusable function that formats date ranges into strings
|
|
2753
2980
|
*
|
|
2754
2981
|
* @example
|
|
2755
2982
|
* ```ts
|
|
@@ -2786,6 +3013,7 @@ function _object_spread$c(target) {
|
|
|
2786
3013
|
* @param range - date range to format
|
|
2787
3014
|
* @param inputConfig - format function or full configuration
|
|
2788
3015
|
* @param separator - optional separator override when inputConfig is a function
|
|
3016
|
+
* @returns the formatted date range string
|
|
2789
3017
|
*
|
|
2790
3018
|
* @example
|
|
2791
3019
|
* ```ts
|
|
@@ -2809,6 +3037,7 @@ function _object_spread$c(target) {
|
|
|
2809
3037
|
* (e.g., "3 hours", "about 2 days"). Delegates to date-fns `formatDistance` or `formatDistanceStrict`.
|
|
2810
3038
|
*
|
|
2811
3039
|
* @param inputConfig - controls distance formatting, optional transforms, and same-day handling
|
|
3040
|
+
* @returns a reusable function that computes and formats date range distances
|
|
2812
3041
|
*
|
|
2813
3042
|
* @example
|
|
2814
3043
|
* ```ts
|
|
@@ -2862,6 +3091,7 @@ function _object_spread$c(target) {
|
|
|
2862
3091
|
*
|
|
2863
3092
|
* @param range - date range to compute distance for
|
|
2864
3093
|
* @param inputConfig - optional distance formatting configuration
|
|
3094
|
+
* @returns the human-readable distance string
|
|
2865
3095
|
*
|
|
2866
3096
|
* @example
|
|
2867
3097
|
* ```ts
|
|
@@ -2902,7 +3132,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2902
3132
|
end = endOrFormat;
|
|
2903
3133
|
}
|
|
2904
3134
|
}
|
|
2905
|
-
var format = inputFormat !== null && inputFormat !== void 0 ? inputFormat :
|
|
3135
|
+
var format = inputFormat !== null && inputFormat !== void 0 ? inputFormat : formatToMonthDaySlashDate;
|
|
2906
3136
|
return formatDateRange(dateOrDateRangeToDateRange(startOrDateRange, end), {
|
|
2907
3137
|
format: format,
|
|
2908
3138
|
simplifySameDate: true
|
|
@@ -2913,6 +3143,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2913
3143
|
* instead of throwing.
|
|
2914
3144
|
*
|
|
2915
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
|
|
2916
3147
|
*
|
|
2917
3148
|
* @example
|
|
2918
3149
|
* ```ts
|
|
@@ -2935,6 +3166,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2935
3166
|
* Formats a Date to a full ISO 8601 date-time string via `Date.toISOString()`. Defaults to the current date/time.
|
|
2936
3167
|
*
|
|
2937
3168
|
* @param date - date to format; defaults to `new Date()`
|
|
3169
|
+
* @returns the full ISO 8601 date-time string
|
|
2938
3170
|
*
|
|
2939
3171
|
* @example
|
|
2940
3172
|
* ```ts
|
|
@@ -2954,6 +3186,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2954
3186
|
* Use {@link toISO8601DayStringForUTC} when the UTC date is needed instead.
|
|
2955
3187
|
*
|
|
2956
3188
|
* @param dateOrString - date or existing day string
|
|
3189
|
+
* @returns the ISO 8601 day string in system timezone
|
|
2957
3190
|
*
|
|
2958
3191
|
* @example
|
|
2959
3192
|
* ```ts
|
|
@@ -2973,6 +3206,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2973
3206
|
* Defaults to the current date.
|
|
2974
3207
|
*
|
|
2975
3208
|
* @param date - date to format; defaults to `new Date()`
|
|
3209
|
+
* @returns the ISO 8601 day string in system timezone
|
|
2976
3210
|
*
|
|
2977
3211
|
* @example
|
|
2978
3212
|
* ```ts
|
|
@@ -2992,6 +3226,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
2992
3226
|
* Use {@link toISO8601DayStringForSystem} when the system-local date is needed instead.
|
|
2993
3227
|
*
|
|
2994
3228
|
* @param dateOrString - date or existing day string
|
|
3229
|
+
* @returns the ISO 8601 day string in UTC
|
|
2995
3230
|
*
|
|
2996
3231
|
* @example
|
|
2997
3232
|
* ```ts
|
|
@@ -3012,6 +3247,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3012
3247
|
* Defaults to the current date.
|
|
3013
3248
|
*
|
|
3014
3249
|
* @param date - date to format; defaults to `new Date()`
|
|
3250
|
+
* @returns the ISO 8601 day string using UTC date components
|
|
3015
3251
|
*
|
|
3016
3252
|
* @example
|
|
3017
3253
|
* ```ts
|
|
@@ -3024,12 +3260,18 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3024
3260
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
3025
3261
|
return "".concat(date.getUTCFullYear(), "-").concat((date.getUTCMonth() + 1).toString().padStart(2, '0'), "-").concat(date.getUTCDate().toString().padStart(2, '0'));
|
|
3026
3262
|
}
|
|
3027
|
-
/**
|
|
3028
|
-
|
|
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;
|
|
3029
3270
|
/**
|
|
3030
3271
|
* Formats a Date as a month/day/year slash-separated string (`MM/dd/yyyy`). Defaults to the current date.
|
|
3031
3272
|
*
|
|
3032
3273
|
* @param date - date to format; defaults to `new Date()`
|
|
3274
|
+
* @returns the formatted `MM/dd/yyyy` string
|
|
3033
3275
|
*
|
|
3034
3276
|
* @example
|
|
3035
3277
|
* ```ts
|
|
@@ -3045,12 +3287,18 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3045
3287
|
/**
|
|
3046
3288
|
* @deprecated use formatToMonthDaySlashDate instead.
|
|
3047
3289
|
*/ var formatToShortDateString = formatToMonthDaySlashDate;
|
|
3048
|
-
/**
|
|
3049
|
-
|
|
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;
|
|
3050
3297
|
/**
|
|
3051
3298
|
* Formats a Date as a month/day string (`MM/dd`) without the year. Defaults to the current date.
|
|
3052
3299
|
*
|
|
3053
3300
|
* @param date - date to format; defaults to `new Date()`
|
|
3301
|
+
* @returns the formatted `MM/dd` string
|
|
3054
3302
|
*
|
|
3055
3303
|
* @example
|
|
3056
3304
|
* ```ts
|
|
@@ -3067,6 +3315,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3067
3315
|
* Formats a Date as a human-friendly weekday and month/day string (e.g., `"Mon, Jan 15th"`).
|
|
3068
3316
|
*
|
|
3069
3317
|
* @param date - date to format
|
|
3318
|
+
* @returns the formatted weekday and month/day string
|
|
3070
3319
|
*
|
|
3071
3320
|
* @example
|
|
3072
3321
|
* ```ts
|
|
@@ -3078,12 +3327,18 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3078
3327
|
*/ function formatToDateString(date) {
|
|
3079
3328
|
return dateFns.format(date, 'EEE, MMM do');
|
|
3080
3329
|
}
|
|
3081
|
-
/**
|
|
3082
|
-
|
|
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;
|
|
3083
3337
|
/**
|
|
3084
3338
|
* Formats a Date as a 12-hour time string with AM/PM (e.g., `"9:00 AM"`).
|
|
3085
3339
|
*
|
|
3086
3340
|
* @param date - date to format
|
|
3341
|
+
* @returns the formatted 12-hour time string with AM/PM
|
|
3087
3342
|
*
|
|
3088
3343
|
* @example
|
|
3089
3344
|
* ```ts
|
|
@@ -3095,12 +3350,18 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3095
3350
|
*/ function formatToTimeString(date) {
|
|
3096
3351
|
return dateFns.format(date, DATE_TIME_STRING_FORMAT);
|
|
3097
3352
|
}
|
|
3098
|
-
/**
|
|
3099
|
-
|
|
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;
|
|
3100
3360
|
/**
|
|
3101
3361
|
* Formats a Date as a short date and time string (e.g., `"01/15/2024 9:00 AM"`).
|
|
3102
3362
|
*
|
|
3103
3363
|
* @param date - date to format
|
|
3364
|
+
* @returns the formatted short date and time string
|
|
3104
3365
|
*
|
|
3105
3366
|
* @example
|
|
3106
3367
|
* ```ts
|
|
@@ -3118,6 +3379,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3118
3379
|
*
|
|
3119
3380
|
* @param start - start date/time
|
|
3120
3381
|
* @param end - end date/time
|
|
3382
|
+
* @returns the formatted time string with an appended duration indicator
|
|
3121
3383
|
*
|
|
3122
3384
|
* @example
|
|
3123
3385
|
* ```ts
|
|
@@ -3139,7 +3401,8 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3139
3401
|
includeSeconds: false
|
|
3140
3402
|
}), ")");
|
|
3141
3403
|
} else {
|
|
3142
|
-
|
|
3404
|
+
var minutesLabel = minutes ? "(".concat(minutes, " Minutes)") : '';
|
|
3405
|
+
subtitle = minutesLabel;
|
|
3143
3406
|
}
|
|
3144
3407
|
return "".concat(formatToTimeString(start), " ").concat(subtitle);
|
|
3145
3408
|
}
|
|
@@ -3162,6 +3425,11 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3162
3425
|
* formatStartedEndedDistanceString(activeRange);
|
|
3163
3426
|
* // "started about 1 hour ago"
|
|
3164
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
|
|
3165
3433
|
*/ function formatStartedEndedDistanceString(param) {
|
|
3166
3434
|
var start = param.start, end = param.end;
|
|
3167
3435
|
var state = dateRangeRelativeState({
|
|
@@ -3193,6 +3461,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3193
3461
|
* Useful for converting heterogeneous date inputs into a consistent midnight-aligned Date.
|
|
3194
3462
|
*
|
|
3195
3463
|
* @param input - date or day string to normalize
|
|
3464
|
+
* @returns a Date set to midnight of the corresponding day in the system timezone
|
|
3196
3465
|
*
|
|
3197
3466
|
* @example
|
|
3198
3467
|
* ```ts
|
|
@@ -3212,6 +3481,7 @@ function formatToDayRangeString(startOrDateRange, endOrFormat, inputFormat) {
|
|
|
3212
3481
|
* in the system timezone. Supports year formats with more than 4 digits but does not support negative years.
|
|
3213
3482
|
*
|
|
3214
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
|
|
3215
3485
|
*
|
|
3216
3486
|
* @example
|
|
3217
3487
|
* ```ts
|
|
@@ -3428,6 +3698,11 @@ function _type_of$5(obj) {
|
|
|
3428
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.
|
|
3429
3699
|
*
|
|
3430
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
|
|
3431
3706
|
*/ function dateCellTiming(durationInput, rangeInput, timezoneInput) {
|
|
3432
3707
|
var duration = durationInput.duration;
|
|
3433
3708
|
if (duration > util.MINUTES_IN_DAY) {
|
|
@@ -3482,7 +3757,12 @@ function _type_of$5(obj) {
|
|
|
3482
3757
|
var utcDay = formatToISO8601DayStringForUTC(startsAtInUtc);
|
|
3483
3758
|
var start = normalInstance.startOfDayInTargetTimezone(utcDay);
|
|
3484
3759
|
var safeMirror = util.isEqualDate(startsAtInUtc, startsAtInUtcInitial);
|
|
3485
|
-
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;
|
|
3486
3766
|
// calculate end to be the ending date/time of the final duration span
|
|
3487
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
|
|
3488
3768
|
var lastStartInTarget = normalInstance.targetDateToBaseDate(lastStartsAtInBaseTimezone);
|
|
@@ -3742,8 +4022,16 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3742
4022
|
var normalInstance = dateTimezoneUtcNormal(timezone);
|
|
3743
4023
|
var startsAtInUtcNormal = normalInstance.baseDateToTargetDate(startsAt); // convert to UTC normal
|
|
3744
4024
|
var endInUtcNormal = normalInstance.baseDateToTargetDate(end);
|
|
3745
|
-
var _normalInstance_safeMirroredConvertDate = normalInstance.safeMirroredConvertDate(
|
|
3746
|
-
|
|
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;
|
|
3747
4035
|
if (startDaylightSavingsOffset) {
|
|
3748
4036
|
startsAtInUtcNormal = dateFns.addHours(startsAtInUtcNormal, startDaylightSavingsOffset);
|
|
3749
4037
|
}
|
|
@@ -3829,7 +4117,7 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3829
4117
|
isExpectedValidEnd = expectedDuration === duration; // should be the expected duration
|
|
3830
4118
|
isValid = isExpectedValidEnd;
|
|
3831
4119
|
}
|
|
3832
|
-
|
|
4120
|
+
return {
|
|
3833
4121
|
isValid: isValid,
|
|
3834
4122
|
endIsAfterTheStartsAtTime: endIsAfterTheStartsAtTime,
|
|
3835
4123
|
durationGreaterThanZero: durationGreaterThanZero,
|
|
@@ -3838,7 +4126,6 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3838
4126
|
isExpectedValidEnd: isExpectedValidEnd,
|
|
3839
4127
|
normalInstance: normalInstance
|
|
3840
4128
|
};
|
|
3841
|
-
return result;
|
|
3842
4129
|
}
|
|
3843
4130
|
/**
|
|
3844
4131
|
* Returns true if the {@link DateCellTiming} passes all validation checks.
|
|
@@ -3903,13 +4190,13 @@ function _calculateExpectedDateCellTimingDurationPair(timing) {
|
|
|
3903
4190
|
return isValid;
|
|
3904
4191
|
}
|
|
3905
4192
|
|
|
3906
|
-
function _array_like_to_array$
|
|
4193
|
+
function _array_like_to_array$6(arr, len) {
|
|
3907
4194
|
if (len == null || len > arr.length) len = arr.length;
|
|
3908
4195
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
3909
4196
|
return arr2;
|
|
3910
4197
|
}
|
|
3911
|
-
function _array_without_holes$
|
|
3912
|
-
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);
|
|
3913
4200
|
}
|
|
3914
4201
|
function _define_property$c(obj, key, value) {
|
|
3915
4202
|
if (key in obj) {
|
|
@@ -3924,10 +4211,10 @@ function _define_property$c(obj, key, value) {
|
|
|
3924
4211
|
}
|
|
3925
4212
|
return obj;
|
|
3926
4213
|
}
|
|
3927
|
-
function _iterable_to_array$
|
|
4214
|
+
function _iterable_to_array$4(iter) {
|
|
3928
4215
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
3929
4216
|
}
|
|
3930
|
-
function _non_iterable_spread$
|
|
4217
|
+
function _non_iterable_spread$4() {
|
|
3931
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.");
|
|
3932
4219
|
}
|
|
3933
4220
|
function _object_spread$a(target) {
|
|
@@ -3964,20 +4251,20 @@ function _object_spread_props$8(target, source) {
|
|
|
3964
4251
|
}
|
|
3965
4252
|
return target;
|
|
3966
4253
|
}
|
|
3967
|
-
function _to_consumable_array$
|
|
3968
|
-
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();
|
|
3969
4256
|
}
|
|
3970
4257
|
function _type_of$4(obj) {
|
|
3971
4258
|
"@swc/helpers - typeof";
|
|
3972
4259
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
3973
4260
|
}
|
|
3974
|
-
function _unsupported_iterable_to_array$
|
|
4261
|
+
function _unsupported_iterable_to_array$6(o, minLen) {
|
|
3975
4262
|
if (!o) return;
|
|
3976
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
4263
|
+
if (typeof o === "string") return _array_like_to_array$6(o, minLen);
|
|
3977
4264
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3978
4265
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3979
4266
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
3980
|
-
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);
|
|
3981
4268
|
}
|
|
3982
4269
|
/**
|
|
3983
4270
|
* Returns true if the input is a DateCellRange.
|
|
@@ -3985,6 +4272,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
3985
4272
|
* Does not check validity. Use {@link isValidDateCellRange} for that.
|
|
3986
4273
|
*
|
|
3987
4274
|
* @param input - value to check
|
|
4275
|
+
* @returns true if the input is a DateCellRange
|
|
3988
4276
|
*/ function isDateCellRange(input) {
|
|
3989
4277
|
return (typeof input === "undefined" ? "undefined" : _type_of$4(input)) === 'object' ? Number.isInteger(input.i) && input.to === undefined || Number.isInteger(input.to) : false;
|
|
3990
4278
|
}
|
|
@@ -3995,6 +4283,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
3995
4283
|
* that is greater than or equal to `i`.
|
|
3996
4284
|
*
|
|
3997
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`
|
|
3998
4287
|
*/ function isValidDateCellRange(input) {
|
|
3999
4288
|
var i = input.i, to = input.to;
|
|
4000
4289
|
if (!isValidDateCellIndex(i)) {
|
|
@@ -4010,6 +4299,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4010
4299
|
* Validates that each range is individually valid and that no ranges overlap or appear out of order.
|
|
4011
4300
|
*
|
|
4012
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
|
|
4013
4303
|
*/ function isValidDateCellRangeSeries(input) {
|
|
4014
4304
|
if (!Array.isArray(input)) {
|
|
4015
4305
|
return false;
|
|
@@ -4021,13 +4311,30 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4021
4311
|
return false;
|
|
4022
4312
|
}
|
|
4023
4313
|
var greatestIndex = -1;
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
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
|
+
}
|
|
4031
4338
|
}
|
|
4032
4339
|
}
|
|
4033
4340
|
return true;
|
|
@@ -4038,6 +4345,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4038
4345
|
* The input range is not expected to be sorted.
|
|
4039
4346
|
*
|
|
4040
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
|
|
4041
4349
|
*/ function getLeastDateCellIndexInDateCellRanges(input) {
|
|
4042
4350
|
var _ref;
|
|
4043
4351
|
var _getLeastAndGreatestDateCellIndexInDateCellRanges;
|
|
@@ -4049,6 +4357,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4049
4357
|
* The input range is not expected to be sorted.
|
|
4050
4358
|
*
|
|
4051
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
|
|
4052
4361
|
*/ function getGreatestDateCellIndexInDateCellRanges(input) {
|
|
4053
4362
|
var _ref;
|
|
4054
4363
|
var _getLeastAndGreatestDateCellIndexInDateCellRanges;
|
|
@@ -4060,6 +4369,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4060
4369
|
* The input range is not expected to be sorted.
|
|
4061
4370
|
*
|
|
4062
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
|
|
4063
4373
|
*/ function getLeastAndGreatestDateCellIndexInDateCellRanges(input) {
|
|
4064
4374
|
if (!input.length) {
|
|
4065
4375
|
return null;
|
|
@@ -4068,17 +4378,34 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4068
4378
|
var greatestIndex = 0;
|
|
4069
4379
|
var leastIndexItem = input[0];
|
|
4070
4380
|
var greatestIndexItem = input[0];
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
var
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
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
|
+
}
|
|
4078
4396
|
}
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
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
|
+
}
|
|
4082
4409
|
}
|
|
4083
4410
|
}
|
|
4084
4411
|
return {
|
|
@@ -4094,6 +4421,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4094
4421
|
*
|
|
4095
4422
|
* @param i - starting cell index
|
|
4096
4423
|
* @param to - ending cell index (inclusive); defaults to `i`
|
|
4424
|
+
* @returns a DateCellRangeWithRange spanning from `i` to `to`
|
|
4097
4425
|
*/ function dateCellRange(i, to) {
|
|
4098
4426
|
return {
|
|
4099
4427
|
i: i,
|
|
@@ -4104,6 +4432,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4104
4432
|
* Creates a single-cell {@link DateCellRangeWithRange} where both `i` and `to` equal the given index.
|
|
4105
4433
|
*
|
|
4106
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
|
|
4107
4436
|
*/ function dateCellRangeWithRangeFromIndex(dateCellIndex) {
|
|
4108
4437
|
return dateCellRange(dateCellIndex, dateCellIndex);
|
|
4109
4438
|
}
|
|
@@ -4112,6 +4441,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4112
4441
|
* ensuring the result always has an explicit `to` value.
|
|
4113
4442
|
*
|
|
4114
4443
|
* @param input - index, cell, or range to normalize
|
|
4444
|
+
* @returns a DateCellRangeWithRange with an explicit `to` value
|
|
4115
4445
|
*/ function dateCellRangeWithRange(input) {
|
|
4116
4446
|
if (typeof input === 'number') {
|
|
4117
4447
|
return dateCellRangeWithRangeFromIndex(input);
|
|
@@ -4124,12 +4454,12 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4124
4454
|
* fully contains the configured `inputRange`.
|
|
4125
4455
|
*
|
|
4126
4456
|
* @param inputRange - the range that must be fully included
|
|
4457
|
+
* @returns a function that returns true when its argument fully contains `inputRange`
|
|
4127
4458
|
*/ function dateCellRangeIncludedByRangeFunction(inputRange) {
|
|
4128
4459
|
var _dateCellRangeWithRange = dateCellRangeWithRange(inputRange), i = _dateCellRangeWithRange.i, to = _dateCellRangeWithRange.to;
|
|
4129
4460
|
return function(input) {
|
|
4130
|
-
var _ref;
|
|
4131
4461
|
var range = dateCellRangeWithRange(input);
|
|
4132
|
-
return range.i <= i &&
|
|
4462
|
+
return range.i <= i && range.to >= to;
|
|
4133
4463
|
};
|
|
4134
4464
|
}
|
|
4135
4465
|
/**
|
|
@@ -4137,12 +4467,12 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4137
4467
|
* has any overlap with the configured `inputRange`.
|
|
4138
4468
|
*
|
|
4139
4469
|
* @param inputRange - the range to test for overlap against
|
|
4470
|
+
* @returns a function that returns true when its argument overlaps with `inputRange`
|
|
4140
4471
|
*/ function dateCellRangeOverlapsRangeFunction(inputRange) {
|
|
4141
4472
|
var _dateCellRangeWithRange = dateCellRangeWithRange(inputRange), i = _dateCellRangeWithRange.i, to = _dateCellRangeWithRange.to;
|
|
4142
4473
|
return function(input) {
|
|
4143
|
-
var _ref;
|
|
4144
4474
|
var range = dateCellRangeWithRange(input);
|
|
4145
|
-
return range.i <= to &&
|
|
4475
|
+
return range.i <= to && range.to >= i;
|
|
4146
4476
|
};
|
|
4147
4477
|
}
|
|
4148
4478
|
/**
|
|
@@ -4150,6 +4480,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4150
4480
|
*
|
|
4151
4481
|
* @param rangeA - first range to compare
|
|
4152
4482
|
* @param rangeB - second range to compare
|
|
4483
|
+
* @returns true if the two ranges share at least one common index
|
|
4153
4484
|
*/ function dateCellRangeOverlapsRange(rangeA, rangeB) {
|
|
4154
4485
|
return dateCellRangeOverlapsRangeFunction(rangeA)(rangeB);
|
|
4155
4486
|
}
|
|
@@ -4157,6 +4488,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4157
4488
|
* Returns a sort comparator that orders ranges first by starting index (`i`), then by ending index (`to`).
|
|
4158
4489
|
*
|
|
4159
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`
|
|
4160
4493
|
*/ function sortDateCellRangeAndSizeFunction() {
|
|
4161
4494
|
return function(a, b) {
|
|
4162
4495
|
var _a_to, _b_to;
|
|
@@ -4167,6 +4500,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4167
4500
|
* Sorts the input date ranges in-place by ascending index using {@link sortAscendingIndexNumberRefFunction}.
|
|
4168
4501
|
*
|
|
4169
4502
|
* @param input - array of ranges to sort (mutated in place)
|
|
4503
|
+
* @returns the same array, sorted in ascending index order
|
|
4170
4504
|
*/ function sortDateCellRanges(input) {
|
|
4171
4505
|
return input.sort(util.sortAscendingIndexNumberRefFunction());
|
|
4172
4506
|
}
|
|
@@ -4177,6 +4511,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4177
4511
|
* The input is sorted internally before grouping.
|
|
4178
4512
|
*
|
|
4179
4513
|
* @param input - cells or ranges to merge into contiguous groups
|
|
4514
|
+
* @returns an array of non-overlapping contiguous DateCellRangeWithRange values
|
|
4180
4515
|
*
|
|
4181
4516
|
* @example
|
|
4182
4517
|
* ```ts
|
|
@@ -4224,6 +4559,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4224
4559
|
* Returns an array containing every individual index in the given date cell range (inclusive of both `i` and `to`).
|
|
4225
4560
|
*
|
|
4226
4561
|
* @param input - range to expand into individual indexes
|
|
4562
|
+
* @returns an array of every DateCellIndex from `i` to `to` inclusive
|
|
4227
4563
|
*/ function allIndexesInDateCellRange(input) {
|
|
4228
4564
|
return input.to != null ? util.range(input.i, input.to + 1) : [
|
|
4229
4565
|
input.i
|
|
@@ -4233,6 +4569,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4233
4569
|
* Flattens an array of indexes and/or ranges into a single array of individual {@link DateCellIndex} values.
|
|
4234
4570
|
*
|
|
4235
4571
|
* @param input - mix of raw indexes and ranges to flatten
|
|
4572
|
+
* @returns a flat array of all individual DateCellIndex values
|
|
4236
4573
|
*/ function allIndexesInDateCellRangesToArray(input) {
|
|
4237
4574
|
var result = [];
|
|
4238
4575
|
input.forEach(function(x) {
|
|
@@ -4249,6 +4586,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4249
4586
|
* Returns a deduplicated {@link Set} of all indexes within the input ranges.
|
|
4250
4587
|
*
|
|
4251
4588
|
* @param input - mix of raw indexes and ranges to collect
|
|
4589
|
+
* @returns a Set containing every unique DateCellIndex from the input
|
|
4252
4590
|
*/ function allIndexesInDateCellRanges(input) {
|
|
4253
4591
|
return new Set(allIndexesInDateCellRangesToArray(input));
|
|
4254
4592
|
}
|
|
@@ -4257,6 +4595,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4257
4595
|
*
|
|
4258
4596
|
* @param blocks - cells or ranges to filter
|
|
4259
4597
|
* @param range - bounding range that blocks must fall within
|
|
4598
|
+
* @returns only the blocks that fall entirely within the given range
|
|
4260
4599
|
*/ function filterDateCellsInDateCellRange(blocks, range) {
|
|
4261
4600
|
var dateCellIsWithinDateCellRange = isDateCellWithinDateCellRangeFunction(range);
|
|
4262
4601
|
return blocks.filter(dateCellIsWithinDateCellRange);
|
|
@@ -4266,6 +4605,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4266
4605
|
* is fully contained within `inputRange`.
|
|
4267
4606
|
*
|
|
4268
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`
|
|
4269
4609
|
*/ function isDateCellWithinDateCellRangeFunction(inputRange) {
|
|
4270
4610
|
var range = dateCellRangeWithRange(inputRange);
|
|
4271
4611
|
return function(input) {
|
|
@@ -4287,6 +4627,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4287
4627
|
*
|
|
4288
4628
|
* @param range - the outer bounding range
|
|
4289
4629
|
* @param contains - the cell or range to test for containment
|
|
4630
|
+
* @returns true if `contains` is fully within `range`
|
|
4290
4631
|
*/ function isDateCellWithinDateCellRange(range, contains) {
|
|
4291
4632
|
return isDateCellWithinDateCellRangeFunction(range)(dateCellRangeWithRange(contains));
|
|
4292
4633
|
}
|
|
@@ -4296,6 +4637,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4296
4637
|
* Internally groups overlapping ranges before counting so each index is counted only once.
|
|
4297
4638
|
*
|
|
4298
4639
|
* @param inputDateCellRange - one or more cells/ranges to analyze
|
|
4640
|
+
* @returns count, total, and average statistics for the given ranges
|
|
4299
4641
|
*/ function dateCellRangeBlocksCountInfo(inputDateCellRange) {
|
|
4300
4642
|
var group = groupToDateCellRanges(util.asArray(inputDateCellRange));
|
|
4301
4643
|
var count = 0;
|
|
@@ -4318,6 +4660,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4318
4660
|
* Shorthand for `dateCellRangeBlocksCountInfo(input).count`.
|
|
4319
4661
|
*
|
|
4320
4662
|
* @param inputDateCellRange - one or more cells/ranges to count
|
|
4663
|
+
* @returns the total number of individual cell indexes
|
|
4321
4664
|
*
|
|
4322
4665
|
* @example
|
|
4323
4666
|
* ```ts
|
|
@@ -4332,13 +4675,14 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4332
4675
|
* grouped range from `ranges` fully covers a given input range.
|
|
4333
4676
|
*
|
|
4334
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
|
|
4335
4679
|
*/ function dateCellRangesFullyCoverDateCellRangeFunction(ranges) {
|
|
4336
4680
|
var groupedRanges = Array.isArray(ranges) ? groupToDateCellRanges(ranges) : [
|
|
4337
4681
|
dateCellRangeWithRange(ranges)
|
|
4338
4682
|
];
|
|
4339
4683
|
return function(inputRange) {
|
|
4340
4684
|
var fn = dateCellRangeIncludedByRangeFunction(inputRange);
|
|
4341
|
-
return groupedRanges.
|
|
4685
|
+
return groupedRanges.some(fn);
|
|
4342
4686
|
};
|
|
4343
4687
|
}
|
|
4344
4688
|
/**
|
|
@@ -4349,6 +4693,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4349
4693
|
* nearest future range's starting index is used.
|
|
4350
4694
|
*
|
|
4351
4695
|
* @param input - the current index and ranges to evaluate
|
|
4696
|
+
* @returns classification of ranges as past/present/future and the next upcoming index
|
|
4352
4697
|
*
|
|
4353
4698
|
* @example
|
|
4354
4699
|
* ```ts
|
|
@@ -4405,6 +4750,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4405
4750
|
*
|
|
4406
4751
|
* @param range - the date cell range to classify
|
|
4407
4752
|
* @param nowIndex - the reference index representing "now"
|
|
4753
|
+
* @returns 'past', 'present', or 'future' depending on the range's position relative to `nowIndex`
|
|
4408
4754
|
*/ function dateRelativeStateForDateCellRangeComparedToIndex(range, nowIndex) {
|
|
4409
4755
|
var _dateCellRange = dateCellRange(range.i, range.to), i = _dateCellRange.i, to = _dateCellRange.to;
|
|
4410
4756
|
var state;
|
|
@@ -4422,6 +4768,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4422
4768
|
* from `i` to `to` (inclusive). Each copy retains all properties of the original block.
|
|
4423
4769
|
*
|
|
4424
4770
|
* @param block - the range to expand
|
|
4771
|
+
* @returns an array of single-cell copies, one per index from `i` to `to`
|
|
4425
4772
|
*
|
|
4426
4773
|
* @example
|
|
4427
4774
|
* ```ts
|
|
@@ -4440,6 +4787,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4440
4787
|
* Returns true if the input spans more than one cell (i.e., has a `to` value strictly greater than `i`).
|
|
4441
4788
|
*
|
|
4442
4789
|
* @param input - range or cell to check
|
|
4790
|
+
* @returns true if `to` is defined and strictly greater than `i`
|
|
4443
4791
|
*/ function dateCellRangeHasRange(input) {
|
|
4444
4792
|
return input.to != null && input.to > input.i;
|
|
4445
4793
|
}
|
|
@@ -4447,6 +4795,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4447
4795
|
* Returns the effective ending index of a range: `to` if defined, otherwise `i`.
|
|
4448
4796
|
*
|
|
4449
4797
|
* @param input - range or cell to read
|
|
4798
|
+
* @returns the `to` index if defined, otherwise `i`
|
|
4450
4799
|
*/ function dateCellEndIndex(input) {
|
|
4451
4800
|
var _input_to;
|
|
4452
4801
|
return (_input_to = input.to) !== null && _input_to !== void 0 ? _input_to : input.i;
|
|
@@ -4457,8 +4806,9 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4457
4806
|
* and `to` is the maximum ending index across all blocks.
|
|
4458
4807
|
*
|
|
4459
4808
|
* @param input - cells or ranges to group
|
|
4809
|
+
* @returns a UniqueDateCellRangeGroup containing the sorted blocks with `i` at 0
|
|
4460
4810
|
*/ function groupUniqueDateCells(input) {
|
|
4461
|
-
var blocks = sortDateCellRanges(_to_consumable_array$
|
|
4811
|
+
var blocks = sortDateCellRanges(_to_consumable_array$4(input));
|
|
4462
4812
|
var i = 0;
|
|
4463
4813
|
var to;
|
|
4464
4814
|
if (blocks.length === 0) {
|
|
@@ -4479,6 +4829,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4479
4829
|
* according to the provided configuration. Handles overlap resolution, gap filling, and boundary clamping.
|
|
4480
4830
|
*
|
|
4481
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
|
|
4482
4833
|
*
|
|
4483
4834
|
* @example
|
|
4484
4835
|
* ```ts
|
|
@@ -4496,9 +4847,10 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4496
4847
|
var retainOnOverlap = inputRetainOnOverlap !== null && inputRetainOnOverlap !== void 0 ? inputRetainOnOverlap : 'next';
|
|
4497
4848
|
var maxAllowedIndex = endAtIndex !== null && endAtIndex !== void 0 ? endAtIndex : Number.MAX_SAFE_INTEGER;
|
|
4498
4849
|
var fillFactory = inputFillFactory;
|
|
4499
|
-
if (!
|
|
4850
|
+
if (!inputFillFactory && fill === 'fill') {
|
|
4500
4851
|
throw new Error('fillFactory is required when fillOption is "fill".');
|
|
4501
4852
|
}
|
|
4853
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
4502
4854
|
return function(input, newBlocks) {
|
|
4503
4855
|
var addBlockWithRange = function addBlockWithRange(inputBlock, i) {
|
|
4504
4856
|
var inputTo = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : i;
|
|
@@ -4536,7 +4888,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4536
4888
|
to: to
|
|
4537
4889
|
};
|
|
4538
4890
|
var block = fillFactory(dateCellRange);
|
|
4539
|
-
addBlockWithRange(block, i, to
|
|
4891
|
+
addBlockWithRange(block, i, to);
|
|
4540
4892
|
} else if (fill === 'empty') ; else if (blocks.length > 0) {
|
|
4541
4893
|
// only extend if one or more blocks have been pushed
|
|
4542
4894
|
var blockToExtend = util.lastValue(blocks);
|
|
@@ -4557,6 +4909,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4557
4909
|
};
|
|
4558
4910
|
var shouldRetainCurrentOverNext = /**
|
|
4559
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
|
|
4560
4914
|
*/ function shouldRetainCurrentOverNext() {
|
|
4561
4915
|
if (current.priority === next.priority) {
|
|
4562
4916
|
return retainOnOverlap === 'current';
|
|
@@ -4597,6 +4951,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4597
4951
|
priority: priority
|
|
4598
4952
|
} : sorted[i];
|
|
4599
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
|
|
4600
4955
|
if (next) {
|
|
4601
4956
|
nextStartIndex = next.block.i;
|
|
4602
4957
|
// complete loop once past the max allowed index
|
|
@@ -4713,6 +5068,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4713
5068
|
}
|
|
4714
5069
|
}
|
|
4715
5070
|
}
|
|
5071
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- current may be undefined when sorted is empty
|
|
4716
5072
|
if (current != null) {
|
|
4717
5073
|
// if current != null, then atleast one block was input/remaining.
|
|
4718
5074
|
var lastStartIndex = current.block.i;
|
|
@@ -4727,12 +5083,11 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
4727
5083
|
} else if (fill === 'fill') {
|
|
4728
5084
|
completeBlocks();
|
|
4729
5085
|
}
|
|
4730
|
-
|
|
5086
|
+
return {
|
|
4731
5087
|
i: 0,
|
|
4732
5088
|
blocks: blocks,
|
|
4733
5089
|
discarded: discarded
|
|
4734
5090
|
};
|
|
4735
|
-
return result;
|
|
4736
5091
|
};
|
|
4737
5092
|
}
|
|
4738
5093
|
|
|
@@ -4795,6 +5150,9 @@ function _type_of$3(obj) {
|
|
|
4795
5150
|
* When `limitToCompletedIndexes` is true, only indexes whose timing duration has fully elapsed are included,
|
|
4796
5151
|
* with the max boundary lazily refreshed as time passes.
|
|
4797
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
|
+
*
|
|
4798
5156
|
* @example
|
|
4799
5157
|
* ```ts
|
|
4800
5158
|
* const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
|
|
@@ -4870,6 +5228,10 @@ function _type_of$3(obj) {
|
|
|
4870
5228
|
* Computes a {@link DateCellRangeWithRange} from a timing and optional start/end input.
|
|
4871
5229
|
*
|
|
4872
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.
|
|
4873
5235
|
*/ function dateCellRangeOfTiming(config, input) {
|
|
4874
5236
|
return dateCellRangeOfTimingFactory(isDateCellTiming(config) ? {
|
|
4875
5237
|
timing: config
|
|
@@ -4880,6 +5242,10 @@ function _type_of$3(obj) {
|
|
|
4880
5242
|
* of the timing schedule. Useful for determining which days have already finished.
|
|
4881
5243
|
*
|
|
4882
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.
|
|
4883
5249
|
*/ function dateCellTimingCompletedTimeRange(timing, config) {
|
|
4884
5250
|
var _ref;
|
|
4885
5251
|
return dateCellRangeOfTiming({
|
|
@@ -4893,6 +5259,10 @@ function _type_of$3(obj) {
|
|
|
4893
5259
|
* Returns the latest completed day index for a {@link DateCellTiming}.
|
|
4894
5260
|
*
|
|
4895
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.
|
|
4896
5266
|
*/ function dateCellTimingLatestCompletedIndex(timing, now) {
|
|
4897
5267
|
return dateCellTimingCompletedTimeRange(timing, {
|
|
4898
5268
|
now: now
|
|
@@ -4900,6 +5270,9 @@ function _type_of$3(obj) {
|
|
|
4900
5270
|
}
|
|
4901
5271
|
/**
|
|
4902
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`.
|
|
4903
5276
|
*/ function dateCellRangeToDateCellIndexRange(range) {
|
|
4904
5277
|
var _range_to;
|
|
4905
5278
|
return {
|
|
@@ -4909,6 +5282,9 @@ function _type_of$3(obj) {
|
|
|
4909
5282
|
}
|
|
4910
5283
|
/**
|
|
4911
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`.
|
|
4912
5288
|
*/ function dateCellIndexRangeToDateCellRange(range) {
|
|
4913
5289
|
return {
|
|
4914
5290
|
i: range.minIndex,
|
|
@@ -4920,6 +5296,11 @@ function _type_of$3(obj) {
|
|
|
4920
5296
|
*
|
|
4921
5297
|
* An arbitrary limit can also be applied. When `fitToTimingRange` is true (default),
|
|
4922
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.
|
|
4923
5304
|
*/ function dateCellIndexRange(timing, limit) {
|
|
4924
5305
|
var fitToTimingRange = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
4925
5306
|
var indexFactory = dateCellTimingRelativeIndexFactory(timing);
|
|
@@ -4948,6 +5329,9 @@ function _type_of$3(obj) {
|
|
|
4948
5329
|
* by combining its timing and blocks.
|
|
4949
5330
|
*
|
|
4950
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.
|
|
4951
5335
|
*/ function expandDateCellCollection(collection) {
|
|
4952
5336
|
return expandDateCellTiming(collection.timing, collection.blocks);
|
|
4953
5337
|
}
|
|
@@ -4955,6 +5339,10 @@ function _type_of$3(obj) {
|
|
|
4955
5339
|
* Expands the given blocks into {@link DateCellDurationSpan} values using the provided timing.
|
|
4956
5340
|
*
|
|
4957
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.
|
|
4958
5346
|
*/ function expandDateCellTiming(timing, blocks) {
|
|
4959
5347
|
return dateCellTimingExpansionFactory({
|
|
4960
5348
|
timing: timing
|
|
@@ -4968,6 +5356,9 @@ function _type_of$3(obj) {
|
|
|
4968
5356
|
* Filtering is applied both at the block level and at the computed duration span level,
|
|
4969
5357
|
* and evaluation can be capped for performance with large datasets.
|
|
4970
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
|
+
*
|
|
4971
5362
|
* @example
|
|
4972
5363
|
* ```ts
|
|
4973
5364
|
* const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
|
|
@@ -5065,6 +5456,9 @@ function _type_of$3(obj) {
|
|
|
5065
5456
|
* const dateInfo = infoFactory(someDate);
|
|
5066
5457
|
* console.log(dateInfo.dayIndex); // which day index this date falls on
|
|
5067
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.
|
|
5068
5462
|
*/ function dateCellDayTimingInfoFactory(config) {
|
|
5069
5463
|
var timing = config.timing, rangeLimit = config.rangeLimit;
|
|
5070
5464
|
var duration = timing.duration;
|
|
@@ -5129,8 +5523,11 @@ function _type_of$3(obj) {
|
|
|
5129
5523
|
* Type guard that returns true if the input is a {@link DateCellTimingRelativeIndexFactory}.
|
|
5130
5524
|
*
|
|
5131
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}.
|
|
5132
5529
|
*/ function isDateCellTimingRelativeIndexFactory(input) {
|
|
5133
|
-
return typeof input === 'function' &&
|
|
5530
|
+
return typeof input === 'function' && '_timing' in input && '_normalInstance' in input;
|
|
5134
5531
|
}
|
|
5135
5532
|
/**
|
|
5136
5533
|
* Creates a {@link DateCellTimingRelativeIndexFactory} that converts dates, ISO8601 day strings,
|
|
@@ -5158,6 +5555,9 @@ function _type_of$3(obj) {
|
|
|
5158
5555
|
* indexFactory._timing; // the original timing
|
|
5159
5556
|
* indexFactory._normalInstance; // timezone normalizer
|
|
5160
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.
|
|
5161
5561
|
*/ function dateCellTimingRelativeIndexFactory(input) {
|
|
5162
5562
|
if (isDateCellTimingRelativeIndexFactory(input)) {
|
|
5163
5563
|
return input;
|
|
@@ -5196,6 +5596,9 @@ function _type_of$3(obj) {
|
|
|
5196
5596
|
* dates, date ranges, and cell ranges into a flat array of day indexes.
|
|
5197
5597
|
*
|
|
5198
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.
|
|
5199
5602
|
*/ function dateCellTimingRelativeIndexArrayFactory(indexFactory) {
|
|
5200
5603
|
var factory = function factory(input) {
|
|
5201
5604
|
var inputAsArray = util.asArray(input);
|
|
@@ -5237,6 +5640,10 @@ function _type_of$3(obj) {
|
|
|
5237
5640
|
* // Get the index for a specific date
|
|
5238
5641
|
* const index = getRelativeIndexForDateCellTiming(timing, someDate);
|
|
5239
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.
|
|
5240
5647
|
*/ function getRelativeIndexForDateCellTiming(timing) {
|
|
5241
5648
|
var date = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Date();
|
|
5242
5649
|
return dateCellTimingRelativeIndexFactory(timing)(date);
|
|
@@ -5263,6 +5670,9 @@ function _type_of$3(obj) {
|
|
|
5263
5670
|
* // Convert index 3 to a date with a specific reference time
|
|
5264
5671
|
* const dateForDay3AtNoon = dateFactory(3, noonDate);
|
|
5265
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.
|
|
5266
5676
|
*/ function dateCellTimingDateFactory(timing) {
|
|
5267
5677
|
var _dateCellTimingStartPair = dateCellTimingStartPair(timing), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
|
|
5268
5678
|
var utcStartDate = normalInstance.baseDateToTargetDate(start);
|
|
@@ -5278,8 +5688,8 @@ function _type_of$3(obj) {
|
|
|
5278
5688
|
if (startUtcHours > nowHours) {
|
|
5279
5689
|
input += 1;
|
|
5280
5690
|
}
|
|
5281
|
-
|
|
5282
|
-
return
|
|
5691
|
+
// add days to apply the correct offset to the target index
|
|
5692
|
+
return dateFns.addHours(utcStartDateWithNowTime, input * util.HOURS_IN_DAY);
|
|
5283
5693
|
}
|
|
5284
5694
|
};
|
|
5285
5695
|
factory._timing = timing;
|
|
@@ -5296,6 +5706,9 @@ function _type_of$3(obj) {
|
|
|
5296
5706
|
* const timing = dateCellTiming({ startsAt, duration: 60 }, 5);
|
|
5297
5707
|
* const lastIndex = dateCellTimingEndIndex(timing); // 4 (zero-based, 5 days)
|
|
5298
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.
|
|
5299
5712
|
*/ function dateCellTimingEndIndex(input) {
|
|
5300
5713
|
var factory = dateCellTimingRelativeIndexFactory(input);
|
|
5301
5714
|
return factory(factory._timing.end);
|
|
@@ -5305,6 +5718,9 @@ function _type_of$3(obj) {
|
|
|
5305
5718
|
* for any day index relative to the timing's start.
|
|
5306
5719
|
*
|
|
5307
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.
|
|
5308
5724
|
*/ function dateCellTimingStartDateFactory(input) {
|
|
5309
5725
|
var indexFactory = dateCellTimingRelativeIndexFactory(input);
|
|
5310
5726
|
var _dateCellTimingStartPair = dateCellTimingStartPair(indexFactory._timing), start = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
|
|
@@ -5342,6 +5758,10 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5342
5758
|
/**
|
|
5343
5759
|
* Convenience function that returns the calendar date for a given day index or date
|
|
5344
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.
|
|
5345
5765
|
*/ function getRelativeDateForDateCellTiming(timing, input) {
|
|
5346
5766
|
return dateCellTimingDateFactory(timing)(input);
|
|
5347
5767
|
}
|
|
@@ -5367,6 +5787,9 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5367
5787
|
* });
|
|
5368
5788
|
* // result has the same start day and end day, but new time-of-day and 90-minute duration
|
|
5369
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.
|
|
5370
5793
|
*/ function updateDateCellTimingWithDateCellTimingEvent(input) {
|
|
5371
5794
|
var timing = input.timing, event = input.event, replaceStartDay = input.replaceStartDay, replaceStartsAt = input.replaceStartsAt, startDateDay = input.startDayDate, endOnEvent = input.endOnEvent, replaceDuration = input.replaceDuration;
|
|
5372
5795
|
var timezone = timing.timezone;
|
|
@@ -5383,7 +5806,8 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5383
5806
|
var _dateCellTimingStartPair = dateCellTimingStartPair({
|
|
5384
5807
|
startsAt: event.startsAt,
|
|
5385
5808
|
timezone: timezone
|
|
5386
|
-
}),
|
|
5809
|
+
}), initialEventStartDate = _dateCellTimingStartPair.start, normalInstance = _dateCellTimingStartPair.normalInstance;
|
|
5810
|
+
var eventStartDate = initialEventStartDate;
|
|
5387
5811
|
if (startDateDay != null) {
|
|
5388
5812
|
var startDateFactory = dateCellTimingStartDateFactory(timing);
|
|
5389
5813
|
eventStartDate = startDateFactory(startDateDay);
|
|
@@ -5447,6 +5871,9 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5447
5871
|
* isInRange(6); // false - index 6 is outside [2, 5]
|
|
5448
5872
|
* isInRange(someDate); // converts date to index, then checks containment
|
|
5449
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.
|
|
5450
5877
|
*/ function isDateWithinDateCellRangeFunction(config) {
|
|
5451
5878
|
var inputStartsAt = config.startsAt, inputRange = config.range;
|
|
5452
5879
|
var startsAt = inputStartsAt;
|
|
@@ -5467,13 +5894,11 @@ function dateCellTimingEndDateFactory(input) {
|
|
|
5467
5894
|
} else {
|
|
5468
5895
|
rangeInput = inputRange;
|
|
5469
5896
|
}
|
|
5470
|
-
if (!inputStartsAt) {
|
|
5471
|
-
|
|
5472
|
-
startsAt
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
};
|
|
5476
|
-
}
|
|
5897
|
+
if (!inputStartsAt && dateRange && isDateInput) {
|
|
5898
|
+
startsAt = {
|
|
5899
|
+
startsAt: inputRange,
|
|
5900
|
+
timezone: guessCurrentTimezone()
|
|
5901
|
+
};
|
|
5477
5902
|
}
|
|
5478
5903
|
if (!startsAt) {
|
|
5479
5904
|
throw new Error('Invalid isDateWithinDateCellRangeFunction() config. StartsAt date info could not be determined from input.');
|
|
@@ -5626,6 +6051,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5626
6051
|
* Useful for identifying events or blocks that have already begun relative to a point in time.
|
|
5627
6052
|
*
|
|
5628
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
|
|
5629
6055
|
*
|
|
5630
6056
|
* @example
|
|
5631
6057
|
* ```ts
|
|
@@ -5644,6 +6070,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5644
6070
|
* The inverse of {@link dateCellDurationSpanHasStartedFilterFunction}. Useful for finding upcoming or future events.
|
|
5645
6071
|
*
|
|
5646
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
|
|
5647
6074
|
*
|
|
5648
6075
|
* @example
|
|
5649
6076
|
* ```ts
|
|
@@ -5663,6 +6090,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5663
6090
|
* Useful for identifying completed events.
|
|
5664
6091
|
*
|
|
5665
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
|
|
5666
6094
|
*
|
|
5667
6095
|
* @example
|
|
5668
6096
|
* ```ts
|
|
@@ -5683,6 +6111,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5683
6111
|
* still in progress or have not yet occurred.
|
|
5684
6112
|
*
|
|
5685
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
|
|
5686
6115
|
*
|
|
5687
6116
|
* @example
|
|
5688
6117
|
* ```ts
|
|
@@ -5704,6 +6133,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5704
6133
|
* indices clamped to the range boundaries. Non-overlapping cells are excluded entirely.
|
|
5705
6134
|
*
|
|
5706
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
|
|
5707
6137
|
*
|
|
5708
6138
|
* @example
|
|
5709
6139
|
* ```ts
|
|
@@ -5744,6 +6174,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5744
6174
|
*
|
|
5745
6175
|
* @param range - The target range to fit cells into.
|
|
5746
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
|
|
5747
6178
|
*
|
|
5748
6179
|
* @example
|
|
5749
6180
|
* ```ts
|
|
@@ -5758,6 +6189,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5758
6189
|
*
|
|
5759
6190
|
* @param range - The target range to fit the cell into.
|
|
5760
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
|
|
5761
6193
|
*
|
|
5762
6194
|
* @example
|
|
5763
6195
|
* ```ts
|
|
@@ -5772,7 +6204,7 @@ function _object_spread_props$6(target, source) {
|
|
|
5772
6204
|
])[0];
|
|
5773
6205
|
}
|
|
5774
6206
|
|
|
5775
|
-
function _array_like_to_array$
|
|
6207
|
+
function _array_like_to_array$5(arr, len) {
|
|
5776
6208
|
if (len == null || len > arr.length) len = arr.length;
|
|
5777
6209
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5778
6210
|
return arr2;
|
|
@@ -5780,6 +6212,9 @@ function _array_like_to_array$4(arr, len) {
|
|
|
5780
6212
|
function _array_with_holes$2(arr) {
|
|
5781
6213
|
if (Array.isArray(arr)) return arr;
|
|
5782
6214
|
}
|
|
6215
|
+
function _array_without_holes$3(arr) {
|
|
6216
|
+
if (Array.isArray(arr)) return _array_like_to_array$5(arr);
|
|
6217
|
+
}
|
|
5783
6218
|
function _instanceof(left, right) {
|
|
5784
6219
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
5785
6220
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -5787,6 +6222,9 @@ function _instanceof(left, right) {
|
|
|
5787
6222
|
return left instanceof right;
|
|
5788
6223
|
}
|
|
5789
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
|
+
}
|
|
5790
6228
|
function _iterable_to_array_limit$2(arr, i) {
|
|
5791
6229
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
5792
6230
|
if (_i == null) return;
|
|
@@ -5814,16 +6252,22 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
5814
6252
|
function _non_iterable_rest$2() {
|
|
5815
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.");
|
|
5816
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
|
+
}
|
|
5817
6258
|
function _sliced_to_array$2(arr, i) {
|
|
5818
|
-
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();
|
|
5819
6260
|
}
|
|
5820
|
-
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) {
|
|
5821
6265
|
if (!o) return;
|
|
5822
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
6266
|
+
if (typeof o === "string") return _array_like_to_array$5(o, minLen);
|
|
5823
6267
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
5824
6268
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
5825
6269
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
5826
|
-
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);
|
|
5827
6271
|
}
|
|
5828
6272
|
/**
|
|
5829
6273
|
* Used for default YearWeekCode values
|
|
@@ -5929,8 +6373,7 @@ function _unsupported_iterable_to_array$4(o, minLen) {
|
|
|
5929
6373
|
* @param input - timezone string, config, or instance
|
|
5930
6374
|
* @returns the resolved normal instance
|
|
5931
6375
|
*/ function yearWeekCodeDateTimezoneInstance(input) {
|
|
5932
|
-
|
|
5933
|
-
return normal;
|
|
6376
|
+
return input ? _instanceof(input, DateTimezoneUtcNormalInstance) ? input : dateTimezoneUtcNormal(input) : SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE;
|
|
5934
6377
|
}
|
|
5935
6378
|
function yearWeekCode(dateOrYear, inputWeek) {
|
|
5936
6379
|
return yearWeekCodeFactory({
|
|
@@ -5982,6 +6425,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
5982
6425
|
*
|
|
5983
6426
|
* @param dateRange - the range to compute week codes for
|
|
5984
6427
|
* @param dateRangeTimezone - the timezone context for accurate week boundary calculation
|
|
6428
|
+
* @returns an array of YearWeekCode values covering the range
|
|
5985
6429
|
*/ function yearWeekCodeForDateRangeInTimezone(dateRange, dateRangeTimezone) {
|
|
5986
6430
|
return yearWeekCodeForDateRangeFactory(yearWeekCodeFactory({
|
|
5987
6431
|
timezone: dateRangeTimezone
|
|
@@ -6014,6 +6458,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6014
6458
|
* Returns all {@link YearWeekCode} values for the calendar month containing the given date, using the system timezone.
|
|
6015
6459
|
*
|
|
6016
6460
|
* @param date - a date within the target month
|
|
6461
|
+
* @returns an array of YearWeekCode values for the month
|
|
6017
6462
|
*/ function yearWeekCodeForCalendarMonth(date) {
|
|
6018
6463
|
return yearWeekCodeForCalendarMonthFactory(yearWeekCodeFactory({
|
|
6019
6464
|
timezone: SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE
|
|
@@ -6057,8 +6502,8 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6057
6502
|
var utcYearDate = new Date(Date.UTC(pair.year, 0, 1, 0, 0, 0, 0));
|
|
6058
6503
|
var systemYearDate = normal.systemDateToBaseDate(utcYearDate); // convert to system before using system date functions
|
|
6059
6504
|
var date = dateFns.startOfWeek(dateFns.setWeek(systemYearDate, pair.week));
|
|
6060
|
-
|
|
6061
|
-
return
|
|
6505
|
+
// back to timezone
|
|
6506
|
+
return normal.targetDateToSystemDate(date);
|
|
6062
6507
|
};
|
|
6063
6508
|
}
|
|
6064
6509
|
/**
|
|
@@ -6112,10 +6557,10 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6112
6557
|
}
|
|
6113
6558
|
return yearWeekCode;
|
|
6114
6559
|
});
|
|
6115
|
-
var groups =
|
|
6560
|
+
var groups = _to_consumable_array$3(map.entries()).map(function(param) {
|
|
6116
6561
|
var _param = _sliced_to_array$2(param, 2), week = _param[0], _$items = _param[1];
|
|
6117
6562
|
return {
|
|
6118
|
-
week: week
|
|
6563
|
+
week: week !== null && week !== void 0 ? week : 0,
|
|
6119
6564
|
items: _$items
|
|
6120
6565
|
};
|
|
6121
6566
|
});
|
|
@@ -6154,8 +6599,7 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6154
6599
|
var normalInstance = startDateFactory._indexFactory._normalInstance;
|
|
6155
6600
|
return function(indexOrDate) {
|
|
6156
6601
|
var dateInSystemTimezone = normalInstance.systemDateToTargetDate(startDateFactory(indexOrDate));
|
|
6157
|
-
|
|
6158
|
-
return yearWeekCode;
|
|
6602
|
+
return yearWeekCodeFromDate(dateInSystemTimezone);
|
|
6159
6603
|
};
|
|
6160
6604
|
}
|
|
6161
6605
|
/**
|
|
@@ -6166,21 +6610,20 @@ function yearWeekCode(dateOrYear, inputWeek) {
|
|
|
6166
6610
|
*/ function dateCellIndexYearWeekCodeGroupFactory(config) {
|
|
6167
6611
|
var dateCellIndexReader = config.dateCellIndexReader, inputDateCellIndexYearWeekCodeFactory = config.dateCellIndexYearWeekCodeFactory;
|
|
6168
6612
|
var dateCellIndexYearWeekCode = typeof inputDateCellIndexYearWeekCodeFactory === 'function' ? inputDateCellIndexYearWeekCodeFactory : dateCellIndexYearWeekCodeFactory(inputDateCellIndexYearWeekCodeFactory);
|
|
6169
|
-
|
|
6613
|
+
return yearWeekCodeGroupFactory({
|
|
6170
6614
|
yearWeekCodeFactory: dateCellIndexYearWeekCode,
|
|
6171
6615
|
yearWeekCodeReader: dateCellIndexYearWeekCode,
|
|
6172
6616
|
dateReader: dateCellIndexReader
|
|
6173
6617
|
});
|
|
6174
|
-
return factory;
|
|
6175
6618
|
}
|
|
6176
6619
|
|
|
6177
|
-
function _array_like_to_array$
|
|
6620
|
+
function _array_like_to_array$4(arr, len) {
|
|
6178
6621
|
if (len == null || len > arr.length) len = arr.length;
|
|
6179
6622
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
6180
6623
|
return arr2;
|
|
6181
6624
|
}
|
|
6182
|
-
function _array_without_holes$
|
|
6183
|
-
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);
|
|
6184
6627
|
}
|
|
6185
6628
|
function _define_property$9(obj, key, value) {
|
|
6186
6629
|
if (key in obj) {
|
|
@@ -6195,10 +6638,10 @@ function _define_property$9(obj, key, value) {
|
|
|
6195
6638
|
}
|
|
6196
6639
|
return obj;
|
|
6197
6640
|
}
|
|
6198
|
-
function _iterable_to_array$
|
|
6641
|
+
function _iterable_to_array$2(iter) {
|
|
6199
6642
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
6200
6643
|
}
|
|
6201
|
-
function _non_iterable_spread$
|
|
6644
|
+
function _non_iterable_spread$2() {
|
|
6202
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.");
|
|
6203
6646
|
}
|
|
6204
6647
|
function _object_spread$7(target) {
|
|
@@ -6235,20 +6678,20 @@ function _object_spread_props$5(target, source) {
|
|
|
6235
6678
|
}
|
|
6236
6679
|
return target;
|
|
6237
6680
|
}
|
|
6238
|
-
function _to_consumable_array$
|
|
6239
|
-
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();
|
|
6240
6683
|
}
|
|
6241
6684
|
function _type_of$2(obj) {
|
|
6242
6685
|
"@swc/helpers - typeof";
|
|
6243
6686
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
6244
6687
|
}
|
|
6245
|
-
function _unsupported_iterable_to_array$
|
|
6688
|
+
function _unsupported_iterable_to_array$4(o, minLen) {
|
|
6246
6689
|
if (!o) return;
|
|
6247
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
6690
|
+
if (typeof o === "string") return _array_like_to_array$4(o, minLen);
|
|
6248
6691
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
6249
6692
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
6250
6693
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
6251
|
-
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);
|
|
6252
6695
|
}
|
|
6253
6696
|
/**
|
|
6254
6697
|
* Encodes days of the week as numeric codes for use in schedule filtering.
|
|
@@ -6313,7 +6756,7 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
6313
6756
|
* @param input - schedule day codes to convert (WEEKDAY/WEEKEND shorthand codes are expanded)
|
|
6314
6757
|
* @returns an EnabledDays object with boolean flags for each day
|
|
6315
6758
|
*/ function enabledDaysFromDateCellScheduleDayCodes(input) {
|
|
6316
|
-
var days = expandDateCellScheduleDayCodesToDayOfWeekSet(
|
|
6759
|
+
var days = expandDateCellScheduleDayCodesToDayOfWeekSet(_to_consumable_array$2(new Set(input)));
|
|
6317
6760
|
return util.enabledDaysFromDaysOfWeek(days);
|
|
6318
6761
|
}
|
|
6319
6762
|
/**
|
|
@@ -6390,7 +6833,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6390
6833
|
* simplifyDateCellScheduleDayCodes([2, 4]);
|
|
6391
6834
|
* // Returns [DateCellScheduleDayCode.MONDAY, DateCellScheduleDayCode.WEDNESDAY] // [2, 4]
|
|
6392
6835
|
* ```
|
|
6393
|
-
*/
|
|
6836
|
+
*/ // eslint-disable-next-line sonarjs/cognitive-complexity
|
|
6837
|
+
function simplifyDateCellScheduleDayCodes(codes) {
|
|
6394
6838
|
var codesSet = new Set(codes);
|
|
6395
6839
|
var result = [];
|
|
6396
6840
|
if (codesSet.size >= 2) {
|
|
@@ -6461,7 +6905,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6461
6905
|
* @param input - day codes to expand
|
|
6462
6906
|
* @returns sorted array of individual day codes (1-7 only, no shorthand)
|
|
6463
6907
|
*/ function expandDateCellScheduleDayCodes(input) {
|
|
6464
|
-
return
|
|
6908
|
+
return _to_consumable_array$2(expandDateCellScheduleDayCodesToDayCodesSet(input)).sort(util.sortNumbersAscendingFunction);
|
|
6465
6909
|
}
|
|
6466
6910
|
/**
|
|
6467
6911
|
* Expands the input DateCellScheduleDayCodesInput to a Set of individual DateCellScheduleDayCode values (1-7), expanding shorthand codes like WEEKDAY and WEEKEND.
|
|
@@ -6472,6 +6916,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6472
6916
|
var codes = rawDateCellScheduleDayCodes(input);
|
|
6473
6917
|
var days = new Set();
|
|
6474
6918
|
codes.forEach(function(code) {
|
|
6919
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
6475
6920
|
switch(code){
|
|
6476
6921
|
case 0:
|
|
6477
6922
|
break;
|
|
@@ -6497,9 +6942,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6497
6942
|
* @returns raw array of day codes with NONE values removed
|
|
6498
6943
|
*/ function rawDateCellScheduleDayCodes(input) {
|
|
6499
6944
|
var dayCodes;
|
|
6945
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
6500
6946
|
switch(typeof input === "undefined" ? "undefined" : _type_of$2(input)){
|
|
6501
6947
|
case 'string':
|
|
6502
|
-
dayCodes =
|
|
6948
|
+
dayCodes = _to_consumable_array$2(new Set(input)).map(function(x) {
|
|
6503
6949
|
return Number(x);
|
|
6504
6950
|
});
|
|
6505
6951
|
break;
|
|
@@ -6509,7 +6955,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6509
6955
|
];
|
|
6510
6956
|
break;
|
|
6511
6957
|
default:
|
|
6512
|
-
dayCodes =
|
|
6958
|
+
dayCodes = _to_consumable_array$2(input);
|
|
6513
6959
|
break;
|
|
6514
6960
|
}
|
|
6515
6961
|
return dayCodes.filter(function(x) {
|
|
@@ -6618,7 +7064,6 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6618
7064
|
var timezone = inputTimezone !== null && inputTimezone !== void 0 ? inputTimezone : requireCurrentTimezone(); // treat input as the current timezone
|
|
6619
7065
|
var normalInstance = dateTimezoneUtcNormal(timezone);
|
|
6620
7066
|
var start;
|
|
6621
|
-
var end;
|
|
6622
7067
|
// either start or startsAt is provided
|
|
6623
7068
|
if (inputStart != null) {
|
|
6624
7069
|
var startInSystemTimezone = normalInstance.systemDateToTargetDate(inputStart); // start needs to be in the system timezone normal before processing.
|
|
@@ -6635,7 +7080,7 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6635
7080
|
}
|
|
6636
7081
|
}
|
|
6637
7082
|
// set the end value
|
|
6638
|
-
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
|
|
6639
7084
|
return {
|
|
6640
7085
|
w: w,
|
|
6641
7086
|
ex: ex,
|
|
@@ -6837,11 +7282,12 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6837
7282
|
* filter(5); // false (Saturday Jan 11)
|
|
6838
7283
|
* ```
|
|
6839
7284
|
*/ function dateCellScheduleDateFilter(config) {
|
|
7285
|
+
var _ref;
|
|
6840
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;
|
|
6841
7287
|
var timezone = inputTimezone !== null && inputTimezone !== void 0 ? inputTimezone : requireCurrentTimezone(); // if the timezone is not provided, assume the startsAt is a system timezone normal.
|
|
6842
7288
|
var normalInstance = dateTimezoneUtcNormal(timezone);
|
|
6843
7289
|
// derive the startsAt time for the range. If not provided, defaults to inputStart, or midnight today in the target timezone.
|
|
6844
|
-
var startsAt = inputStartsAt
|
|
7290
|
+
var startsAt = (_ref = inputStartsAt !== null && inputStartsAt !== void 0 ? inputStartsAt : inputStart) !== null && _ref !== void 0 ? _ref : normalInstance.startOfDayInTargetTimezone();
|
|
6845
7291
|
var allowedDays = expandDateCellScheduleDayCodesToDayOfWeekSet(w);
|
|
6846
7292
|
var startsAtInSystem = normalInstance.systemDateToTargetDate(startsAt); // convert to the system date
|
|
6847
7293
|
var firstDateDay = dateFns.getDay(startsAtInSystem);
|
|
@@ -6867,15 +7313,13 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6867
7313
|
var excludedIndexes = new Set(config.ex);
|
|
6868
7314
|
var fn = function fn(input) {
|
|
6869
7315
|
var i;
|
|
6870
|
-
var day;
|
|
6871
7316
|
if (typeof input === 'number') {
|
|
6872
7317
|
i = input;
|
|
6873
7318
|
} else {
|
|
6874
7319
|
i = _dateCellTimingRelativeIndexFactory(input);
|
|
6875
7320
|
}
|
|
6876
|
-
day = dayForIndex(i);
|
|
6877
|
-
|
|
6878
|
-
return result;
|
|
7321
|
+
var day = dayForIndex(i);
|
|
7322
|
+
return i >= minAllowedIndex && i <= maxAllowedIndex && allowedDays.has(day) && !excludedIndexes.has(i) || includedIndexes.has(i);
|
|
6879
7323
|
};
|
|
6880
7324
|
fn._dateCellTimingRelativeIndexFactory = _dateCellTimingRelativeIndexFactory;
|
|
6881
7325
|
return fn;
|
|
@@ -6929,6 +7373,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6929
7373
|
* Creates a DateCellScheduleDateCellTimingFilter that tests whether a DateCell block's index is allowed by the schedule within the given timing.
|
|
6930
7374
|
*
|
|
6931
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
|
|
6932
7378
|
* @returns a decision function returning true for allowed blocks
|
|
6933
7379
|
*/ function dateCellScheduleDateCellTimingFilter(param) {
|
|
6934
7380
|
var timing = param.timing, schedule = param.schedule;
|
|
@@ -6952,7 +7398,6 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6952
7398
|
* @returns an expansion factory that converts DateCellRange arrays into filtered DateCellDurationSpan arrays
|
|
6953
7399
|
*/ function expandDateCellScheduleFactory(config) {
|
|
6954
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;
|
|
6955
|
-
var durationSpanFilter;
|
|
6956
7401
|
var durationSpanFilters = [];
|
|
6957
7402
|
if (inputDurationSpanFilter) {
|
|
6958
7403
|
durationSpanFilters.push(inputDurationSpanFilter);
|
|
@@ -6969,14 +7414,13 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
6969
7414
|
durationSpanFilters.push(dateCellDurationSpanHasNotEndedFilterFunction(now));
|
|
6970
7415
|
}
|
|
6971
7416
|
}
|
|
6972
|
-
durationSpanFilter = util.mergeFilterFunctions.apply(void 0, _to_consumable_array$
|
|
6973
|
-
|
|
7417
|
+
var durationSpanFilter = util.mergeFilterFunctions.apply(void 0, _to_consumable_array$2(durationSpanFilters));
|
|
7418
|
+
return dateCellTimingExpansionFactory({
|
|
6974
7419
|
timing: config.timing,
|
|
6975
7420
|
filter: util.invertFilter(dateCellScheduleDateCellTimingFilter(config), invertSchedule),
|
|
6976
7421
|
durationSpanFilter: durationSpanFilter,
|
|
6977
7422
|
maxDateCellsToReturn: maxDateCellsToReturn
|
|
6978
7423
|
});
|
|
6979
|
-
return expansionFactory;
|
|
6980
7424
|
}
|
|
6981
7425
|
/**
|
|
6982
7426
|
* Expands a DateCellTiming and DateCellSchedule into concrete DateCellDurationSpan values representing each active block in the event.
|
|
@@ -7062,16 +7506,155 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7062
7506
|
});
|
|
7063
7507
|
}
|
|
7064
7508
|
|
|
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;
|
|
7536
|
+
}
|
|
7537
|
+
/**
|
|
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
|
+
}
|
|
7065
7644
|
/**
|
|
7066
7645
|
* Returns all recognized IANA timezone strings, including the explicit UTC entry.
|
|
7067
7646
|
*
|
|
7647
|
+
* @returns all known IANA timezone strings plus UTC
|
|
7648
|
+
*
|
|
7068
7649
|
* @example
|
|
7069
7650
|
* ```ts
|
|
7070
7651
|
* const zones = allTimezoneStrings();
|
|
7071
7652
|
* // ['Africa/Abidjan', ..., 'UTC']
|
|
7072
7653
|
* ```
|
|
7073
7654
|
*/ function allTimezoneStrings() {
|
|
7074
|
-
return tzdb.timeZonesNames.concat(
|
|
7655
|
+
return _to_consumable_array$1(tzdb.timeZonesNames).concat([
|
|
7656
|
+
util.UTC_TIMEZONE_STRING
|
|
7657
|
+
]);
|
|
7075
7658
|
}
|
|
7076
7659
|
/**
|
|
7077
7660
|
* Lazily-computed set of all known timezone strings for O(1) membership checks.
|
|
@@ -7097,6 +7680,8 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7097
7680
|
/**
|
|
7098
7681
|
* Returns the {@link TimezoneInfo} for the current system timezone, falling back to UTC.
|
|
7099
7682
|
*
|
|
7683
|
+
* @returns timezone info for the current system timezone
|
|
7684
|
+
*
|
|
7100
7685
|
* @example
|
|
7101
7686
|
* ```ts
|
|
7102
7687
|
* const info = timezoneInfoForSystem();
|
|
@@ -7112,6 +7697,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7112
7697
|
* The date matters because abbreviations change with DST transitions.
|
|
7113
7698
|
* Returns `"UKNOWN"` if no timezone is provided.
|
|
7114
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
|
+
*
|
|
7115
7704
|
* @example
|
|
7116
7705
|
* ```ts
|
|
7117
7706
|
* getTimezoneAbbreviation('America/New_York'); // 'EST' or 'EDT'
|
|
@@ -7125,6 +7714,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7125
7714
|
*
|
|
7126
7715
|
* Returns `"Unknown Timezone"` if no timezone is provided.
|
|
7127
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
|
+
*
|
|
7128
7721
|
* @example
|
|
7129
7722
|
* ```ts
|
|
7130
7723
|
* getTimezoneLongName('America/New_York'); // 'Eastern Standard Time'
|
|
@@ -7136,6 +7729,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7136
7729
|
/**
|
|
7137
7730
|
* Builds a {@link TimezoneInfo} for the given timezone, computing abbreviation and search variants.
|
|
7138
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
|
+
*
|
|
7139
7736
|
* @example
|
|
7140
7737
|
* ```ts
|
|
7141
7738
|
* const info = timezoneStringToTimezoneInfo('America/Chicago');
|
|
@@ -7145,14 +7742,13 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7145
7742
|
*/ function timezoneStringToTimezoneInfo(timezone) {
|
|
7146
7743
|
var date = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Date();
|
|
7147
7744
|
var abbreviation = getTimezoneAbbreviation(timezone, date);
|
|
7148
|
-
|
|
7745
|
+
return {
|
|
7149
7746
|
timezone: timezone,
|
|
7150
7747
|
search: timezoneStringToSearchableString(timezone),
|
|
7151
7748
|
lowercase: timezone.toLowerCase(),
|
|
7152
7749
|
abbreviation: abbreviation,
|
|
7153
7750
|
lowercaseAbbreviation: abbreviation.toLowerCase()
|
|
7154
7751
|
};
|
|
7155
|
-
return result;
|
|
7156
7752
|
}
|
|
7157
7753
|
/**
|
|
7158
7754
|
* Filters timezone infos by a search string, matching against the searchable name,
|
|
@@ -7160,6 +7756,10 @@ var DATE_CELL_SCHEDULE_ENCODED_WEEK_REGEX = /^[0-9]{0,9}$/;
|
|
|
7160
7756
|
*
|
|
7161
7757
|
* For queries longer than 2 characters, substring matching on the searchable name is also used.
|
|
7162
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
|
+
*
|
|
7163
7763
|
* @example
|
|
7164
7764
|
* ```ts
|
|
7165
7765
|
* const results = searchTimezoneInfos('eastern', allTimezoneInfos());
|
|
@@ -7182,6 +7782,9 @@ var timezoneStringToSearchableStringReplace = util.replaceStringsFunction({
|
|
|
7182
7782
|
*
|
|
7183
7783
|
* Replaces `/` and `_` with spaces (e.g., `"America/New_York"` becomes `"america new york"`).
|
|
7184
7784
|
*
|
|
7785
|
+
* @param timezone - the IANA timezone string to convert
|
|
7786
|
+
* @returns the searchable lowercase string
|
|
7787
|
+
*
|
|
7185
7788
|
* @example
|
|
7186
7789
|
* ```ts
|
|
7187
7790
|
* timezoneStringToSearchableString('America/New_York'); // 'america new york'
|
|
@@ -7194,6 +7797,9 @@ var timezoneStringToSearchableStringReplace = util.replaceStringsFunction({
|
|
|
7194
7797
|
*
|
|
7195
7798
|
* Uses the cached set from {@link allKnownTimezoneStrings} for O(1) lookup.
|
|
7196
7799
|
*
|
|
7800
|
+
* @param input - the string to check
|
|
7801
|
+
* @returns whether the input is a known timezone
|
|
7802
|
+
*
|
|
7197
7803
|
* @example
|
|
7198
7804
|
* ```ts
|
|
7199
7805
|
* isKnownTimezone('America/New_York'); // true
|
|
@@ -7203,116 +7809,6 @@ var timezoneStringToSearchableStringReplace = util.replaceStringsFunction({
|
|
|
7203
7809
|
return allKnownTimezoneStrings().has(input);
|
|
7204
7810
|
}
|
|
7205
7811
|
|
|
7206
|
-
function _define_property$8(obj, key, value) {
|
|
7207
|
-
if (key in obj) {
|
|
7208
|
-
Object.defineProperty(obj, key, {
|
|
7209
|
-
value: value,
|
|
7210
|
-
enumerable: true,
|
|
7211
|
-
configurable: true,
|
|
7212
|
-
writable: true
|
|
7213
|
-
});
|
|
7214
|
-
} else {
|
|
7215
|
-
obj[key] = value;
|
|
7216
|
-
}
|
|
7217
|
-
return obj;
|
|
7218
|
-
}
|
|
7219
|
-
function _object_spread$6(target) {
|
|
7220
|
-
for(var i = 1; i < arguments.length; i++){
|
|
7221
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
7222
|
-
var ownKeys = Object.keys(source);
|
|
7223
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
7224
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
7225
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
7226
|
-
}));
|
|
7227
|
-
}
|
|
7228
|
-
ownKeys.forEach(function(key) {
|
|
7229
|
-
_define_property$8(target, key, source[key]);
|
|
7230
|
-
});
|
|
7231
|
-
}
|
|
7232
|
-
return target;
|
|
7233
|
-
}
|
|
7234
|
-
/**
|
|
7235
|
-
* Distinguishes between time-based calendar events and all-day/multi-day events.
|
|
7236
|
-
*/ exports.CalendarDateType = void 0;
|
|
7237
|
-
(function(CalendarDateType) {
|
|
7238
|
-
/**
|
|
7239
|
-
* Event starts at a specific time and lasts for a certain duration.
|
|
7240
|
-
*/ CalendarDateType["TIME"] = "time";
|
|
7241
|
-
/**
|
|
7242
|
-
* Event is specifically for a number of days. Duration is still tracked in minutes.
|
|
7243
|
-
*/ CalendarDateType["DAYS"] = "days";
|
|
7244
|
-
})(exports.CalendarDateType || (exports.CalendarDateType = {}));
|
|
7245
|
-
/**
|
|
7246
|
-
* Creates a {@link CalendarDateFactory} that produces all-day calendar events with timezone-aware start times.
|
|
7247
|
-
*
|
|
7248
|
-
* The factory converts an ISO 8601 day string to a UTC date, then applies timezone normalization
|
|
7249
|
-
* so the resulting `startsAt` represents the correct moment for the target timezone.
|
|
7250
|
-
*
|
|
7251
|
-
* @param config - optional timezone configuration
|
|
7252
|
-
* @returns a factory function that creates CalendarDate objects
|
|
7253
|
-
*
|
|
7254
|
-
* @example
|
|
7255
|
-
* ```ts
|
|
7256
|
-
* const factory = calendarDateFactory({ timezone: 'America/Denver' });
|
|
7257
|
-
* const event = factory('2024-01-15', 3);
|
|
7258
|
-
* // event.type === CalendarDateType.DAYS
|
|
7259
|
-
* // event.duration === daysToMinutes(3)
|
|
7260
|
-
* ```
|
|
7261
|
-
*/ function calendarDateFactory(config) {
|
|
7262
|
-
var normalConfig = (config === null || config === void 0 ? void 0 : config.timezone) === undefined ? {
|
|
7263
|
-
useSystemTimezone: true
|
|
7264
|
-
} : {
|
|
7265
|
-
timezone: config.timezone ? config.timezone : undefined
|
|
7266
|
-
};
|
|
7267
|
-
var normal = dateTimezoneUtcNormal(normalConfig);
|
|
7268
|
-
return function(day, days) {
|
|
7269
|
-
var date = util.parseISO8601DayStringToUTCDate(day);
|
|
7270
|
-
var startsAt = normal.targetDateToBaseDate(date);
|
|
7271
|
-
return {
|
|
7272
|
-
type: exports.CalendarDateType.DAYS,
|
|
7273
|
-
startsAt: startsAt,
|
|
7274
|
-
duration: daysToMinutes(days)
|
|
7275
|
-
};
|
|
7276
|
-
};
|
|
7277
|
-
}
|
|
7278
|
-
/**
|
|
7279
|
-
* Convenience function that creates a single all-day {@link CalendarDate} with optional timezone.
|
|
7280
|
-
*
|
|
7281
|
-
* Shorthand for creating a factory and immediately invoking it.
|
|
7282
|
-
*
|
|
7283
|
-
* @param day - ISO 8601 day string (e.g. '2024-01-15')
|
|
7284
|
-
* @param days - number of days the event spans
|
|
7285
|
-
* @param timezone - IANA timezone string, false for UTC, or undefined for system timezone
|
|
7286
|
-
* @returns a CalendarDate with type DAYS
|
|
7287
|
-
*
|
|
7288
|
-
* @example
|
|
7289
|
-
* ```ts
|
|
7290
|
-
* const event = calendarDate('2024-01-15', 1, 'America/Denver');
|
|
7291
|
-
* // event.type === CalendarDateType.DAYS
|
|
7292
|
-
* ```
|
|
7293
|
-
*/ function calendarDate(day, days, timezone) {
|
|
7294
|
-
return calendarDateFactory({
|
|
7295
|
-
timezone: timezone
|
|
7296
|
-
})(day, days);
|
|
7297
|
-
}
|
|
7298
|
-
/**
|
|
7299
|
-
* Wraps an existing {@link DateDurationSpan} as a time-based {@link CalendarDate}.
|
|
7300
|
-
*
|
|
7301
|
-
* @param dateDurationSpan - the duration span to wrap
|
|
7302
|
-
* @returns a CalendarDate with type TIME
|
|
7303
|
-
*
|
|
7304
|
-
* @example
|
|
7305
|
-
* ```ts
|
|
7306
|
-
* const span: DateDurationSpan = { startsAt: new Date(), duration: 60 };
|
|
7307
|
-
* const event = calendarDateForDateDurationSpan(span);
|
|
7308
|
-
* // event.type === CalendarDateType.TIME
|
|
7309
|
-
* ```
|
|
7310
|
-
*/ function calendarDateForDateDurationSpan(dateDurationSpan) {
|
|
7311
|
-
return _object_spread$6({
|
|
7312
|
-
type: exports.CalendarDateType.TIME
|
|
7313
|
-
}, dateDurationSpan);
|
|
7314
|
-
}
|
|
7315
|
-
|
|
7316
7812
|
function _array_like_to_array$2(arr, len) {
|
|
7317
7813
|
if (len == null || len > arr.length) len = arr.length;
|
|
7318
7814
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -7352,7 +7848,7 @@ var _type, _type1;
|
|
|
7352
7848
|
* const result = knownTimezoneType('America/Denver');
|
|
7353
7849
|
* ```
|
|
7354
7850
|
*/ var knownTimezoneType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
7355
|
-
return
|
|
7851
|
+
return isKnownTimezone(val) || ctx.mustBe('a known timezone');
|
|
7356
7852
|
});
|
|
7357
7853
|
// MARK: DateDurationSpan
|
|
7358
7854
|
/**
|
|
@@ -7466,21 +7962,21 @@ var _type, _type1;
|
|
|
7466
7962
|
* Accepts both Date objects and date strings (parsed via `string.date.parse`), then validates the resulting timing
|
|
7467
7963
|
* using {@link isValidDateCellTiming}.
|
|
7468
7964
|
*/ var validDateCellTimingType = dateCellTimingType.narrow(function(val, ctx) {
|
|
7469
|
-
return
|
|
7965
|
+
return isValidDateCellTiming(val) || ctx.mustBe('a valid DateCellTiming');
|
|
7470
7966
|
});
|
|
7471
7967
|
/**
|
|
7472
7968
|
* ArkType DTO schema that validates a value is a valid {@link DateCellRange} (non-negative indexes, `to >= i`).
|
|
7473
7969
|
*
|
|
7474
7970
|
* Validates cell range data from JSON/DTO input.
|
|
7475
7971
|
*/ var validDateCellRangeType = dateCellRangeType.narrow(function(val, ctx) {
|
|
7476
|
-
return
|
|
7972
|
+
return isValidDateCellRange(val) || ctx.mustBe('a valid DateCellRange');
|
|
7477
7973
|
});
|
|
7478
7974
|
/**
|
|
7479
7975
|
* ArkType DTO schema that validates a value is a sorted array of non-overlapping {@link DateCellRange} values.
|
|
7480
7976
|
*
|
|
7481
7977
|
* Validates cell range series data from JSON/DTO input.
|
|
7482
7978
|
*/ var validDateCellRangeSeriesType = arktype.type(dateCellRangeType.array()).narrow(function(val, ctx) {
|
|
7483
|
-
return
|
|
7979
|
+
return isValidDateCellRangeSeries(val) || ctx.mustBe('a valid DateCellRange series with items sorted in ascending order and no repeat indexes');
|
|
7484
7980
|
});
|
|
7485
7981
|
|
|
7486
7982
|
function _assert_this_initialized$1(self) {
|
|
@@ -7760,7 +8256,7 @@ function _object_spread_props$4(target, source) {
|
|
|
7760
8256
|
logicalDate = 'now';
|
|
7761
8257
|
}
|
|
7762
8258
|
var intervalPeriod = period !== null && period !== void 0 ? period : util.MS_IN_SECOND;
|
|
7763
|
-
var factory = inputFactory ? inputFactory : util.protectedFactory(logicalDateStringCodeDateFactory(logicalDate));
|
|
8259
|
+
var factory = inputFactory !== null && inputFactory !== void 0 ? inputFactory : util.protectedFactory(logicalDateStringCodeDateFactory(logicalDate));
|
|
7764
8260
|
var obs = rxjs.interval(intervalPeriod, scheduler).pipe(rxjs.startWith(-1), rxjs.map(factory));
|
|
7765
8261
|
if (emitAll !== true) {
|
|
7766
8262
|
obs = obs.pipe(rxjs.distinctUntilChanged(isSameDate));
|
|
@@ -7852,7 +8348,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7852
8348
|
{
|
|
7853
8349
|
key: "instant",
|
|
7854
8350
|
get: function get() {
|
|
7855
|
-
|
|
8351
|
+
var _this__config_instant;
|
|
8352
|
+
return (_this__config_instant = this._config.instant) !== null && _this__config_instant !== void 0 ? _this__config_instant : 'now';
|
|
7856
8353
|
}
|
|
7857
8354
|
},
|
|
7858
8355
|
{
|
|
@@ -7897,10 +8394,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7897
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;
|
|
7898
8395
|
var isPast = limits.isPast, max = limits.max;
|
|
7899
8396
|
var limit = max;
|
|
7900
|
-
if (typeof max !== 'string' && isPast) {
|
|
7901
|
-
|
|
7902
|
-
limit = util.DATE_NOW_VALUE;
|
|
7903
|
-
}
|
|
8397
|
+
if (typeof max !== 'string' && isPast && (!max || dateFns.isBefore(max, instant))) {
|
|
8398
|
+
limit = util.DATE_NOW_VALUE;
|
|
7904
8399
|
}
|
|
7905
8400
|
return limit;
|
|
7906
8401
|
}
|
|
@@ -7915,6 +8410,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7915
8410
|
* const limiter = new LimitDateTimeInstance({ limits: { isFuture: true } });
|
|
7916
8411
|
* const range = limiter.dateRange(); // { start: <now>, end: undefined }
|
|
7917
8412
|
* ```
|
|
8413
|
+
*
|
|
8414
|
+
* @returns A partial {@link DateRange} with `start` and/or `end` derived from the limits.
|
|
7918
8415
|
*/ key: "dateRange",
|
|
7919
8416
|
value: function dateRange() {
|
|
7920
8417
|
var _this__config = this._config, _this__config_instant = _this__config.instant, instant = _this__config_instant === void 0 ? new Date() : _this__config_instant;
|
|
@@ -7927,6 +8424,7 @@ function _define_property$6(obj, key, value) {
|
|
|
7927
8424
|
* like "now" or relative future offsets to resolve against the given moment.
|
|
7928
8425
|
*
|
|
7929
8426
|
* @param instant - The reference point in time for resolving dynamic limits.
|
|
8427
|
+
* @returns A partial {@link DateRange} resolved against the given instant.
|
|
7930
8428
|
*/ key: "dateRangeForInstant",
|
|
7931
8429
|
value: function dateRangeForInstant(instant) {
|
|
7932
8430
|
var _this = this, min = _this.min, max = _this.max;
|
|
@@ -7950,6 +8448,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7950
8448
|
* });
|
|
7951
8449
|
* const safe = limiter.clamp(new Date()); // at least 30 minutes from now
|
|
7952
8450
|
* ```
|
|
8451
|
+
*
|
|
8452
|
+
* @returns The clamped date within the allowed range.
|
|
7953
8453
|
*/ key: "clamp",
|
|
7954
8454
|
value: function clamp(date) {
|
|
7955
8455
|
var result = date;
|
|
@@ -7987,6 +8487,8 @@ function _define_property$6(obj, key, value) {
|
|
|
7987
8487
|
* const clamped = limiter.clampDateRange({ start: pastDate, end: futureDate });
|
|
7988
8488
|
* // clamped.start will be at least now
|
|
7989
8489
|
* ```
|
|
8490
|
+
*
|
|
8491
|
+
* @returns The date range clamped to the allowed limits.
|
|
7990
8492
|
*/ key: "clampDateRange",
|
|
7991
8493
|
value: function clampDateRange(dateRange) {
|
|
7992
8494
|
return clampDateRangeToDateRange(dateRange, this.dateRange());
|
|
@@ -8008,6 +8510,8 @@ function _define_property$6(obj, key, value) {
|
|
|
8008
8510
|
* });
|
|
8009
8511
|
* const clamped = limiter.clamp(someDate);
|
|
8010
8512
|
* ```
|
|
8513
|
+
*
|
|
8514
|
+
* @returns A new {@link LimitDateTimeInstance}.
|
|
8011
8515
|
*/ function limitDateTimeInstance(config) {
|
|
8012
8516
|
return new LimitDateTimeInstance(config);
|
|
8013
8517
|
}
|
|
@@ -8099,14 +8603,14 @@ function _object_spread_props$3(target, source) {
|
|
|
8099
8603
|
function DateTimeMinuteInstance() {
|
|
8100
8604
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, dateOverride = arguments.length > 1 ? arguments[1] : void 0;
|
|
8101
8605
|
_class_call_check$5(this, DateTimeMinuteInstance);
|
|
8102
|
-
var _config_step;
|
|
8606
|
+
var _ref, _config_step;
|
|
8103
8607
|
_define_property$5(this, "_config", void 0);
|
|
8104
8608
|
_define_property$5(this, "_date", void 0);
|
|
8105
8609
|
_define_property$5(this, "_step", void 0);
|
|
8106
8610
|
_define_property$5(this, "_limit", void 0);
|
|
8107
8611
|
_define_property$5(this, "_dateFilter", void 0);
|
|
8108
8612
|
this._config = config;
|
|
8109
|
-
this._date = (dateOverride
|
|
8613
|
+
this._date = (_ref = dateOverride !== null && dateOverride !== void 0 ? dateOverride : config.date) !== null && _ref !== void 0 ? _ref : new Date();
|
|
8110
8614
|
this._step = (_config_step = config.step) !== null && _config_step !== void 0 ? _config_step : 1;
|
|
8111
8615
|
this._limit = new LimitDateTimeInstance(config);
|
|
8112
8616
|
this._dateFilter = config.schedule ? dateCellScheduleDateFilter(config.schedule) : undefined;
|
|
@@ -8140,6 +8644,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8140
8644
|
key: "limitInstance",
|
|
8141
8645
|
get: /**
|
|
8142
8646
|
* Returns the LimitDateTimeInstance. This does not take the schedule into consideration.
|
|
8647
|
+
*
|
|
8648
|
+
* @returns The underlying {@link LimitDateTimeInstance}.
|
|
8143
8649
|
*/ function get() {
|
|
8144
8650
|
return this._limit;
|
|
8145
8651
|
}
|
|
@@ -8162,6 +8668,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8162
8668
|
* // true if June 15 is a weekday and overlaps the limit range
|
|
8163
8669
|
* instance.dateDayContainsValidDateValue(new Date('2024-06-15'));
|
|
8164
8670
|
* ```
|
|
8671
|
+
*
|
|
8672
|
+
* @returns `true` if the day contains at least one valid date/time value.
|
|
8165
8673
|
*/ key: "dateDayContainsValidDateValue",
|
|
8166
8674
|
value: function dateDayContainsValidDateValue(date) {
|
|
8167
8675
|
var isInSchedule = this.dateIsInSchedule(date);
|
|
@@ -8200,6 +8708,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8200
8708
|
*
|
|
8201
8709
|
* instance.isInValidRange(new Date('2024-06-15T10:00:00')); // true if a weekday
|
|
8202
8710
|
* ```
|
|
8711
|
+
*
|
|
8712
|
+
* @returns `true` if the date is within the min/max limits and on a scheduled day.
|
|
8203
8713
|
*/ key: "isInValidRange",
|
|
8204
8714
|
value: function isInValidRange(date) {
|
|
8205
8715
|
var result = this.getStatus(date);
|
|
@@ -8222,6 +8732,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8222
8732
|
*
|
|
8223
8733
|
* instance.isValid(new Date('2099-03-15T10:00:00')); // true if all constraints pass
|
|
8224
8734
|
* ```
|
|
8735
|
+
*
|
|
8736
|
+
* @returns `true` if the date passes all configured constraints.
|
|
8225
8737
|
*/ key: "isValid",
|
|
8226
8738
|
value: function isValid(date) {
|
|
8227
8739
|
var result = this.getStatus(date);
|
|
@@ -8245,6 +8757,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8245
8757
|
* // status.isAfterMinimum === false (before min)
|
|
8246
8758
|
* // status.inFuture === false (if date is in the past)
|
|
8247
8759
|
* ```
|
|
8760
|
+
*
|
|
8761
|
+
* @returns A {@link DateTimeMinuteDateStatus} snapshot for the given date.
|
|
8248
8762
|
*/ key: "getStatus",
|
|
8249
8763
|
value: function getStatus() {
|
|
8250
8764
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date;
|
|
@@ -8303,6 +8817,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8303
8817
|
*
|
|
8304
8818
|
* instance.dateIsInSchedule(new Date('2024-06-15')); // true (Saturday = false)
|
|
8305
8819
|
* ```
|
|
8820
|
+
*
|
|
8821
|
+
* @returns `true` if the date is on a scheduled day or no schedule is configured.
|
|
8306
8822
|
*/ key: "dateIsInSchedule",
|
|
8307
8823
|
value: function dateIsInSchedule() {
|
|
8308
8824
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date;
|
|
@@ -8327,6 +8843,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8327
8843
|
* instance.round({ roundToSteps: true }); // 2024-06-15T09:00:00
|
|
8328
8844
|
* instance.round({ roundToSteps: true, roundToBound: true }); // clamped to min if below
|
|
8329
8845
|
* ```
|
|
8846
|
+
*
|
|
8847
|
+
* @returns The rounded (and optionally clamped) date.
|
|
8330
8848
|
*/ key: "round",
|
|
8331
8849
|
value: function round(round) {
|
|
8332
8850
|
var _round_step;
|
|
@@ -8356,6 +8874,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8356
8874
|
*
|
|
8357
8875
|
* instance.clamp(new Date('2024-05-25')); // clamped to min, then nearest weekday
|
|
8358
8876
|
* ```
|
|
8877
|
+
*
|
|
8878
|
+
* @returns The date clamped to both the limits and the schedule.
|
|
8359
8879
|
*/ key: "clamp",
|
|
8360
8880
|
value: function clamp() {
|
|
8361
8881
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date, maxClampDistance = arguments.length > 1 ? arguments[1] : void 0;
|
|
@@ -8376,6 +8896,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8376
8896
|
*
|
|
8377
8897
|
* instance.clampToLimit(new Date('2025-03-01')); // returns max (2024-12-31)
|
|
8378
8898
|
* ```
|
|
8899
|
+
*
|
|
8900
|
+
* @returns The date clamped to the configured min/max limits.
|
|
8379
8901
|
*/ key: "clampToLimit",
|
|
8380
8902
|
value: function clampToLimit() {
|
|
8381
8903
|
var date = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.date;
|
|
@@ -8400,7 +8922,10 @@ function _object_spread_props$3(target, source) {
|
|
|
8400
8922
|
* // If June 15, 2024 is a Saturday, returns the next Monday
|
|
8401
8923
|
* instance.clampToSchedule(new Date('2024-06-15'));
|
|
8402
8924
|
* ```
|
|
8403
|
-
|
|
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",
|
|
8404
8929
|
value: function clampToSchedule() {
|
|
8405
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;
|
|
8406
8931
|
var nextAvailableDate;
|
|
@@ -8434,9 +8959,7 @@ function _object_spread_props$3(target, source) {
|
|
|
8434
8959
|
}
|
|
8435
8960
|
}
|
|
8436
8961
|
// set a default from the given input if applicable
|
|
8437
|
-
|
|
8438
|
-
nextAvailableDate = this.clampToLimit(date);
|
|
8439
|
-
}
|
|
8962
|
+
nextAvailableDate !== null && nextAvailableDate !== void 0 ? nextAvailableDate : nextAvailableDate = this.clampToLimit(date);
|
|
8440
8963
|
}
|
|
8441
8964
|
}
|
|
8442
8965
|
return nextAvailableDate !== null && nextAvailableDate !== void 0 ? nextAvailableDate : date;
|
|
@@ -8461,6 +8984,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8461
8984
|
* // Find the next weekday after a Saturday
|
|
8462
8985
|
* instance.findNextAvailableDayInSchedule(new Date('2024-06-15'), 'future');
|
|
8463
8986
|
* ```
|
|
8987
|
+
*
|
|
8988
|
+
* @returns The next valid schedule date, or `undefined` if none found within the max distance.
|
|
8464
8989
|
*/ key: "findNextAvailableDayInSchedule",
|
|
8465
8990
|
value: function findNextAvailableDayInSchedule(date, direction) {
|
|
8466
8991
|
var maxDistance = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 370;
|
|
@@ -8496,6 +9021,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8496
9021
|
* instance.isInSchedule(new Date('2024-06-17')); // true (Monday)
|
|
8497
9022
|
* instance.isInSchedule(new Date('2024-06-16')); // false (Sunday)
|
|
8498
9023
|
* ```
|
|
9024
|
+
*
|
|
9025
|
+
* @returns `true` if the date is on a scheduled day or no schedule is configured.
|
|
8499
9026
|
*/ key: "isInSchedule",
|
|
8500
9027
|
value: function isInSchedule(date) {
|
|
8501
9028
|
return this._dateFilter ? this._dateFilter(date) : true;
|
|
@@ -8555,6 +9082,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8555
9082
|
*
|
|
8556
9083
|
* isValid(new Date('2024-06-17T10:00:00')); // true if future weekday after min
|
|
8557
9084
|
* ```
|
|
9085
|
+
*
|
|
9086
|
+
* @returns A decision function that returns `true` for valid dates.
|
|
8558
9087
|
*/ function dateTimeMinuteDecisionFunction(config) {
|
|
8559
9088
|
var instance = new DateTimeMinuteInstance(config, null);
|
|
8560
9089
|
return function(date) {
|
|
@@ -8587,6 +9116,8 @@ function _object_spread_props$3(target, source) {
|
|
|
8587
9116
|
* // true only if both 00:00 and 23:59 on June 15 pass all constraints
|
|
8588
9117
|
* isFullDayValid(new Date('2024-06-15'));
|
|
8589
9118
|
* ```
|
|
9119
|
+
*
|
|
9120
|
+
* @returns A decision function that returns `true` for valid days.
|
|
8590
9121
|
*/ function dateTimeMinuteWholeDayDecisionFunction(config) {
|
|
8591
9122
|
var startAndEndOfDayMustBeValid = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
8592
9123
|
var instance = new DateTimeMinuteInstance(config, null);
|
|
@@ -8671,6 +9202,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8671
9202
|
* guaranteeing that `raw` and `result` are defined.
|
|
8672
9203
|
*
|
|
8673
9204
|
* @param result - The parse result to check.
|
|
9205
|
+
* @returns `true` if the result is valid, narrowing the type to {@link ValidDateFromTimestringResult}.
|
|
8674
9206
|
*
|
|
8675
9207
|
* @example
|
|
8676
9208
|
* ```ts
|
|
@@ -8714,6 +9246,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8714
9246
|
*
|
|
8715
9247
|
* @param date - The date to check. Defaults to now.
|
|
8716
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.
|
|
8717
9250
|
*
|
|
8718
9251
|
* @example
|
|
8719
9252
|
* ```ts
|
|
@@ -8733,6 +9266,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8733
9266
|
*
|
|
8734
9267
|
* @param date - The date to format.
|
|
8735
9268
|
* @param timezone - Overrides the instance's configured timezone for this call.
|
|
9269
|
+
* @returns The formatted time string (e.g., "1:30PM").
|
|
8736
9270
|
*
|
|
8737
9271
|
* @example
|
|
8738
9272
|
* ```ts
|
|
@@ -8827,18 +9361,35 @@ function _object_spread_props$2(target, source) {
|
|
|
8827
9361
|
'h:mm',
|
|
8828
9362
|
'HH:mm' // 01:20
|
|
8829
9363
|
];
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
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
|
+
}
|
|
8836
9387
|
}
|
|
8837
9388
|
}
|
|
8838
9389
|
var removedPm = false;
|
|
8839
9390
|
function removeAmPm(inputString) {
|
|
8840
9391
|
inputString = inputString.toLowerCase();
|
|
8841
|
-
removedPm = inputString.
|
|
9392
|
+
removedPm = inputString.includes('pm');
|
|
8842
9393
|
inputString = inputString.replace(/am|pm/g, '');
|
|
8843
9394
|
return inputString;
|
|
8844
9395
|
}
|
|
@@ -8870,6 +9421,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8870
9421
|
case 6:
|
|
8871
9422
|
// 1212AM
|
|
8872
9423
|
removeAmPm(input);
|
|
9424
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- removedPm is set via closure side effect in removeAmPm()
|
|
8873
9425
|
if (removedPm) {
|
|
8874
9426
|
removedPm = input[0] !== '2'; // If 2, ignore the PM part.
|
|
8875
9427
|
}
|
|
@@ -8938,6 +9490,8 @@ function _object_spread_props$2(target, source) {
|
|
|
8938
9490
|
/**
|
|
8939
9491
|
* Creates a {@link DateTimeUtilityInstance} configured for UTC.
|
|
8940
9492
|
*
|
|
9493
|
+
* @returns A new {@link DateTimeUtilityInstance} using the UTC timezone.
|
|
9494
|
+
*
|
|
8941
9495
|
* @example
|
|
8942
9496
|
* ```ts
|
|
8943
9497
|
* const utcInstance = dateTimeInstanceUtc();
|
|
@@ -8951,6 +9505,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8951
9505
|
* Defaults to UTC when no timezone is provided.
|
|
8952
9506
|
*
|
|
8953
9507
|
* @param timezone - The IANA timezone identifier (e.g., 'America/New_York').
|
|
9508
|
+
* @returns A new {@link DateTimeUtilityInstance} for the specified timezone.
|
|
8954
9509
|
*
|
|
8955
9510
|
* @example
|
|
8956
9511
|
* ```ts
|
|
@@ -8965,6 +9520,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8965
9520
|
*
|
|
8966
9521
|
* @param date - The date to check. Defaults to now.
|
|
8967
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.
|
|
8968
9524
|
*
|
|
8969
9525
|
* @example
|
|
8970
9526
|
* ```ts
|
|
@@ -8982,6 +9538,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8982
9538
|
* unlike {@link toReadableTimeString} which defaults to UTC.
|
|
8983
9539
|
*
|
|
8984
9540
|
* @param date - The date to format.
|
|
9541
|
+
* @returns The formatted time string in the system's local timezone.
|
|
8985
9542
|
*
|
|
8986
9543
|
* @example
|
|
8987
9544
|
* ```ts
|
|
@@ -8995,6 +9552,7 @@ function _object_spread_props$2(target, source) {
|
|
|
8995
9552
|
*
|
|
8996
9553
|
* @param date - The date to format.
|
|
8997
9554
|
* @param timezone - The IANA timezone to format in. Defaults to UTC.
|
|
9555
|
+
* @returns The formatted time string (e.g., "10:30AM").
|
|
8998
9556
|
*
|
|
8999
9557
|
* @example
|
|
9000
9558
|
* ```ts
|
|
@@ -9010,6 +9568,7 @@ function _object_spread_props$2(target, source) {
|
|
|
9010
9568
|
*
|
|
9011
9569
|
* @param input - A time string such as "1:30PM", "13:30", or "1PM".
|
|
9012
9570
|
* @param config - Optional configuration specifying the timezone and reference date.
|
|
9571
|
+
* @returns The parsed time string result, or `undefined` if parsing failed.
|
|
9013
9572
|
*
|
|
9014
9573
|
* @example
|
|
9015
9574
|
* ```ts
|
|
@@ -9028,6 +9587,7 @@ function _object_spread_props$2(target, source) {
|
|
|
9028
9587
|
*
|
|
9029
9588
|
* @param input - A time string such as "1:30PM" or "13:30".
|
|
9030
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.
|
|
9031
9591
|
*
|
|
9032
9592
|
* @example
|
|
9033
9593
|
* ```ts
|
|
@@ -9041,6 +9601,7 @@ function _object_spread_props$2(target, source) {
|
|
|
9041
9601
|
* Creates a {@link LimitDateTimeInstance} for clamping and constraining dates to a configured range.
|
|
9042
9602
|
*
|
|
9043
9603
|
* @param config - The limit configuration specifying min/max bounds, future requirements, etc.
|
|
9604
|
+
* @returns A new {@link LimitDateTimeInstance} configured with the given bounds.
|
|
9044
9605
|
*
|
|
9045
9606
|
* @example
|
|
9046
9607
|
* ```ts
|
|
@@ -9150,6 +9711,7 @@ function _object_spread_props$1(target, source) {
|
|
|
9150
9711
|
date: dateFnsTz.toZonedTime(find.range.date, find.timezone)
|
|
9151
9712
|
}) : find.range;
|
|
9152
9713
|
var dates = dateRange(range);
|
|
9714
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
|
|
9153
9715
|
switch(range.type){
|
|
9154
9716
|
case exports.DateRangeType.DAY:
|
|
9155
9717
|
case exports.DateRangeType.WEEK:
|
|
@@ -9345,13 +9907,12 @@ function _object_spread$1(target) {
|
|
|
9345
9907
|
// A single field that manages start/end will start and end at the same instant (end = start)
|
|
9346
9908
|
// so we merge the gte/lte values.
|
|
9347
9909
|
var merged = mergeMongoDBLikeRangeFilters(startsAt, endsAt);
|
|
9348
|
-
startsAtFilter =
|
|
9910
|
+
startsAtFilter = _define_property$2({}, fields.start, merged);
|
|
9349
9911
|
} else {
|
|
9350
9912
|
startsAtFilter = startsAt ? _define_property$2({}, fields.start, startsAt) : undefined;
|
|
9351
9913
|
endsAtFilter = endsAt && fields.end ? _define_property$2({}, fields.end, endsAt) : undefined;
|
|
9352
9914
|
}
|
|
9353
|
-
|
|
9354
|
-
return filter;
|
|
9915
|
+
return _object_spread$1({}, startsAtFilter, endsAtFilter);
|
|
9355
9916
|
}
|
|
9356
9917
|
};
|
|
9357
9918
|
}
|
|
@@ -9474,6 +10035,8 @@ function _is_native_reflect_construct() {
|
|
|
9474
10035
|
* const rule = new DateRRule({ freq: RRule.DAILY, count: 5, dtstart: startDate });
|
|
9475
10036
|
* const lastDate = rule.last(); // fifth occurrence
|
|
9476
10037
|
* ```
|
|
10038
|
+
*
|
|
10039
|
+
* @returns The last occurrence date, or `undefined` if there are none.
|
|
9477
10040
|
*/ key: "last",
|
|
9478
10041
|
value: function last() {
|
|
9479
10042
|
return this._iter(new LastIterResult());
|
|
@@ -9488,6 +10051,9 @@ function _is_native_reflect_construct() {
|
|
|
9488
10051
|
* const rule = new DateRRule({ freq: RRule.WEEKLY, dtstart: startDate });
|
|
9489
10052
|
* const nextDate = rule.next(new Date());
|
|
9490
10053
|
* ```
|
|
10054
|
+
*
|
|
10055
|
+
* @param minDate - The earliest date to consider.
|
|
10056
|
+
* @returns The first occurrence on or after `minDate`, or `undefined` if none.
|
|
9491
10057
|
*/ key: "next",
|
|
9492
10058
|
value: function next(minDate) {
|
|
9493
10059
|
return this._iter(new NextIterResult(minDate));
|
|
@@ -9502,6 +10068,11 @@ function _is_native_reflect_construct() {
|
|
|
9502
10068
|
* const rule = new DateRRule({ freq: RRule.DAILY, dtstart: startDate });
|
|
9503
10069
|
* const exists = rule.any({ minDate: rangeStart, maxDate: rangeEnd });
|
|
9504
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.
|
|
9505
10076
|
*/ key: "any",
|
|
9506
10077
|
value: function any() {
|
|
9507
10078
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
@@ -9762,7 +10333,10 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9762
10333
|
/**
|
|
9763
10334
|
* Delimiter separating the property name/params from values in an RRule line.
|
|
9764
10335
|
*/ var RRULE_STRING_SPLITTER = ':';
|
|
9765
|
-
/**
|
|
10336
|
+
/**
|
|
10337
|
+
* @deprecated use RRULE_STRING_SPLITTER instead.
|
|
10338
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10339
|
+
var RRuleStringSplitter = RRULE_STRING_SPLITTER;
|
|
9766
10340
|
/**
|
|
9767
10341
|
* Utility class for parsing and manipulating RFC 5545 RRule strings.
|
|
9768
10342
|
*
|
|
@@ -9793,6 +10367,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9793
10367
|
* // result.basic = ['RRULE:FREQ=DAILY']
|
|
9794
10368
|
* // result.exdates contains the parsed exclusion dates
|
|
9795
10369
|
* ```
|
|
10370
|
+
*
|
|
10371
|
+
* @param input - The RRule string line set to separate.
|
|
10372
|
+
* @returns The separated basic rules and parsed EXDATE exclusion dates.
|
|
9796
10373
|
*/ function separateRRuleStringSetValues(input) {
|
|
9797
10374
|
var basic = [];
|
|
9798
10375
|
var exdateRules = [];
|
|
@@ -9822,6 +10399,8 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9822
10399
|
/**
|
|
9823
10400
|
* Parses an EXDATE line into its timezone and date components.
|
|
9824
10401
|
*
|
|
10402
|
+
* @param line - The raw EXDATE line string to parse.
|
|
10403
|
+
* @returns The parsed EXDATE attribute with timezone and dates.
|
|
9825
10404
|
* @throws Error if the line is not an EXDATE property.
|
|
9826
10405
|
*/ function parseExdateAttributeFromLine(line) {
|
|
9827
10406
|
var property = this.parseProperty(line);
|
|
@@ -9833,6 +10412,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9833
10412
|
key: "parseExdateAttributeFromProperty",
|
|
9834
10413
|
value: /**
|
|
9835
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.
|
|
9836
10418
|
*/ function parseExdateAttributeFromProperty(property) {
|
|
9837
10419
|
var _property_params_find;
|
|
9838
10420
|
var timezone = (_property_params_find = property.params.find(function(x) {
|
|
@@ -9856,6 +10438,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9856
10438
|
value: /**
|
|
9857
10439
|
* Convenience wrapper that creates a timezone converter and delegates to {@link parseDateTimeString}.
|
|
9858
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.
|
|
9859
10444
|
* @throws Error if the date string is not UTC and no timezone is provided.
|
|
9860
10445
|
*/ function parseDateTimeStringWithTimezone(rfcDateString, timezone) {
|
|
9861
10446
|
return DateRRuleParseUtility.parseDateTimeString(rfcDateString, timezone ? new DateTimezoneUtcNormalInstance({
|
|
@@ -9871,6 +10456,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9871
10456
|
* If the string does not end in `Z` (indicating UTC), the converter is used to normalize
|
|
9872
10457
|
* the local date representation to its true UTC equivalent.
|
|
9873
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.
|
|
9874
10462
|
* @throws Error if the string cannot be parsed or a non-UTC string lacks a converter.
|
|
9875
10463
|
*/ function parseDateTimeString(rfcDateString, converter) {
|
|
9876
10464
|
var RFC5545_DATE_TIME_FORMAT = /^((\d{4})(\d{2})(\d{2}))(T(\d{2})(\d{2})(\d{2})Z?)?$/;
|
|
@@ -9914,6 +10502,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9914
10502
|
* DateRRuleParseUtility.formatDateTimeString(new Date('2021-06-11T11:00:00Z'));
|
|
9915
10503
|
* // => '20210611T110000Z'
|
|
9916
10504
|
* ```
|
|
10505
|
+
*
|
|
10506
|
+
* @param date - The date to format.
|
|
10507
|
+
* @returns The RFC 5545 UTC date-time string representation.
|
|
9917
10508
|
*/ function formatDateTimeString(date) {
|
|
9918
10509
|
return dateFnsTz.format(date, "yyyyMMdd'T'HHmmss'Z'");
|
|
9919
10510
|
}
|
|
@@ -9922,6 +10513,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9922
10513
|
key: "parseProperty",
|
|
9923
10514
|
value: /**
|
|
9924
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.
|
|
9925
10519
|
*/ function parseProperty(line) {
|
|
9926
10520
|
var rawLine = DateRRuleParseUtility.parseRawLine(line);
|
|
9927
10521
|
return DateRRuleParseUtility.propertyFromRawLine(rawLine);
|
|
@@ -9931,6 +10525,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9931
10525
|
key: "propertyFromRawLine",
|
|
9932
10526
|
value: /**
|
|
9933
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.
|
|
9934
10531
|
*/ function propertyFromRawLine(rawLine) {
|
|
9935
10532
|
var typeAndParams = rawLine.params.split(';');
|
|
9936
10533
|
var type = typeAndParams[0].toUpperCase();
|
|
@@ -9946,6 +10543,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9946
10543
|
key: "parseRawParam",
|
|
9947
10544
|
value: /**
|
|
9948
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.
|
|
9949
10549
|
*/ function parseRawParam(param) {
|
|
9950
10550
|
var _splitJoinRemainder = _sliced_to_array$1(util.splitJoinRemainder(param, '=', 2), 2), key = _splitJoinRemainder[0], value = _splitJoinRemainder[1];
|
|
9951
10551
|
return {
|
|
@@ -9959,6 +10559,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9959
10559
|
value: /**
|
|
9960
10560
|
* Splits a raw line at the colon delimiter into params and values portions.
|
|
9961
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.
|
|
9962
10565
|
*/ function parseRawLine(line) {
|
|
9963
10566
|
var _splitJoinRemainder = _sliced_to_array$1(util.splitJoinRemainder(line, RRULE_STRING_SPLITTER, 2), 2), params = _splitJoinRemainder[0], values = _splitJoinRemainder[1];
|
|
9964
10567
|
var result;
|
|
@@ -9981,6 +10584,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9981
10584
|
value: // MARK: String
|
|
9982
10585
|
/**
|
|
9983
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.
|
|
9984
10590
|
*/ function toRRuleStringSet(lines) {
|
|
9985
10591
|
return lines.split('\n');
|
|
9986
10592
|
}
|
|
@@ -9989,6 +10595,9 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9989
10595
|
key: "toRRuleLines",
|
|
9990
10596
|
value: /**
|
|
9991
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.
|
|
9992
10601
|
*/ function toRRuleLines(rruleStringSet) {
|
|
9993
10602
|
return rruleStringSet.join('\n');
|
|
9994
10603
|
}
|
|
@@ -9999,6 +10608,8 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
9999
10608
|
/**
|
|
10000
10609
|
* Asserts that the property has the expected type, throwing if it does not match.
|
|
10001
10610
|
*
|
|
10611
|
+
* @param type - The expected property type.
|
|
10612
|
+
* @param property - The property to check.
|
|
10002
10613
|
* @throws Error if the property type does not match the expected type.
|
|
10003
10614
|
*/ function assertPropertyType(type, property) {
|
|
10004
10615
|
if (property.type !== type) {
|
|
@@ -10139,7 +10750,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
10139
10750
|
this.options = options;
|
|
10140
10751
|
var tzid = rrule.origOptions.tzid;
|
|
10141
10752
|
var dtstart = rrule.origOptions.dtstart;
|
|
10142
|
-
var timezone = tzid
|
|
10753
|
+
var timezone = tzid !== null && tzid !== void 0 ? tzid : options.timezone;
|
|
10143
10754
|
/**
|
|
10144
10755
|
* The normal instance for DateRRuleInstance is used backwards in most cases because DateRRule always
|
|
10145
10756
|
* parses dates as UTC, so we handle all input dates as base dates, an
|
|
@@ -10190,8 +10801,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
10190
10801
|
var from = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new Date();
|
|
10191
10802
|
var baseFrom = this.normalInstance.baseDateToTargetDate(from);
|
|
10192
10803
|
var rawNext = this.rrule.next(baseFrom);
|
|
10193
|
-
|
|
10194
|
-
return next;
|
|
10804
|
+
return rawNext ? this.normalInstance.targetDateToBaseDate(rawNext) : undefined;
|
|
10195
10805
|
}
|
|
10196
10806
|
},
|
|
10197
10807
|
{
|
|
@@ -10332,11 +10942,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
10332
10942
|
/**
|
|
10333
10943
|
* Returns `true` when the underlying RRule has neither a `count` nor an
|
|
10334
10944
|
* `until` constraint, meaning it recurs indefinitely.
|
|
10945
|
+
*
|
|
10946
|
+
* @returns `true` if the rule recurs indefinitely.
|
|
10335
10947
|
*/ key: "hasForeverRange",
|
|
10336
10948
|
value: function hasForeverRange() {
|
|
10337
10949
|
var options = this.rrule.options;
|
|
10338
|
-
|
|
10339
|
-
return forever;
|
|
10950
|
+
return !options.count && !options.until;
|
|
10340
10951
|
}
|
|
10341
10952
|
}
|
|
10342
10953
|
], [
|