@dereekb/date 9.25.16 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +9 -17
- package/src/lib/date/date.calendar.d.ts +1 -1
- package/src/lib/date/date.calendar.js +2 -2
- package/src/lib/date/date.calendar.js.map +1 -1
- package/src/lib/date/date.cell.d.ts +16 -32
- package/src/lib/date/date.cell.factory.d.ts +15 -15
- package/src/lib/date/date.cell.factory.js +1 -1
- package/src/lib/date/date.cell.factory.js.map +1 -1
- package/src/lib/date/date.cell.filter.d.ts +2 -2
- package/src/lib/date/date.cell.filter.js.map +1 -1
- package/src/lib/date/date.cell.index.d.ts +12 -12
- package/src/lib/date/date.cell.index.js +2 -2
- package/src/lib/date/date.cell.index.js.map +1 -1
- package/src/lib/date/date.cell.js +4 -21
- package/src/lib/date/date.cell.js.map +1 -1
- package/src/lib/date/date.cell.schedule.d.ts +12 -12
- package/src/lib/date/date.cell.schedule.js +4 -4
- package/src/lib/date/date.cell.schedule.js.map +1 -1
- package/src/lib/date/date.cell.week.d.ts +3 -3
- package/src/lib/date/date.d.ts +3 -15
- package/src/lib/date/date.day.d.ts +9 -9
- package/src/lib/date/date.duration.d.ts +1 -5
- package/src/lib/date/date.duration.js +2 -7
- package/src/lib/date/date.duration.js.map +1 -1
- package/src/lib/date/date.format.d.ts +10 -13
- package/src/lib/date/date.format.js +3 -12
- package/src/lib/date/date.format.js.map +1 -1
- package/src/lib/date/date.js +1 -17
- package/src/lib/date/date.js.map +1 -1
- package/src/lib/date/date.logical.d.ts +6 -6
- package/src/lib/date/date.range.d.ts +14 -35
- package/src/lib/date/date.range.js +4 -27
- package/src/lib/date/date.range.js.map +1 -1
- package/src/lib/date/date.range.timezone.d.ts +1 -8
- package/src/lib/date/date.range.timezone.js +7 -6
- package/src/lib/date/date.range.timezone.js.map +1 -1
- package/src/lib/date/date.sort.d.ts +2 -2
- package/src/lib/date/date.time.js.map +1 -1
- package/src/lib/date/date.time.limit.d.ts +0 -8
- package/src/lib/date/date.time.limit.js +0 -10
- package/src/lib/date/date.time.limit.js.map +1 -1
- package/src/lib/date/date.time.minute.d.ts +2 -9
- package/src/lib/date/date.time.minute.js +2 -11
- package/src/lib/date/date.time.minute.js.map +1 -1
- package/src/lib/date/date.timezone.d.ts +13 -17
- package/src/lib/date/date.timezone.js +13 -18
- package/src/lib/date/date.timezone.js.map +1 -1
- package/src/lib/date/date.week.d.ts +13 -17
- package/src/lib/date/date.week.js +1 -6
- package/src/lib/date/date.week.js.map +1 -1
- package/src/lib/date/index.d.ts +0 -5
- package/src/lib/date/index.js +0 -5
- package/src/lib/date/index.js.map +1 -1
- package/src/lib/query/query.builder.d.ts +4 -4
- package/src/lib/query/query.builder.mongo.d.ts +1 -1
- package/src/lib/rrule/date.recurrence.d.ts +1 -1
- package/src/lib/rrule/date.recurrence.js +2 -3
- package/src/lib/rrule/date.recurrence.js.map +1 -1
- package/src/lib/rrule/date.rrule.d.ts +1 -1
- package/src/lib/rrule/date.rrule.js +14 -14
- package/src/lib/rrule/date.rrule.js.map +1 -1
- package/src/lib/rrule/date.rrule.parse.d.ts +10 -10
- package/src/lib/date/date.block.d.ts +0 -1388
- package/src/lib/date/date.block.day.d.ts +0 -10
- package/src/lib/date/date.block.day.js +0 -16
- package/src/lib/date/date.block.day.js.map +0 -1
- package/src/lib/date/date.block.js +0 -1849
- package/src/lib/date/date.block.js.map +0 -1
- package/src/lib/date/date.block.validator.d.ts +0 -20
- package/src/lib/date/date.block.validator.js +0 -72
- package/src/lib/date/date.block.validator.js.map +0 -1
- package/src/lib/date/date.block.week.d.ts +0 -44
- package/src/lib/date/date.block.week.js +0 -46
- package/src/lib/date/date.block.week.js.map +0 -1
- package/src/lib/date/date.filter.d.ts +0 -7
- package/src/lib/date/date.filter.js +0 -28
- package/src/lib/date/date.filter.js.map +0 -1
- package/src/lib/date/date.schedule.d.ts +0 -431
- package/src/lib/date/date.schedule.js +0 -553
- package/src/lib/date/date.schedule.js.map +0 -1
|
@@ -1,1849 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dateBlockIndexRangeToDateBlockRange = exports.dateBlockRangeToDateBlockIndexRange = exports.dateBlockDayTimingInfoFactory = exports.dateBlocksExpansionFactory = exports.expandDateBlocks = exports.expandDateBlockCollection = exports.dateBlockDayOfWeekFactory = exports.isValidDateBlockTiming = exports.isValidDateBlockTimingInfo = exports.dateBlockTimingInTimezone = exports.dateBlockTimingInTimezoneFunction = exports.dateBlockTiming = exports.getRelativeDateForDateBlockTiming = exports.dateBlockTimingStartsAtDateFactory = exports.dateBlockTimingStartDateFactory = exports.dateBlockTimingDateFactory = exports.dateRelativeStateForDateBlockRangeComparedToIndex = exports.getNextDateBlockTimingIndex = exports.getRelativeIndexForDateBlockTiming = exports.dateBlockTimingRelativeIndexArrayFactory = exports.dateBlockTimingRelativeIndexFactory = exports.isDateBlockTimingRelativeIndexFactory = exports.isValidDateBlockTimingStartDate = exports.getCurrentDateBlockTimingStartDate = exports.dateBlockTimingStartForNowInTimezone = exports.dateBlockTimingStartForNowInSystemTimezone = exports.changeTimingToSystemTimezone = exports.changeTimingToTimezone = exports.changeTimingToTimezoneFunction = exports.dateBlockTimingFromDateBlockTimingStartEndDayDateRange = exports.safeDateBlockTimingFromDateRangeAndEvent = exports.dateBlockTimingFromDateRangeAndEvent = exports.assertedTimingDateTimezoneUtcNormal = exports.timingDateTimezoneUtcNormal = exports.getDateBlockTimingHoursInEvent = exports.getDateBlockTimingFirstEventDateRange = exports.timingIsInExpectedTimezone = exports.timingIsInExpectedTimezoneFunction = exports.getCurrentDateBlockTimingOffset = exports.getCurrentDateBlockTimingOffsetData = exports.getCurrentDateBlockTimingUtcData = exports.dateBlockTimingEventRange = exports.dateBlockTimingFullRange = exports.isSameDateBlockTiming = exports.DateBlockTiming = exports.MIN_DATE_BLOCK_TIMING_OFFSET_HOURS = exports.MAX_DATE_BLOCK_TIMING_OFFSET_HOURS = exports.dateBlock = exports.DateBlock = exports.isValidDateBlockIndex = void 0;
|
|
4
|
-
exports.getRelativeIndexForDateTiming = exports.dateTimingRelativeIndexArrayFactory = exports.dateTimingRelativeIndexFactory = exports.isDateTimingRelativeIndexFactory = exports.dateBlocksDayInfoFactory = exports.dateBlockRangeContainsDateBlock = exports.dateBlockIsWithinDateBlockRangeFunction = exports.dateBlocksInDateBlockRange = exports.modifyDateBlockToFitRange = exports.modifyDateBlocksToFitRange = exports.modifyDateBlocksToFitRangeFunction = exports.expandUniqueDateBlocksFunction = exports.groupUniqueDateBlocks = exports.dateBlockEndIndex = exports.dateBlockRangeHasRange = exports.expandDateBlockRange = exports.dateBlockRangesFullyCoverDateBlockRangeFunction = exports.dateBlockRangeBlocksCount = exports.dateBlockRangeBlocksCountInfo = exports.allIndexesInDateBlockRanges = exports.allIndexesInDateBlockRange = exports.groupToDateBlockRanges = exports.sortDateBlockRanges = exports.sortDateBlockRangeAndSizeFunction = exports.dateBlockRangeOverlapsRange = exports.dateBlockRangeOverlapsRangeFunction = exports.dateBlockRangeIncludedByRangeFunction = exports.dateBlockRangeWithRange = exports.dateBlockRangeWithRangeFromIndex = exports.dateBlockRange = exports.getLeastAndGreatestDateBlockIndexInDateBlockRanges = exports.getGreatestDateBlockIndexInDateBlockRanges = exports.getLeastDateBlockIndexInDateBlockRanges = exports.isValidDateBlockRangeSeries = exports.isValidDateBlockRange = exports.DateBlockRange = exports.isDateWithinDateBlockRangeFunction = exports.isDateBlockWithinDateBlockRange = exports.isDateBlockWithinDateBlockRangeFunction = exports.filterDateBlocksInDateBlockRange = exports.dateBlockIndexRange = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const util_1 = require("@dereekb/util");
|
|
7
|
-
const date_range_1 = require("./date.range");
|
|
8
|
-
const date_duration_1 = require("./date.duration");
|
|
9
|
-
const date_fns_1 = require("date-fns");
|
|
10
|
-
const date_1 = require("./date");
|
|
11
|
-
const class_transformer_1 = require("class-transformer");
|
|
12
|
-
const date_timezone_1 = require("./date.timezone");
|
|
13
|
-
const class_validator_1 = require("class-validator");
|
|
14
|
-
const date_format_1 = require("./date.format");
|
|
15
|
-
const date_range_timezone_1 = require("./date.range.timezone");
|
|
16
|
-
/**
|
|
17
|
-
* Returns true if the index is a non-negative integer.
|
|
18
|
-
*
|
|
19
|
-
* @deprecated use DateCell implementation instead.
|
|
20
|
-
* @param input
|
|
21
|
-
*/
|
|
22
|
-
function isValidDateBlockIndex(input) {
|
|
23
|
-
return input >= 0 && Number.isInteger(input);
|
|
24
|
-
}
|
|
25
|
-
exports.isValidDateBlockIndex = isValidDateBlockIndex;
|
|
26
|
-
class DateBlock {
|
|
27
|
-
constructor(template) {
|
|
28
|
-
if (template) {
|
|
29
|
-
this.i = template.i;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
tslib_1.__decorate([
|
|
34
|
-
(0, class_transformer_1.Expose)(),
|
|
35
|
-
(0, class_validator_1.IsNumber)(),
|
|
36
|
-
(0, class_validator_1.Min)(0),
|
|
37
|
-
tslib_1.__metadata("design:type", Number)
|
|
38
|
-
], DateBlock.prototype, "i", void 0);
|
|
39
|
-
exports.DateBlock = DateBlock;
|
|
40
|
-
/**
|
|
41
|
-
* Converts the input number or DateBlock to a DateBlock.
|
|
42
|
-
*
|
|
43
|
-
* @deprecated use DateCell implementation instead.
|
|
44
|
-
* @param dateBlockOrIndex
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
function dateBlock(dateBlockOrIndex) {
|
|
48
|
-
return typeof dateBlockOrIndex === 'number' ? { i: dateBlockOrIndex } : dateBlockOrIndex;
|
|
49
|
-
}
|
|
50
|
-
exports.dateBlock = dateBlock;
|
|
51
|
-
/**
|
|
52
|
-
* The maximum number of hours that a DateBlockTiming's start can be offset. This means a max timezone of UTC+12.
|
|
53
|
-
*
|
|
54
|
-
* The timezones UTC+13 and UTC+14 are not supported, and will experience undetermined behavior.
|
|
55
|
-
*
|
|
56
|
-
* @deprecated use DateCell implementation instead.
|
|
57
|
-
*/
|
|
58
|
-
exports.MAX_DATE_BLOCK_TIMING_OFFSET_HOURS = 12;
|
|
59
|
-
/**
|
|
60
|
-
* The minimum number of hours that a DateBlockTiming's start can be offset. This means a min timezone of UTC-12.
|
|
61
|
-
*
|
|
62
|
-
* @deprecated use DateCell implementation instead.
|
|
63
|
-
*/
|
|
64
|
-
exports.MIN_DATE_BLOCK_TIMING_OFFSET_HOURS = -12;
|
|
65
|
-
class DateBlockTiming extends date_duration_1.DateDurationSpan {
|
|
66
|
-
constructor(template) {
|
|
67
|
-
super(template);
|
|
68
|
-
if (template) {
|
|
69
|
-
this.start = template.start;
|
|
70
|
-
this.end = template.end;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
tslib_1.__decorate([
|
|
75
|
-
(0, class_transformer_1.Expose)(),
|
|
76
|
-
(0, class_validator_1.IsDate)(),
|
|
77
|
-
(0, class_transformer_1.Type)(() => Date),
|
|
78
|
-
tslib_1.__metadata("design:type", Date)
|
|
79
|
-
], DateBlockTiming.prototype, "start", void 0);
|
|
80
|
-
tslib_1.__decorate([
|
|
81
|
-
(0, class_transformer_1.Expose)(),
|
|
82
|
-
(0, class_validator_1.IsDate)(),
|
|
83
|
-
(0, class_transformer_1.Type)(() => Date),
|
|
84
|
-
tslib_1.__metadata("design:type", Date)
|
|
85
|
-
], DateBlockTiming.prototype, "end", void 0);
|
|
86
|
-
tslib_1.__decorate([
|
|
87
|
-
(0, class_transformer_1.Expose)(),
|
|
88
|
-
(0, class_validator_1.IsOptional)(),
|
|
89
|
-
tslib_1.__metadata("design:type", String)
|
|
90
|
-
], DateBlockTiming.prototype, "timezone", void 0);
|
|
91
|
-
exports.DateBlockTiming = DateBlockTiming;
|
|
92
|
-
/**
|
|
93
|
-
* Returns true if the two timings are equivalent.
|
|
94
|
-
*
|
|
95
|
-
* @deprecated use DateCell implementation instead.
|
|
96
|
-
* @param a
|
|
97
|
-
* @param b
|
|
98
|
-
*/
|
|
99
|
-
function isSameDateBlockTiming(a, b) {
|
|
100
|
-
return a && b ? a.duration === b.duration && (0, date_1.isSameDate)(a.start, b.start) && (0, date_1.isSameDate)(a.startsAt, b.startsAt) && (0, date_1.isSameDate)(a.end, b.end) : a == b;
|
|
101
|
-
}
|
|
102
|
-
exports.isSameDateBlockTiming = isSameDateBlockTiming;
|
|
103
|
-
/**
|
|
104
|
-
* Returns the date range from the start of the first event to the end time of the last event.
|
|
105
|
-
*
|
|
106
|
-
* @deprecated use DateCell implementation instead.
|
|
107
|
-
* @param timing
|
|
108
|
-
* @returns
|
|
109
|
-
*/
|
|
110
|
-
function dateBlockTimingFullRange(timing) {
|
|
111
|
-
return { start: timing.start, end: timing.end };
|
|
112
|
-
}
|
|
113
|
-
exports.dateBlockTimingFullRange = dateBlockTimingFullRange;
|
|
114
|
-
/**
|
|
115
|
-
* Returns the date range from the start of the first event to the end time of the last event.
|
|
116
|
-
*
|
|
117
|
-
* @deprecated use DateCell implementation instead.
|
|
118
|
-
* @param timing
|
|
119
|
-
* @returns
|
|
120
|
-
*/
|
|
121
|
-
function dateBlockTimingEventRange(timing) {
|
|
122
|
-
return { start: timing.startsAt, end: timing.end };
|
|
123
|
-
}
|
|
124
|
-
exports.dateBlockTimingEventRange = dateBlockTimingEventRange;
|
|
125
|
-
/**
|
|
126
|
-
*
|
|
127
|
-
* @deprecated use DateCell implementation instead.
|
|
128
|
-
* @param timing
|
|
129
|
-
* @returns
|
|
130
|
-
*/
|
|
131
|
-
function getCurrentDateBlockTimingUtcData(timing) {
|
|
132
|
-
const start = timing.start;
|
|
133
|
-
const dateHours = start.getUTCHours();
|
|
134
|
-
// if it is a positive offset, then the date is in the future so we subtract the offset from 24 hours to get the proper offset.
|
|
135
|
-
const originalUtcOffsetInHours = dateHours >= exports.MAX_DATE_BLOCK_TIMING_OFFSET_HOURS ? util_1.HOURS_IN_DAY - dateHours : -dateHours;
|
|
136
|
-
const originalUtcDate = (0, date_fns_1.addHours)(start, originalUtcOffsetInHours); // convert to original UTC
|
|
137
|
-
return {
|
|
138
|
-
originalUtcDate,
|
|
139
|
-
originalUtcOffsetInHours
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
exports.getCurrentDateBlockTimingUtcData = getCurrentDateBlockTimingUtcData;
|
|
143
|
-
/**
|
|
144
|
-
* The offset in milliseconds to the "real start date", the first second in the target day on in the system timezone.
|
|
145
|
-
*
|
|
146
|
-
* @deprecated use DateCell implementation instead.
|
|
147
|
-
* @param timing
|
|
148
|
-
*/
|
|
149
|
-
function getCurrentDateBlockTimingOffsetData(timing) {
|
|
150
|
-
const { originalUtcOffsetInHours, originalUtcDate } = getCurrentDateBlockTimingUtcData(timing);
|
|
151
|
-
const currentTimezoneOffsetInHours = (0, date_timezone_1.getCurrentSystemOffsetInHours)(originalUtcDate); // get the offset as it is on that day
|
|
152
|
-
// calculate the true offset
|
|
153
|
-
let offset = originalUtcOffsetInHours - currentTimezoneOffsetInHours;
|
|
154
|
-
if (offset === -util_1.HOURS_IN_DAY) {
|
|
155
|
-
offset = 0; // auckland can return -24 for itself
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
originalUtcDate,
|
|
159
|
-
originalUtcOffsetInHours,
|
|
160
|
-
offset: (0, date_fns_1.hoursToMilliseconds)(offset),
|
|
161
|
-
currentTimezoneOffsetInHours
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
exports.getCurrentDateBlockTimingOffsetData = getCurrentDateBlockTimingOffsetData;
|
|
165
|
-
/**
|
|
166
|
-
*
|
|
167
|
-
* @deprecated use DateCell implementation instead.
|
|
168
|
-
* @param timing
|
|
169
|
-
* @returns
|
|
170
|
-
*/
|
|
171
|
-
function getCurrentDateBlockTimingOffset(timing) {
|
|
172
|
-
return getCurrentDateBlockTimingOffsetData(timing).offset;
|
|
173
|
-
}
|
|
174
|
-
exports.getCurrentDateBlockTimingOffset = getCurrentDateBlockTimingOffset;
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
* @deprecated use DateCell implementation instead.
|
|
178
|
-
* @param timezone
|
|
179
|
-
* @returns
|
|
180
|
-
*/
|
|
181
|
-
function timingIsInExpectedTimezoneFunction(timezone) {
|
|
182
|
-
const normal = (0, date_timezone_1.dateTimezoneUtcNormal)(timezone);
|
|
183
|
-
return (timing) => {
|
|
184
|
-
const { start } = timing;
|
|
185
|
-
const offset = normal.systemDateToTargetDateOffset(start);
|
|
186
|
-
const expectedTimingOffset = getCurrentDateBlockTimingOffsetData(timing);
|
|
187
|
-
return offset === expectedTimingOffset.offset;
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
exports.timingIsInExpectedTimezoneFunction = timingIsInExpectedTimezoneFunction;
|
|
191
|
-
/**
|
|
192
|
-
*
|
|
193
|
-
* @deprecated use DateCell implementation instead.
|
|
194
|
-
* @param timing
|
|
195
|
-
* @param timezone
|
|
196
|
-
* @returns
|
|
197
|
-
*/
|
|
198
|
-
function timingIsInExpectedTimezone(timing, timezone) {
|
|
199
|
-
return timingIsInExpectedTimezoneFunction(timezone)(timing);
|
|
200
|
-
}
|
|
201
|
-
exports.timingIsInExpectedTimezone = timingIsInExpectedTimezone;
|
|
202
|
-
/**
|
|
203
|
-
* Returns the total minutes between the start of the first event and the end of the last event.
|
|
204
|
-
*
|
|
205
|
-
* @param timing
|
|
206
|
-
* @returns
|
|
207
|
-
*/
|
|
208
|
-
function getDateBlockTimingFirstEventDateRange(timing) {
|
|
209
|
-
return (0, date_range_timezone_1.fitDateRangeToDayPeriod)({ start: timing.startsAt, end: timing.end });
|
|
210
|
-
}
|
|
211
|
-
exports.getDateBlockTimingFirstEventDateRange = getDateBlockTimingFirstEventDateRange;
|
|
212
|
-
/**
|
|
213
|
-
* Returns the fractional hours in the event.
|
|
214
|
-
*
|
|
215
|
-
* @deprecated use DateCell implementation instead.
|
|
216
|
-
* @param timing
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
function getDateBlockTimingHoursInEvent(timing) {
|
|
220
|
-
const dateRange = getDateBlockTimingFirstEventDateRange(timing);
|
|
221
|
-
return (0, util_1.minutesToFractionalHours)((0, date_fns_1.differenceInMinutes)(dateRange.end, dateRange.start));
|
|
222
|
-
}
|
|
223
|
-
exports.getDateBlockTimingHoursInEvent = getDateBlockTimingHoursInEvent;
|
|
224
|
-
/**
|
|
225
|
-
* Creates a DateTimezoneUtcNormalInstance from the input.
|
|
226
|
-
*
|
|
227
|
-
* @deprecated use DateCell implementation instead.
|
|
228
|
-
* @param input
|
|
229
|
-
* @returns
|
|
230
|
-
*/
|
|
231
|
-
function timingDateTimezoneUtcNormal(input) {
|
|
232
|
-
const timezoneNormalInput = (0, date_range_1.isDateRangeStart)(input) ? (0, date_fns_1.hoursToMilliseconds)(getCurrentDateBlockTimingUtcData(input).originalUtcOffsetInHours) : input;
|
|
233
|
-
const timezoneInstance = (0, date_timezone_1.dateTimezoneUtcNormal)(timezoneNormalInput);
|
|
234
|
-
return timezoneInstance;
|
|
235
|
-
}
|
|
236
|
-
exports.timingDateTimezoneUtcNormal = timingDateTimezoneUtcNormal;
|
|
237
|
-
/**
|
|
238
|
-
* Convenience function that extends timingDateTimezoneUtcNormal() but also asserts the that the timing matches it.
|
|
239
|
-
*
|
|
240
|
-
* @deprecated use DateCell implementation instead.
|
|
241
|
-
* @param input
|
|
242
|
-
* @param timing
|
|
243
|
-
* @returns
|
|
244
|
-
*/
|
|
245
|
-
function assertedTimingDateTimezoneUtcNormal(input, timing) {
|
|
246
|
-
const timezoneInstance = timingDateTimezoneUtcNormal(input);
|
|
247
|
-
if (!timingIsInExpectedTimezone(timing, timezoneInstance)) {
|
|
248
|
-
throw new Error(`assertedTimingDateTimezoneUtcNormal() failed to expected to match with the timing.`);
|
|
249
|
-
}
|
|
250
|
-
return timezoneInstance;
|
|
251
|
-
}
|
|
252
|
-
exports.assertedTimingDateTimezoneUtcNormal = assertedTimingDateTimezoneUtcNormal;
|
|
253
|
-
function dateBlockTimingFromDateRangeAndEvent(dateBlockTimingStartEndRange, event) {
|
|
254
|
-
const { start, end } = dateBlockTimingStartEndRange;
|
|
255
|
-
const { startsAt: eventStartsAt, duration } = event;
|
|
256
|
-
// need the timezone instance to compute against the normal and convert to the system time, before going back.
|
|
257
|
-
// this is necessary because the start is a timezone normal for UTC, and the minutes need to be converted back properly adjusting for timezones.
|
|
258
|
-
const timezoneInstance = timingDateTimezoneUtcNormal(dateBlockTimingStartEndRange);
|
|
259
|
-
// compute startsAt, the start time for the first event
|
|
260
|
-
const startsAt = (0, date_timezone_1.copyHoursAndMinutesFromDateWithTimezoneNormal)(start, eventStartsAt, timezoneInstance);
|
|
261
|
-
const timing = {
|
|
262
|
-
start,
|
|
263
|
-
end,
|
|
264
|
-
startsAt,
|
|
265
|
-
duration
|
|
266
|
-
};
|
|
267
|
-
return timing;
|
|
268
|
-
}
|
|
269
|
-
exports.dateBlockTimingFromDateRangeAndEvent = dateBlockTimingFromDateRangeAndEvent;
|
|
270
|
-
function safeDateBlockTimingFromDateRangeAndEvent(dateBlockTimingStartEndRange, event, timezone) {
|
|
271
|
-
const { start, end } = dateBlockTimingStartEndRange;
|
|
272
|
-
const timezoneInstance = assertedTimingDateTimezoneUtcNormal(timezone !== null && timezone !== void 0 ? timezone : dateBlockTimingStartEndRange, dateBlockTimingStartEndRange);
|
|
273
|
-
// const startDayFactory = dateBlockTimingStartDateFactory({ start }, timezoneInstance);
|
|
274
|
-
const endDay = end; // get midnight of the day the job usually ends at
|
|
275
|
-
const endDayDateRange = { start, endDay };
|
|
276
|
-
return _dateBlockTimingFromDateBlockTimingStartEndDayDateRange(endDayDateRange, event, timezoneInstance);
|
|
277
|
-
}
|
|
278
|
-
exports.safeDateBlockTimingFromDateRangeAndEvent = safeDateBlockTimingFromDateRangeAndEvent;
|
|
279
|
-
/**
|
|
280
|
-
* Converts a DateBlockTimingStartEndDayDateRange and DateBlockTimingEvent to a DateBlockTiming. The event is used to derive the startsAt, duration and end time. The timezone offset is retained.
|
|
281
|
-
*
|
|
282
|
-
* @deprecated use DateCell implementation instead.
|
|
283
|
-
* @param dateBlockTimingStartEndDayDateRange
|
|
284
|
-
* @param event
|
|
285
|
-
* @returns
|
|
286
|
-
*/
|
|
287
|
-
function dateBlockTimingFromDateBlockTimingStartEndDayDateRange(dateBlockTimingStartEndDayDateRange, event, timezone) {
|
|
288
|
-
// need the timezone instance to compute against the normal and convert to the system time, before going back.
|
|
289
|
-
// this is necessary because the start is a timezone normal for UTC, and the minutes need to be converted back properly adjusting for timezones.
|
|
290
|
-
const timezoneInstance = assertedTimingDateTimezoneUtcNormal(timezone !== null && timezone !== void 0 ? timezone : dateBlockTimingStartEndDayDateRange, dateBlockTimingStartEndDayDateRange);
|
|
291
|
-
return _dateBlockTimingFromDateBlockTimingStartEndDayDateRange(dateBlockTimingStartEndDayDateRange, event, timezoneInstance);
|
|
292
|
-
}
|
|
293
|
-
exports.dateBlockTimingFromDateBlockTimingStartEndDayDateRange = dateBlockTimingFromDateBlockTimingStartEndDayDateRange;
|
|
294
|
-
/**
|
|
295
|
-
* Internal function that allows safeDateBlockTimingFromDateRangeAndEvent() and dateBlockTimingFromDateBlockTimingStartEndDayDateRange()
|
|
296
|
-
* to pass their timezone instances to this function, without having to create a new instance.
|
|
297
|
-
*
|
|
298
|
-
* See dateBlockTimingFromDateBlockTimingStartEndDayDateRange() for details.
|
|
299
|
-
*
|
|
300
|
-
* @deprecated use DateCell implementation instead.
|
|
301
|
-
* @param dateBlockTimingStartEndDayDateRange
|
|
302
|
-
* @param event
|
|
303
|
-
* @param timezoneInstance
|
|
304
|
-
* @returns
|
|
305
|
-
*/
|
|
306
|
-
function _dateBlockTimingFromDateBlockTimingStartEndDayDateRange(dateBlockTimingStartEndDayDateRange, event, timezoneInstance) {
|
|
307
|
-
const { start, endDay } = dateBlockTimingStartEndDayDateRange;
|
|
308
|
-
const { startsAt: eventStartsAt, duration } = event;
|
|
309
|
-
// compute startsAt, the start time for the first event
|
|
310
|
-
const startsAt = (0, date_timezone_1.copyHoursAndMinutesFromDateWithTimezoneNormal)(start, eventStartsAt, timezoneInstance);
|
|
311
|
-
// compute end, the end time for the last event using the last day
|
|
312
|
-
const lastDayStartsAt = dateBlockTimingStartsAtDateFactory({ start, startsAt }, timezoneInstance)(endDay);
|
|
313
|
-
const end = (0, date_fns_1.addMinutes)(lastDayStartsAt, duration);
|
|
314
|
-
const timing = {
|
|
315
|
-
start,
|
|
316
|
-
end,
|
|
317
|
-
startsAt,
|
|
318
|
-
duration
|
|
319
|
-
};
|
|
320
|
-
// console.log({ timezoneInstance, startsAt, eventStartsAt, lastDayStartsAt, dateBlockTimingStartEndDayDateRange, event, timing });
|
|
321
|
-
return timing;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Creates a ChangeTimingToTimezoneFunction from the input.
|
|
325
|
-
*
|
|
326
|
-
* @deprecated use DateCell implementation instead.
|
|
327
|
-
* @param input
|
|
328
|
-
* @returns
|
|
329
|
-
*/
|
|
330
|
-
function changeTimingToTimezoneFunction(input) {
|
|
331
|
-
const timezoneInstance = timingDateTimezoneUtcNormal(input);
|
|
332
|
-
const fn = ((timing) => {
|
|
333
|
-
const baseTimingOffset = getCurrentDateBlockTimingUtcData(timing);
|
|
334
|
-
const startInUtc = baseTimingOffset.originalUtcDate;
|
|
335
|
-
const start = timezoneInstance.targetDateToBaseDate(startInUtc);
|
|
336
|
-
const newTiming = Object.assign(Object.assign({}, timing), { start });
|
|
337
|
-
return newTiming;
|
|
338
|
-
});
|
|
339
|
-
fn._timezoneInstance = timezoneInstance;
|
|
340
|
-
return fn;
|
|
341
|
-
}
|
|
342
|
-
exports.changeTimingToTimezoneFunction = changeTimingToTimezoneFunction;
|
|
343
|
-
/**
|
|
344
|
-
*
|
|
345
|
-
* @deprecated use DateCell implementation instead.
|
|
346
|
-
* @param timing
|
|
347
|
-
* @param timezone
|
|
348
|
-
* @returns
|
|
349
|
-
*/
|
|
350
|
-
function changeTimingToTimezone(timing, timezone) {
|
|
351
|
-
return changeTimingToTimezoneFunction(timezone)(timing);
|
|
352
|
-
}
|
|
353
|
-
exports.changeTimingToTimezone = changeTimingToTimezone;
|
|
354
|
-
/**
|
|
355
|
-
*
|
|
356
|
-
* @deprecated use DateCell implementation instead.
|
|
357
|
-
* @param timing
|
|
358
|
-
* @returns
|
|
359
|
-
*/
|
|
360
|
-
function changeTimingToSystemTimezone(timing) {
|
|
361
|
-
return changeTimingToTimezoneFunction(date_timezone_1.SYSTEM_DATE_TIMEZONE_UTC_NORMAL_INSTANCE)(timing);
|
|
362
|
-
}
|
|
363
|
-
exports.changeTimingToSystemTimezone = changeTimingToSystemTimezone;
|
|
364
|
-
/**
|
|
365
|
-
*
|
|
366
|
-
* @deprecated use DateCell implementation instead.
|
|
367
|
-
* @returns
|
|
368
|
-
*/
|
|
369
|
-
function dateBlockTimingStartForNowInSystemTimezone() {
|
|
370
|
-
return {
|
|
371
|
-
start: (0, date_fns_1.startOfDay)(new Date())
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
exports.dateBlockTimingStartForNowInSystemTimezone = dateBlockTimingStartForNowInSystemTimezone;
|
|
375
|
-
/**
|
|
376
|
-
* Creates a DateBlockTimingStart for now in the given timezone.
|
|
377
|
-
*
|
|
378
|
-
* @param timezoneInput
|
|
379
|
-
* @returns
|
|
380
|
-
*/
|
|
381
|
-
function dateBlockTimingStartForNowInTimezone(timezoneInput) {
|
|
382
|
-
const dateBlockTimingStartSystemTimezone = dateBlockTimingStartForNowInSystemTimezone();
|
|
383
|
-
return changeTimingToTimezone(dateBlockTimingStartSystemTimezone, timezoneInput);
|
|
384
|
-
}
|
|
385
|
-
exports.dateBlockTimingStartForNowInTimezone = dateBlockTimingStartForNowInTimezone;
|
|
386
|
-
/**
|
|
387
|
-
* Returns the start date in the current/system timezone for the given date.
|
|
388
|
-
*
|
|
389
|
-
* @deprecated use DateCell implementation instead.
|
|
390
|
-
* @param timing
|
|
391
|
-
*/
|
|
392
|
-
function getCurrentDateBlockTimingStartDate(timing) {
|
|
393
|
-
const offset = getCurrentDateBlockTimingOffset(timing);
|
|
394
|
-
return (0, date_fns_1.addMilliseconds)(timing.start, offset);
|
|
395
|
-
}
|
|
396
|
-
exports.getCurrentDateBlockTimingStartDate = getCurrentDateBlockTimingStartDate;
|
|
397
|
-
/**
|
|
398
|
-
*
|
|
399
|
-
* @deprecated use DateCell implementation instead.
|
|
400
|
-
* @param date
|
|
401
|
-
* @returns
|
|
402
|
-
*/
|
|
403
|
-
function isValidDateBlockTimingStartDate(date) {
|
|
404
|
-
return (0, date_fns_1.getMinutes)(date) === 0 && (0, date_fns_1.getSeconds)(date) === 0 && (0, date_fns_1.getMilliseconds)(date) === 0;
|
|
405
|
-
}
|
|
406
|
-
exports.isValidDateBlockTimingStartDate = isValidDateBlockTimingStartDate;
|
|
407
|
-
/**
|
|
408
|
-
* Returns true if the input is a DateBlockTimingRelativeIndexFactory.
|
|
409
|
-
*
|
|
410
|
-
* @deprecated use DateCell implementation instead.
|
|
411
|
-
* @param input
|
|
412
|
-
* @returns
|
|
413
|
-
*/
|
|
414
|
-
function isDateBlockTimingRelativeIndexFactory(input) {
|
|
415
|
-
return typeof input === 'function' && input._timing != null && input._timingOffsetData != null;
|
|
416
|
-
}
|
|
417
|
-
exports.isDateBlockTimingRelativeIndexFactory = isDateBlockTimingRelativeIndexFactory;
|
|
418
|
-
/**
|
|
419
|
-
* Creates a DateBlockTimingRelativeIndexFactory from the input.
|
|
420
|
-
*
|
|
421
|
-
* @deprecated use DateCell implementation instead.
|
|
422
|
-
* @param input
|
|
423
|
-
* @returns
|
|
424
|
-
*/
|
|
425
|
-
function dateBlockTimingRelativeIndexFactory(input) {
|
|
426
|
-
if (isDateBlockTimingRelativeIndexFactory(input)) {
|
|
427
|
-
return input;
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
const timing = input;
|
|
431
|
-
const offsetData = getCurrentDateBlockTimingOffsetData(timing);
|
|
432
|
-
const { originalUtcOffsetInHours: toUtcOffset, currentTimezoneOffsetInHours, originalUtcDate: originalUtcDateInSystemTimeNormal } = offsetData;
|
|
433
|
-
const baseOffsetInHours = currentTimezoneOffsetInHours;
|
|
434
|
-
const factory = ((input) => {
|
|
435
|
-
const inputType = typeof input;
|
|
436
|
-
if (inputType === 'number') {
|
|
437
|
-
return input;
|
|
438
|
-
}
|
|
439
|
-
else if (inputType === 'string') {
|
|
440
|
-
const startOfDayInUtc = (0, date_format_1.parseISO8601DayStringToUTCDate)(input); // convert to system timezone
|
|
441
|
-
const diff = (0, date_fns_1.differenceInHours)(startOfDayInUtc, originalUtcDateInSystemTimeNormal, { roundingMethod: 'floor' }); // compare the system times. Round down.
|
|
442
|
-
const daysOffset = Math.floor(diff / util_1.HOURS_IN_DAY); // total number of hours difference from the original UTC date
|
|
443
|
-
return daysOffset ? daysOffset : 0; // do not return -0
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
const inputDateTimezoneOffset = input.getTimezoneOffset(); // get current system timezone offset
|
|
447
|
-
const offsetDifferenceHours = baseOffsetInHours + (0, date_fns_1.minutesToHours)(inputDateTimezoneOffset); // handle timezone offset changes
|
|
448
|
-
const baseDiff = (0, date_fns_1.differenceInHours)(input, originalUtcDateInSystemTimeNormal, { roundingMethod: 'floor' }); // compare the difference in system times. Round down.
|
|
449
|
-
const diff = baseDiff + toUtcOffset - offsetDifferenceHours; // apply any timezone changes, then back to UTC for comparison
|
|
450
|
-
const daysOffset = Math.floor(diff / util_1.HOURS_IN_DAY); // total number of hours difference from the original UTC date
|
|
451
|
-
return daysOffset ? daysOffset : 0; // do not return -0
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
factory._timing = timing;
|
|
455
|
-
factory._timingOffsetData = offsetData;
|
|
456
|
-
return factory;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
exports.dateBlockTimingRelativeIndexFactory = dateBlockTimingRelativeIndexFactory;
|
|
460
|
-
/**
|
|
461
|
-
* Creates a DateBlockTimingRelativeIndexArrayFactory from the input DateBlockTimingRelativeIndexFactory.
|
|
462
|
-
*
|
|
463
|
-
* @deprecated use DateCell implementation instead.
|
|
464
|
-
* @param indexFactory
|
|
465
|
-
*/
|
|
466
|
-
function dateBlockTimingRelativeIndexArrayFactory(indexFactory) {
|
|
467
|
-
const factory = ((input) => {
|
|
468
|
-
const inputAsArray = (0, util_1.asArray)(input);
|
|
469
|
-
const result = [];
|
|
470
|
-
inputAsArray.forEach((value) => {
|
|
471
|
-
var _a;
|
|
472
|
-
let resultIndexes;
|
|
473
|
-
if (typeof value === 'object' && !(0, date_1.isDate)(value)) {
|
|
474
|
-
if ((0, date_range_1.isDateRange)(value)) {
|
|
475
|
-
resultIndexes = (0, util_1.range)(indexFactory(value.start), indexFactory(value.end) + 1);
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
resultIndexes = (0, util_1.range)(value.i, ((_a = value.to) !== null && _a !== void 0 ? _a : value.i) + 1);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
resultIndexes = [indexFactory(value)];
|
|
483
|
-
}
|
|
484
|
-
(0, util_1.mergeArrayIntoArray)(result, resultIndexes);
|
|
485
|
-
});
|
|
486
|
-
return result;
|
|
487
|
-
});
|
|
488
|
-
factory._indexFactory = indexFactory;
|
|
489
|
-
return factory;
|
|
490
|
-
}
|
|
491
|
-
exports.dateBlockTimingRelativeIndexArrayFactory = dateBlockTimingRelativeIndexArrayFactory;
|
|
492
|
-
/**
|
|
493
|
-
* Gets the relative index of the input date compared to the input timing.
|
|
494
|
-
*
|
|
495
|
-
* @deprecated use DateCell implementation instead.
|
|
496
|
-
* @param timing
|
|
497
|
-
* @param date
|
|
498
|
-
*/
|
|
499
|
-
function getRelativeIndexForDateBlockTiming(timing, date = new Date()) {
|
|
500
|
-
return dateBlockTimingRelativeIndexFactory(timing)(date);
|
|
501
|
-
}
|
|
502
|
-
exports.getRelativeIndexForDateBlockTiming = getRelativeIndexForDateBlockTiming;
|
|
503
|
-
/**
|
|
504
|
-
* Computes a GetNextDateBlockTimingIndexResult from the input.
|
|
505
|
-
*
|
|
506
|
-
* @deprecated use DateCell implementation instead.
|
|
507
|
-
* @param input
|
|
508
|
-
*/
|
|
509
|
-
function getNextDateBlockTimingIndex(input) {
|
|
510
|
-
var _a, _b, _c;
|
|
511
|
-
const { ranges, currentIndex } = input;
|
|
512
|
-
const relativeStateGroups = (0, util_1.makeValuesGroupMap)((0, util_1.asArray)(ranges), (range) => {
|
|
513
|
-
return dateRelativeStateForDateBlockRangeComparedToIndex(range, currentIndex);
|
|
514
|
-
});
|
|
515
|
-
const pastResults = (_a = relativeStateGroups.get('past')) !== null && _a !== void 0 ? _a : [];
|
|
516
|
-
const presentResults = (_b = relativeStateGroups.get('present')) !== null && _b !== void 0 ? _b : [];
|
|
517
|
-
const futureResults = (_c = relativeStateGroups.get('future')) !== null && _c !== void 0 ? _c : [];
|
|
518
|
-
const currentResult = presentResults[0];
|
|
519
|
-
let nextResult;
|
|
520
|
-
let nextIndex = currentIndex + 1;
|
|
521
|
-
const nextResultFromPresent = presentResults.find((x) => dateRelativeStateForDateBlockRangeComparedToIndex(x, nextIndex) === 'present');
|
|
522
|
-
if (nextResultFromPresent) {
|
|
523
|
-
nextResult = nextResultFromPresent;
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
// search through the future indexes, looking for the one with the lowest index.
|
|
527
|
-
const greatestAndLeastIndexResult = getLeastAndGreatestDateBlockIndexInDateBlockRanges(futureResults);
|
|
528
|
-
if (greatestAndLeastIndexResult) {
|
|
529
|
-
nextIndex = greatestAndLeastIndexResult.leastIndex;
|
|
530
|
-
nextResult = greatestAndLeastIndexResult.leastIndexItem;
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
nextIndex = undefined;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
return {
|
|
537
|
-
currentResult,
|
|
538
|
-
nextIndex,
|
|
539
|
-
nextResult,
|
|
540
|
-
pastResults,
|
|
541
|
-
presentResults,
|
|
542
|
-
futureResults
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
exports.getNextDateBlockTimingIndex = getNextDateBlockTimingIndex;
|
|
546
|
-
/**
|
|
547
|
-
* Returns the DateRelativeState for the given index and range.
|
|
548
|
-
*
|
|
549
|
-
* @deprecated use DateCell implementation instead.
|
|
550
|
-
* @param nowIndex
|
|
551
|
-
* @param range
|
|
552
|
-
*/
|
|
553
|
-
function dateRelativeStateForDateBlockRangeComparedToIndex(range, nowIndex) {
|
|
554
|
-
const { i, to } = dateBlockRange(range.i, range.to);
|
|
555
|
-
let state;
|
|
556
|
-
if (i > nowIndex) {
|
|
557
|
-
state = 'future'; // if i greater, then the range is in the future.
|
|
558
|
-
}
|
|
559
|
-
else if (to < nowIndex) {
|
|
560
|
-
state = 'past'; // if i is less than or equal, and to is less than i, then it is in the past
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
state = 'present';
|
|
564
|
-
}
|
|
565
|
-
return state;
|
|
566
|
-
}
|
|
567
|
-
exports.dateRelativeStateForDateBlockRangeComparedToIndex = dateRelativeStateForDateBlockRangeComparedToIndex;
|
|
568
|
-
/**
|
|
569
|
-
* Creates a DateBlockTimingDateFactory.
|
|
570
|
-
*
|
|
571
|
-
* @deprecated use DateCell implementation instead.
|
|
572
|
-
* @param timing
|
|
573
|
-
* @returns
|
|
574
|
-
*/
|
|
575
|
-
function dateBlockTimingDateFactory(timing) {
|
|
576
|
-
const offsetData = getCurrentDateBlockTimingOffsetData(timing);
|
|
577
|
-
const utcStartDate = offsetData.originalUtcDate;
|
|
578
|
-
const factory = ((input) => {
|
|
579
|
-
if ((0, date_1.isDate)(input)) {
|
|
580
|
-
return input;
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
const now = new Date();
|
|
584
|
-
const nowHours = now.getUTCHours();
|
|
585
|
-
const utcStartDateWithNowTime = new Date(Date.UTC(utcStartDate.getUTCFullYear(), utcStartDate.getUTCMonth(), utcStartDate.getUTCDate(), nowHours, now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds()));
|
|
586
|
-
// if the current hours are less than the UTC offset hours, then bump one extra day forward to be sure we're in the correct day.
|
|
587
|
-
if (timing.start.getUTCHours() > nowHours) {
|
|
588
|
-
input += 1;
|
|
589
|
-
}
|
|
590
|
-
const nowWithDateForIndex = (0, date_fns_1.addHours)(utcStartDateWithNowTime, input * util_1.HOURS_IN_DAY);
|
|
591
|
-
return nowWithDateForIndex;
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
factory._timing = timing;
|
|
595
|
-
return factory;
|
|
596
|
-
}
|
|
597
|
-
exports.dateBlockTimingDateFactory = dateBlockTimingDateFactory;
|
|
598
|
-
/**
|
|
599
|
-
* Creates a DateBlockTimingDateFactory. The timezone is required to properly compute the accurate startsAt date for locations that experience daylight savings.
|
|
600
|
-
*
|
|
601
|
-
* @deprecated use DateCell implementation instead.
|
|
602
|
-
* @param timing
|
|
603
|
-
* @returns
|
|
604
|
-
*/
|
|
605
|
-
function dateBlockTimingStartDateFactory(input, timezone) {
|
|
606
|
-
const indexFactory = dateBlockTimingRelativeIndexFactory(input);
|
|
607
|
-
const timezoneInstance = timingDateTimezoneUtcNormal(timezone);
|
|
608
|
-
if (timezoneInstance.config.assertTimingMatchesTimezone !== false && !timingIsInExpectedTimezone(indexFactory._timing, timezoneInstance)) {
|
|
609
|
-
throw new Error(`unexpected timezone "${timezone}" for start date "${indexFactory._timing.start}" for dateBlockTimingStartDateFactory(). Is expected to match the timezones.`);
|
|
610
|
-
}
|
|
611
|
-
const { start: baseTimingStart } = indexFactory._timing;
|
|
612
|
-
const baseStart = timezoneInstance.baseDateToTargetDate(baseTimingStart);
|
|
613
|
-
const factory = ((input) => {
|
|
614
|
-
const index = indexFactory(input); // get the index
|
|
615
|
-
const startInUtc = (0, date_fns_1.addHours)(baseStart, index * util_1.HOURS_IN_DAY);
|
|
616
|
-
return timezoneInstance.targetDateToBaseDate(startInUtc);
|
|
617
|
-
});
|
|
618
|
-
factory._indexFactory = indexFactory;
|
|
619
|
-
return factory;
|
|
620
|
-
}
|
|
621
|
-
exports.dateBlockTimingStartDateFactory = dateBlockTimingStartDateFactory;
|
|
622
|
-
function dateBlockTimingStartsAtDateFactory(input, timezone) {
|
|
623
|
-
const indexFactory = dateBlockTimingRelativeIndexFactory(input);
|
|
624
|
-
const { start, startsAt: baseTimingStartsAt } = indexFactory._timing;
|
|
625
|
-
const timezoneInstance = timingDateTimezoneUtcNormal(timezone !== null && timezone !== void 0 ? timezone : { start });
|
|
626
|
-
if (timezoneInstance.config.assertTimingMatchesTimezone !== false && !timingIsInExpectedTimezone(indexFactory._timing, timezoneInstance)) {
|
|
627
|
-
throw new Error(`unexpected timezone "${timezone}" for start date "${indexFactory._timing.start}" for dateBlockTimingStartsAtDateFactory(). Is expected to match the timezones.`);
|
|
628
|
-
}
|
|
629
|
-
const baseStartsAtInUtc = timezoneInstance.baseDateToTargetDate(baseTimingStartsAt);
|
|
630
|
-
const factory = ((input) => {
|
|
631
|
-
const index = indexFactory(input); // get the index
|
|
632
|
-
const startAtInUtc = (0, date_fns_1.addHours)(baseStartsAtInUtc, index * util_1.HOURS_IN_DAY);
|
|
633
|
-
return timezoneInstance.targetDateToBaseDate(startAtInUtc);
|
|
634
|
-
});
|
|
635
|
-
factory._indexFactory = indexFactory;
|
|
636
|
-
return factory;
|
|
637
|
-
}
|
|
638
|
-
exports.dateBlockTimingStartsAtDateFactory = dateBlockTimingStartsAtDateFactory;
|
|
639
|
-
/**
|
|
640
|
-
* Returns the date of the input index.
|
|
641
|
-
*
|
|
642
|
-
* @deprecated use DateCell implementation instead.
|
|
643
|
-
* @param timing
|
|
644
|
-
* @param date
|
|
645
|
-
*/
|
|
646
|
-
function getRelativeDateForDateBlockTiming(timing, input) {
|
|
647
|
-
return dateBlockTimingDateFactory(timing)(input);
|
|
648
|
-
}
|
|
649
|
-
exports.getRelativeDateForDateBlockTiming = getRelativeDateForDateBlockTiming;
|
|
650
|
-
/**
|
|
651
|
-
* Creates a valid DateBlock timing from the DateDurationSpan and range input.
|
|
652
|
-
*
|
|
653
|
-
* The duration is first considered, then the date range is applied to it.
|
|
654
|
-
*
|
|
655
|
-
* If a number is passed as the input range, then the duration's startsAt date will be used and the input number used as the distance.
|
|
656
|
-
* The input range's date takes priority over the duration's startsAt start date, meaning the input date range will be adapted
|
|
657
|
-
* to fit the startsAt time.
|
|
658
|
-
*
|
|
659
|
-
* The input range date is used as the start and end date ranges, meaning they will be used as the expected date offset (have only hours, no minutes/seconds/milliseconds) and be validated as such.
|
|
660
|
-
* The end date is used just to determine the number of days, but a minimum of 1 day is always enforced as a DateBlockTiming must contain atleast 1 day.
|
|
661
|
-
*
|
|
662
|
-
* The start date from the inputDate is considered to to have the offset noted in DateBlock, and will be retained.
|
|
663
|
-
*
|
|
664
|
-
* @deprecated use DateCell implementation instead.
|
|
665
|
-
*/
|
|
666
|
-
function dateBlockTiming(durationInput, inputRange, options) {
|
|
667
|
-
const { duration } = durationInput;
|
|
668
|
-
const { timezone: timezoneInput } = options !== null && options !== void 0 ? options : {};
|
|
669
|
-
const timezoneInstance = timezoneInput ? (0, date_timezone_1.dateTimezoneUtcNormal)(timezoneInput) : undefined;
|
|
670
|
-
if (duration > util_1.MINUTES_IN_DAY) {
|
|
671
|
-
throw new Error('dateBlockTiming() duration cannot be longer than 24 hours.');
|
|
672
|
-
}
|
|
673
|
-
let { startsAt: inputStartsAt } = durationInput;
|
|
674
|
-
// it is important that startsAt is evaluated the system time normal, as addDays/addMinutes and related functionality rely on the system timezone.
|
|
675
|
-
let startsAt = timezoneInstance ? timezoneInstance.systemDateToTargetDate(inputStartsAt) : inputStartsAt;
|
|
676
|
-
let numberOfBlockedDays;
|
|
677
|
-
let inputDate;
|
|
678
|
-
let range;
|
|
679
|
-
if (typeof inputRange === 'number') {
|
|
680
|
-
numberOfBlockedDays = inputRange - 1;
|
|
681
|
-
range = (0, date_range_1.dateRange)({ type: date_range_1.DateRangeType.DAY, date: startsAt });
|
|
682
|
-
}
|
|
683
|
-
else if ((0, date_range_1.isDateRange)(inputRange)) {
|
|
684
|
-
range = inputRange;
|
|
685
|
-
inputDate = inputRange.start;
|
|
686
|
-
if (!isValidDateBlockTimingStartDate(inputRange.start)) {
|
|
687
|
-
throw new Error('Invalid dateBlockTiming start date passed to dateBlockTiming() via inputRange.');
|
|
688
|
-
}
|
|
689
|
-
numberOfBlockedDays = (0, date_fns_1.differenceInDays)(inputRange.end, inputRange.start); // min of 1 day
|
|
690
|
-
}
|
|
691
|
-
else {
|
|
692
|
-
inputDate = startsAt; // TODO: May not be needed?
|
|
693
|
-
numberOfBlockedDays = inputRange.distance - 1;
|
|
694
|
-
range = (0, date_range_1.dateRange)({ type: date_range_1.DateRangeType.DAY, date: inputDate }, true);
|
|
695
|
-
}
|
|
696
|
-
if (inputDate != null) {
|
|
697
|
-
// input date takes priority, so move the startsAt's date to be on the same date.
|
|
698
|
-
startsAt = (0, date_1.copyHoursAndMinutesFromDate)(range.start, startsAt, true);
|
|
699
|
-
const startedBeforeRange = (0, date_fns_1.isBefore)(startsAt, range.start);
|
|
700
|
-
if (startedBeforeRange) {
|
|
701
|
-
startsAt = (0, date_fns_1.addDays)(startsAt, 1); // starts 24 hours later
|
|
702
|
-
numberOfBlockedDays = Math.max(numberOfBlockedDays - 1, 0); // reduce number of applied days by 1, to a min of 0
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
else {
|
|
706
|
-
startsAt = (0, date_1.roundDownToMinute)(startsAt); // clear seconds and milliseconds from startsAt
|
|
707
|
-
// numberOfBlockedDays = numberOfBlockedDays - 1; // reduce number of applied days by 1
|
|
708
|
-
}
|
|
709
|
-
const start = range.start;
|
|
710
|
-
let lastStart = (0, date_fns_1.addDays)(startsAt, numberOfBlockedDays); // add days so the system can change for daylight savings
|
|
711
|
-
if (timezoneInstance) {
|
|
712
|
-
startsAt = timezoneInstance.targetDateToSystemDate(startsAt);
|
|
713
|
-
lastStart = timezoneInstance.targetDateToSystemDate(lastStart); // may be affected by daylight savings
|
|
714
|
-
}
|
|
715
|
-
// calculate end to be the ending date/time of the final duration span
|
|
716
|
-
const end = (0, date_fns_1.addMinutes)(lastStart, duration);
|
|
717
|
-
return {
|
|
718
|
-
start,
|
|
719
|
-
end,
|
|
720
|
-
startsAt,
|
|
721
|
-
duration
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
exports.dateBlockTiming = dateBlockTiming;
|
|
725
|
-
/**
|
|
726
|
-
*
|
|
727
|
-
* @deprecated use DateCell implementation instead.
|
|
728
|
-
* @param input
|
|
729
|
-
* @returns
|
|
730
|
-
*/
|
|
731
|
-
function dateBlockTimingInTimezoneFunction(input) {
|
|
732
|
-
const changeTimezoneFunction = changeTimingToTimezoneFunction(input);
|
|
733
|
-
const fn = ((durationInput, inputRange) => {
|
|
734
|
-
const timing = dateBlockTiming(durationInput, inputRange, { timezone: changeTimezoneFunction._timezoneInstance });
|
|
735
|
-
return changeTimezoneFunction(timing);
|
|
736
|
-
});
|
|
737
|
-
fn._timezoneInstance = changeTimezoneFunction._timezoneInstance;
|
|
738
|
-
return fn;
|
|
739
|
-
}
|
|
740
|
-
exports.dateBlockTimingInTimezoneFunction = dateBlockTimingInTimezoneFunction;
|
|
741
|
-
/**
|
|
742
|
-
*
|
|
743
|
-
* @deprecated use DateCell implementation instead.
|
|
744
|
-
* @param durationInput
|
|
745
|
-
* @param inputRange
|
|
746
|
-
* @param timezone
|
|
747
|
-
* @returns
|
|
748
|
-
*/
|
|
749
|
-
function dateBlockTimingInTimezone(durationInput, inputRange, timezone) {
|
|
750
|
-
return dateBlockTimingInTimezoneFunction(timezone)(durationInput, inputRange);
|
|
751
|
-
}
|
|
752
|
-
exports.dateBlockTimingInTimezone = dateBlockTimingInTimezone;
|
|
753
|
-
/**
|
|
754
|
-
*
|
|
755
|
-
* @deprecated use DateCell implementation instead.
|
|
756
|
-
* @param timing
|
|
757
|
-
* @returns
|
|
758
|
-
*/
|
|
759
|
-
function isValidDateBlockTimingInfo(timing) {
|
|
760
|
-
const { end, start, startsAt, duration, timezone } = timing;
|
|
761
|
-
const { currentTimezoneOffsetInHours: startOffsetInHours // offset as computed on the given date.
|
|
762
|
-
} = getCurrentDateBlockTimingOffsetData(timing);
|
|
763
|
-
const isStartRoundedToSeconds = start.getMilliseconds() === 0; // should have no milliseconds specified
|
|
764
|
-
const msDifference = (0, date_fns_1.differenceInMilliseconds)(startsAt, start); // startsAt is a specific instance to compare to the midnight instant of the target timezone
|
|
765
|
-
const endIsAfterTheStartsAtTime = (0, date_fns_1.isAfter)(end, startsAt);
|
|
766
|
-
const durationLessThan24Hours = duration <= util_1.MINUTES_IN_DAY;
|
|
767
|
-
const startHasZeroSeconds = start.getSeconds() === 0;
|
|
768
|
-
const startsAtIsAfterStart = msDifference >= 0;
|
|
769
|
-
const startsAtIsLessThan24HoursAfterStart = msDifference < util_1.MS_IN_DAY;
|
|
770
|
-
let isValid = false;
|
|
771
|
-
let isExpectedValidEnd = false;
|
|
772
|
-
let isPlausiblyValidEnd = false;
|
|
773
|
-
let isTimezoneValidatedEnd = false;
|
|
774
|
-
if (isStartRoundedToSeconds &&
|
|
775
|
-
endIsAfterTheStartsAtTime && // end must be after the startsAt time
|
|
776
|
-
durationLessThan24Hours &&
|
|
777
|
-
startHasZeroSeconds && // start cannot have seconds
|
|
778
|
-
startsAtIsAfterStart && // startsAt is after start instance, secondsDifference
|
|
779
|
-
startsAtIsLessThan24HoursAfterStart // startsAt is not 24 hours or more later. If so, should start at that time instead.
|
|
780
|
-
) {
|
|
781
|
-
const endOffset = (0, date_timezone_1.getCurrentSystemOffsetInHours)(timing.end);
|
|
782
|
-
const timezoneOffsetDelta = endOffset - startOffsetInHours;
|
|
783
|
-
const expectedFinalStartTime = (0, date_fns_1.addHours)((0, date_fns_1.addMinutes)(end, -duration), timezoneOffsetDelta);
|
|
784
|
-
const finalMsDifference = (0, date_fns_1.differenceInMilliseconds)(startsAt, expectedFinalStartTime);
|
|
785
|
-
const hoursDifference = Math.abs((finalMsDifference % util_1.MS_IN_DAY) / util_1.MS_IN_HOUR);
|
|
786
|
-
const difference = hoursDifference === 23 ? -1 : hoursDifference; // depending on daylight savings, may be off by 1 hour
|
|
787
|
-
isExpectedValidEnd = difference === 0;
|
|
788
|
-
isPlausiblyValidEnd = isExpectedValidEnd || Math.abs(difference) === 1;
|
|
789
|
-
isValid = isPlausiblyValidEnd;
|
|
790
|
-
if (isPlausiblyValidEnd && timezone) {
|
|
791
|
-
// TODO: validate properly for the timezone...
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
const result = {
|
|
795
|
-
isValid,
|
|
796
|
-
isStartRoundedToSeconds,
|
|
797
|
-
msDifference,
|
|
798
|
-
endIsAfterTheStartsAtTime,
|
|
799
|
-
durationLessThan24Hours,
|
|
800
|
-
startHasZeroSeconds,
|
|
801
|
-
startsAtIsAfterStart,
|
|
802
|
-
startsAtIsLessThan24HoursAfterStart,
|
|
803
|
-
isExpectedValidEnd,
|
|
804
|
-
isPlausiblyValidEnd
|
|
805
|
-
};
|
|
806
|
-
return result;
|
|
807
|
-
}
|
|
808
|
-
exports.isValidDateBlockTimingInfo = isValidDateBlockTimingInfo;
|
|
809
|
-
/**
|
|
810
|
-
*
|
|
811
|
-
* @deprecated use DateCell implementation instead.
|
|
812
|
-
* @param timing
|
|
813
|
-
* @returns
|
|
814
|
-
*/
|
|
815
|
-
function isValidDateBlockTiming(timing) {
|
|
816
|
-
const { isValid } = isValidDateBlockTimingInfo(timing);
|
|
817
|
-
return isValid;
|
|
818
|
-
}
|
|
819
|
-
exports.isValidDateBlockTiming = isValidDateBlockTiming;
|
|
820
|
-
/**
|
|
821
|
-
* Creates a DateBlockDayOfWeekFactory
|
|
822
|
-
*
|
|
823
|
-
* @deprecated use DateCell implementation instead.
|
|
824
|
-
* @param dayForIndexZero
|
|
825
|
-
* @returns
|
|
826
|
-
*/
|
|
827
|
-
function dateBlockDayOfWeekFactory(inputDayForIndexZero) {
|
|
828
|
-
const dayForIndexZero = typeof inputDayForIndexZero === 'number' ? inputDayForIndexZero : inputDayForIndexZero.getUTCDay();
|
|
829
|
-
return (index) => (0, util_1.getNextDay)(dayForIndexZero, index);
|
|
830
|
-
}
|
|
831
|
-
exports.dateBlockDayOfWeekFactory = dateBlockDayOfWeekFactory;
|
|
832
|
-
/**
|
|
833
|
-
* Convenience function for calling expandDateBlocks() with the input DateBlockCollection.
|
|
834
|
-
*
|
|
835
|
-
* @deprecated use DateCell implementation instead.
|
|
836
|
-
* @param collection
|
|
837
|
-
* @returns
|
|
838
|
-
*/
|
|
839
|
-
function expandDateBlockCollection(collection) {
|
|
840
|
-
return expandDateBlocks(collection.timing, collection.blocks);
|
|
841
|
-
}
|
|
842
|
-
exports.expandDateBlockCollection = expandDateBlockCollection;
|
|
843
|
-
/**
|
|
844
|
-
* Convenience function for calling dateBlocksExpansionFactory() then passing the blocks.
|
|
845
|
-
*
|
|
846
|
-
* @deprecated use DateCell implementation instead.
|
|
847
|
-
* @param blocks
|
|
848
|
-
* @param timing
|
|
849
|
-
* @returns
|
|
850
|
-
*/
|
|
851
|
-
function expandDateBlocks(timing, blocks) {
|
|
852
|
-
return dateBlocksExpansionFactory({ timing })(blocks);
|
|
853
|
-
}
|
|
854
|
-
exports.expandDateBlocks = expandDateBlocks;
|
|
855
|
-
/**
|
|
856
|
-
* Creates a DateBlocksExpansionFactory
|
|
857
|
-
*
|
|
858
|
-
* @deprecated use DateCell implementation instead.
|
|
859
|
-
* @param config
|
|
860
|
-
* @returns
|
|
861
|
-
*/
|
|
862
|
-
function dateBlocksExpansionFactory(config) {
|
|
863
|
-
const { timing, rangeLimit, filter: inputFilter, durationSpanFilter: inputDurationSpanFilter, maxDateBlocksToReturn = Number.MAX_SAFE_INTEGER, blocksEvaluationLimit = Number.MAX_SAFE_INTEGER } = config;
|
|
864
|
-
const { startsAt: baseStart, duration } = timing;
|
|
865
|
-
const indexRange = rangeLimit !== false ? dateBlockIndexRange(timing, rangeLimit) : { minIndex: Number.MIN_SAFE_INTEGER, maxIndex: Number.MAX_SAFE_INTEGER };
|
|
866
|
-
const isInRange = (0, util_1.indexRangeCheckFunction)({ indexRange, inclusiveMaxIndex: false });
|
|
867
|
-
const filter = (0, util_1.mergeFilterFunctions)((x) => isInRange(x.i), inputFilter);
|
|
868
|
-
const durationSpanFilter = inputDurationSpanFilter !== null && inputDurationSpanFilter !== void 0 ? inputDurationSpanFilter : (() => true);
|
|
869
|
-
return (input) => {
|
|
870
|
-
const blocks = Array.isArray(input) ? input : input.blocks;
|
|
871
|
-
const spans = [];
|
|
872
|
-
let blocksEvaluated = 0;
|
|
873
|
-
function filterAndPush(block, blockIndex) {
|
|
874
|
-
// increase the evaluation count early in-case we set the blocksEvaluationLimit below.
|
|
875
|
-
blocksEvaluated += 1;
|
|
876
|
-
if (filter(block, blockIndex)) {
|
|
877
|
-
const startsAt = (0, date_fns_1.addDays)(baseStart, block.i);
|
|
878
|
-
const durationSpan = Object.assign(Object.assign({}, block), { startsAt,
|
|
879
|
-
duration });
|
|
880
|
-
// try the duration span filter
|
|
881
|
-
if (durationSpanFilter(durationSpan, blockIndex)) {
|
|
882
|
-
if (spans.length >= maxDateBlocksToReturn) {
|
|
883
|
-
blocksEvaluated = blocksEvaluationLimit; // trigger return below
|
|
884
|
-
}
|
|
885
|
-
else {
|
|
886
|
-
spans.push(durationSpan);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
blocks.findIndex((block) => {
|
|
892
|
-
if (dateBlockRangeHasRange(block)) {
|
|
893
|
-
// Expands the block's range as if it is at a single index
|
|
894
|
-
(0, util_1.range)(block.i, block.to + 1).findIndex((i) => {
|
|
895
|
-
const blockAtIndex = Object.assign(Object.assign({}, block), { i, to: i }); // copy block, set to as i
|
|
896
|
-
filterAndPush(blockAtIndex, blocksEvaluated);
|
|
897
|
-
// continue iterating until we hit the evaluation limit.
|
|
898
|
-
return blocksEvaluated >= blocksEvaluationLimit;
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
else {
|
|
902
|
-
filterAndPush(block, blocksEvaluated);
|
|
903
|
-
}
|
|
904
|
-
return blocksEvaluated >= blocksEvaluationLimit; // continue iterating until we hit the evaluation limit or run out of items.
|
|
905
|
-
});
|
|
906
|
-
return spans;
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
exports.dateBlocksExpansionFactory = dateBlocksExpansionFactory;
|
|
910
|
-
/**
|
|
911
|
-
*
|
|
912
|
-
* @deprecated use DateCell implementation instead.
|
|
913
|
-
* @param config
|
|
914
|
-
* @returns
|
|
915
|
-
*/
|
|
916
|
-
function dateBlockDayTimingInfoFactory(config) {
|
|
917
|
-
const { timing, rangeLimit } = config;
|
|
918
|
-
const { duration } = timing;
|
|
919
|
-
const indexRange = rangeLimit !== false ? dateBlockIndexRange(timing, rangeLimit) : { minIndex: Number.MIN_SAFE_INTEGER, maxIndex: Number.MAX_SAFE_INTEGER };
|
|
920
|
-
const checkIsInRange = (0, util_1.indexRangeCheckFunction)({ indexRange, inclusiveMaxIndex: false });
|
|
921
|
-
const dayIndexFactory = dateBlockTimingRelativeIndexFactory(timing);
|
|
922
|
-
const dayFactory = dateBlockTimingDateFactory(timing);
|
|
923
|
-
const startsAtFactory = dateBlockTimingStartsAtDateFactory(dayIndexFactory);
|
|
924
|
-
return (input, inputNow) => {
|
|
925
|
-
const date = typeof input === 'number' ? dayFactory(input) : input;
|
|
926
|
-
const dayIndex = dayIndexFactory(input);
|
|
927
|
-
const isInRange = checkIsInRange(dayIndex);
|
|
928
|
-
const now = inputNow !== null && inputNow !== void 0 ? inputNow : date;
|
|
929
|
-
const startsAtOnDay = startsAtFactory(dayIndex); // convert back to the proper date
|
|
930
|
-
const endsAtOnDay = (0, date_fns_1.addMinutes)(startsAtOnDay, duration);
|
|
931
|
-
const potentiallyInProgress = !(0, date_fns_1.isAfter)(startsAtOnDay, now); // is potentially in progress if the now is equal-to or after the start time.
|
|
932
|
-
const isInProgress = potentiallyInProgress && !(0, date_fns_1.isAfter)(now, endsAtOnDay);
|
|
933
|
-
const hasOccuredToday = potentiallyInProgress && !isInProgress;
|
|
934
|
-
const currentIndex = isInProgress || hasOccuredToday ? dayIndex : dayIndex - 1; // If not in progress and hasn't occured today, current index is the previous index.
|
|
935
|
-
const nextIndex = currentIndex + 1;
|
|
936
|
-
const nextIndexInRange = checkIsInRange(nextIndex) ? nextIndex : undefined;
|
|
937
|
-
const isComplete = currentIndex >= 0 && !nextIndexInRange && (!isInRange || hasOccuredToday);
|
|
938
|
-
return {
|
|
939
|
-
now,
|
|
940
|
-
date,
|
|
941
|
-
dayIndex,
|
|
942
|
-
currentIndex,
|
|
943
|
-
nextIndex,
|
|
944
|
-
hasOccuredToday,
|
|
945
|
-
isInProgress,
|
|
946
|
-
isInRange,
|
|
947
|
-
startsAtOnDay,
|
|
948
|
-
endsAtOnDay,
|
|
949
|
-
nextIndexInRange,
|
|
950
|
-
isComplete
|
|
951
|
-
};
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
exports.dateBlockDayTimingInfoFactory = dateBlockDayTimingInfoFactory;
|
|
955
|
-
/**
|
|
956
|
-
*
|
|
957
|
-
* @deprecated use DateCell implementation instead.
|
|
958
|
-
* @param range
|
|
959
|
-
* @returns
|
|
960
|
-
*/
|
|
961
|
-
function dateBlockRangeToDateBlockIndexRange(range) {
|
|
962
|
-
var _a;
|
|
963
|
-
return { minIndex: range.i, maxIndex: ((_a = range.to) !== null && _a !== void 0 ? _a : range.i) + 1 };
|
|
964
|
-
}
|
|
965
|
-
exports.dateBlockRangeToDateBlockIndexRange = dateBlockRangeToDateBlockIndexRange;
|
|
966
|
-
/**
|
|
967
|
-
*
|
|
968
|
-
* @deprecated use DateCell implementation instead.
|
|
969
|
-
* @param range
|
|
970
|
-
* @returns
|
|
971
|
-
*/
|
|
972
|
-
function dateBlockIndexRangeToDateBlockRange(range) {
|
|
973
|
-
return { i: range.minIndex, to: range.maxIndex - 1 };
|
|
974
|
-
}
|
|
975
|
-
exports.dateBlockIndexRangeToDateBlockRange = dateBlockIndexRangeToDateBlockRange;
|
|
976
|
-
/**
|
|
977
|
-
* Generates a DateBlockIndexRange based on the input timing.
|
|
978
|
-
*
|
|
979
|
-
* An arbitrary limit can also be applied.
|
|
980
|
-
*
|
|
981
|
-
* @deprecated use DateCell implementation instead.
|
|
982
|
-
* @param timing
|
|
983
|
-
* @param limit
|
|
984
|
-
* @param fitToTimingRange
|
|
985
|
-
*/
|
|
986
|
-
function dateBlockIndexRange(timing, limit, fitToTimingRange = true) {
|
|
987
|
-
const { start: zeroDate, end: endDate } = timing;
|
|
988
|
-
let minIndex = 0;
|
|
989
|
-
let maxIndex = (0, date_fns_1.differenceInDays)(endDate, zeroDate) + 1;
|
|
990
|
-
if (limit) {
|
|
991
|
-
const { start, end } = dateBlockTiming(timing, limit);
|
|
992
|
-
const limitMin = (0, date_fns_1.differenceInDays)(start, zeroDate);
|
|
993
|
-
const hoursDiff = (0, date_fns_1.differenceInHours)(end, zeroDate) / util_1.HOURS_IN_DAY;
|
|
994
|
-
const limitMax = Math.ceil(hoursDiff);
|
|
995
|
-
if (fitToTimingRange) {
|
|
996
|
-
minIndex = Math.min(limitMin, maxIndex);
|
|
997
|
-
maxIndex = Math.min(limitMax, maxIndex);
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
minIndex = limitMin;
|
|
1001
|
-
maxIndex = limitMax;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return { minIndex, maxIndex };
|
|
1005
|
-
}
|
|
1006
|
-
exports.dateBlockIndexRange = dateBlockIndexRange;
|
|
1007
|
-
/**
|
|
1008
|
-
* Returns blocks that are only in the given DateBlockRange.
|
|
1009
|
-
*
|
|
1010
|
-
* @deprecated use DateCell implementation instead.
|
|
1011
|
-
* @param blocks
|
|
1012
|
-
* @param range
|
|
1013
|
-
* @returns
|
|
1014
|
-
*/
|
|
1015
|
-
function filterDateBlocksInDateBlockRange(blocks, range) {
|
|
1016
|
-
const dateBlockIsWithinDateBlockRange = isDateBlockWithinDateBlockRangeFunction(range);
|
|
1017
|
-
return blocks.filter(dateBlockIsWithinDateBlockRange);
|
|
1018
|
-
}
|
|
1019
|
-
exports.filterDateBlocksInDateBlockRange = filterDateBlocksInDateBlockRange;
|
|
1020
|
-
/**
|
|
1021
|
-
*
|
|
1022
|
-
* @deprecated use DateCell implementation instead.
|
|
1023
|
-
* @param inputRange
|
|
1024
|
-
* @returns
|
|
1025
|
-
*/
|
|
1026
|
-
function isDateBlockWithinDateBlockRangeFunction(inputRange) {
|
|
1027
|
-
const range = dateBlockRangeWithRange(inputRange);
|
|
1028
|
-
return (input) => {
|
|
1029
|
-
var _a;
|
|
1030
|
-
if (typeof input === 'number') {
|
|
1031
|
-
input = { i: input };
|
|
1032
|
-
}
|
|
1033
|
-
if (input.i >= range.i) {
|
|
1034
|
-
const to = (_a = input.to) !== null && _a !== void 0 ? _a : input.i;
|
|
1035
|
-
return to <= range.to;
|
|
1036
|
-
}
|
|
1037
|
-
return false;
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
exports.isDateBlockWithinDateBlockRangeFunction = isDateBlockWithinDateBlockRangeFunction;
|
|
1041
|
-
/**
|
|
1042
|
-
* Returns true if the first DateBlock or DateBlockRange contains the second input.
|
|
1043
|
-
*
|
|
1044
|
-
* @deprecated use DateCell implementation instead.
|
|
1045
|
-
* @param range
|
|
1046
|
-
* @param isContainedWithin
|
|
1047
|
-
* @returns
|
|
1048
|
-
*/
|
|
1049
|
-
function isDateBlockWithinDateBlockRange(range, contains) {
|
|
1050
|
-
return isDateBlockWithinDateBlockRangeFunction(range)(dateBlockRangeWithRange(contains));
|
|
1051
|
-
}
|
|
1052
|
-
exports.isDateBlockWithinDateBlockRange = isDateBlockWithinDateBlockRange;
|
|
1053
|
-
/**
|
|
1054
|
-
*
|
|
1055
|
-
* @deprecated use DateCell implementation instead.
|
|
1056
|
-
* @param config
|
|
1057
|
-
* @returns
|
|
1058
|
-
*/
|
|
1059
|
-
function isDateWithinDateBlockRangeFunction(config) {
|
|
1060
|
-
const { start: inputStart, range: inputRange } = config;
|
|
1061
|
-
let start = inputStart;
|
|
1062
|
-
let dateRange;
|
|
1063
|
-
let rangeInput;
|
|
1064
|
-
if (typeof inputRange === 'number') {
|
|
1065
|
-
rangeInput = { i: inputRange };
|
|
1066
|
-
}
|
|
1067
|
-
else if ((0, date_1.isDate)(inputRange)) {
|
|
1068
|
-
dateRange = { start: inputRange };
|
|
1069
|
-
}
|
|
1070
|
-
else if ((0, date_range_1.isDateRangeStart)(inputRange)) {
|
|
1071
|
-
dateRange = inputRange;
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
rangeInput = inputRange;
|
|
1075
|
-
}
|
|
1076
|
-
if (start == null) {
|
|
1077
|
-
if (dateRange) {
|
|
1078
|
-
start = inputRange;
|
|
1079
|
-
}
|
|
1080
|
-
else {
|
|
1081
|
-
throw new Error('Invalid isDateWithinDateBlockRangeFunction() config. Start date could not be determined from input.');
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
const indexFactory = dateBlockTimingRelativeIndexFactory({ start });
|
|
1085
|
-
function convertDateRangeToIndexRange(range) {
|
|
1086
|
-
const i = indexFactory(range.start);
|
|
1087
|
-
const end = range.end;
|
|
1088
|
-
const to = end != null ? indexFactory(end) : undefined;
|
|
1089
|
-
return { i, to };
|
|
1090
|
-
}
|
|
1091
|
-
if (!rangeInput) {
|
|
1092
|
-
if (dateRange) {
|
|
1093
|
-
rangeInput = convertDateRangeToIndexRange(dateRange);
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
throw new Error('Invalid isDateWithinDateBlockRangeFunction() config. Range determined from input.'); // shouldn't occur
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
const isDateBlockWithinDateBlockRange = isDateBlockWithinDateBlockRangeFunction(rangeInput);
|
|
1100
|
-
return (input) => {
|
|
1101
|
-
let range;
|
|
1102
|
-
if ((0, date_1.isDate)(input)) {
|
|
1103
|
-
range = indexFactory(input);
|
|
1104
|
-
}
|
|
1105
|
-
else if ((0, date_range_1.isDateRangeStart)(input)) {
|
|
1106
|
-
range = convertDateRangeToIndexRange(input);
|
|
1107
|
-
}
|
|
1108
|
-
else {
|
|
1109
|
-
range = input;
|
|
1110
|
-
}
|
|
1111
|
-
if (typeof input === 'number') {
|
|
1112
|
-
range = { i: input };
|
|
1113
|
-
}
|
|
1114
|
-
return isDateBlockWithinDateBlockRange(range);
|
|
1115
|
-
};
|
|
1116
|
-
}
|
|
1117
|
-
exports.isDateWithinDateBlockRangeFunction = isDateWithinDateBlockRangeFunction;
|
|
1118
|
-
/**
|
|
1119
|
-
*
|
|
1120
|
-
* @deprecated use DateCell implementation instead.
|
|
1121
|
-
*/
|
|
1122
|
-
class DateBlockRange extends DateBlock {
|
|
1123
|
-
constructor(template) {
|
|
1124
|
-
super(template);
|
|
1125
|
-
if (template) {
|
|
1126
|
-
this.to = template.to;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
tslib_1.__decorate([
|
|
1131
|
-
(0, class_transformer_1.Expose)(),
|
|
1132
|
-
(0, class_validator_1.IsNumber)(),
|
|
1133
|
-
(0, class_validator_1.IsOptional)(),
|
|
1134
|
-
(0, class_validator_1.Min)(0),
|
|
1135
|
-
tslib_1.__metadata("design:type", Number)
|
|
1136
|
-
], DateBlockRange.prototype, "to", void 0);
|
|
1137
|
-
exports.DateBlockRange = DateBlockRange;
|
|
1138
|
-
/**
|
|
1139
|
-
* Returns true if the input is a valid DateBlockRange.
|
|
1140
|
-
*
|
|
1141
|
-
* @deprecated use DateCell implementation instead.
|
|
1142
|
-
* @param input
|
|
1143
|
-
* @returns
|
|
1144
|
-
*/
|
|
1145
|
-
function isValidDateBlockRange(input) {
|
|
1146
|
-
const { i, to } = input;
|
|
1147
|
-
if (!isValidDateBlockIndex(i)) {
|
|
1148
|
-
return false;
|
|
1149
|
-
}
|
|
1150
|
-
else if (to != null && (!isValidDateBlockIndex(to) || to < i)) {
|
|
1151
|
-
return false;
|
|
1152
|
-
}
|
|
1153
|
-
return true;
|
|
1154
|
-
}
|
|
1155
|
-
exports.isValidDateBlockRange = isValidDateBlockRange;
|
|
1156
|
-
/**
|
|
1157
|
-
* Returns true if the input is a sorted DateBlockRange array and there are no repeat indexes.
|
|
1158
|
-
*
|
|
1159
|
-
* @deprecated use DateCell implementation instead.
|
|
1160
|
-
* @param input
|
|
1161
|
-
* @returns
|
|
1162
|
-
*/
|
|
1163
|
-
function isValidDateBlockRangeSeries(input) {
|
|
1164
|
-
if (!Array.isArray(input)) {
|
|
1165
|
-
return false;
|
|
1166
|
-
}
|
|
1167
|
-
const invalidRange = input.findIndex((range) => !isValidDateBlockRange(range));
|
|
1168
|
-
if (invalidRange !== -1) {
|
|
1169
|
-
return false;
|
|
1170
|
-
}
|
|
1171
|
-
let greatestIndex = -1;
|
|
1172
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
1173
|
-
const range = input[i];
|
|
1174
|
-
if (range.i <= greatestIndex) {
|
|
1175
|
-
return false;
|
|
1176
|
-
}
|
|
1177
|
-
else {
|
|
1178
|
-
const nextGreatestIndex = range.to || range.i; // to is greater than or equal to i in a valid date block range.
|
|
1179
|
-
greatestIndex = nextGreatestIndex;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
return true;
|
|
1183
|
-
}
|
|
1184
|
-
exports.isValidDateBlockRangeSeries = isValidDateBlockRangeSeries;
|
|
1185
|
-
/**
|
|
1186
|
-
* Returns the lowest index between all the input date block ranges. Returns 0 by default if there is no minimum or input blocks.
|
|
1187
|
-
*
|
|
1188
|
-
* The input range is not expected to be sorted.
|
|
1189
|
-
*
|
|
1190
|
-
* @deprecated use DateCell implementation instead.
|
|
1191
|
-
*/
|
|
1192
|
-
function getLeastDateBlockIndexInDateBlockRanges(input) {
|
|
1193
|
-
var _a, _b;
|
|
1194
|
-
return (_b = (_a = getLeastAndGreatestDateBlockIndexInDateBlockRanges(input)) === null || _a === void 0 ? void 0 : _a.leastIndex) !== null && _b !== void 0 ? _b : 0;
|
|
1195
|
-
}
|
|
1196
|
-
exports.getLeastDateBlockIndexInDateBlockRanges = getLeastDateBlockIndexInDateBlockRanges;
|
|
1197
|
-
/**
|
|
1198
|
-
* Returns the largest index between all the input date block ranges. Returns 0 by default.
|
|
1199
|
-
*
|
|
1200
|
-
* The input range is not expected to be sorted.
|
|
1201
|
-
*
|
|
1202
|
-
* @deprecated use DateCell implementation instead.
|
|
1203
|
-
*/
|
|
1204
|
-
function getGreatestDateBlockIndexInDateBlockRanges(input) {
|
|
1205
|
-
var _a, _b;
|
|
1206
|
-
return (_b = (_a = getLeastAndGreatestDateBlockIndexInDateBlockRanges(input)) === null || _a === void 0 ? void 0 : _a.greatestIndex) !== null && _b !== void 0 ? _b : 0;
|
|
1207
|
-
}
|
|
1208
|
-
exports.getGreatestDateBlockIndexInDateBlockRanges = getGreatestDateBlockIndexInDateBlockRanges;
|
|
1209
|
-
/**
|
|
1210
|
-
* Returns the largest index between all the input date block ranges. Returns null if the input is empty.
|
|
1211
|
-
*
|
|
1212
|
-
* The input range is not expected to be sorted.
|
|
1213
|
-
*
|
|
1214
|
-
* @deprecated use DateCell implementation instead.
|
|
1215
|
-
*/
|
|
1216
|
-
function getLeastAndGreatestDateBlockIndexInDateBlockRanges(input) {
|
|
1217
|
-
if (!input.length) {
|
|
1218
|
-
return null;
|
|
1219
|
-
}
|
|
1220
|
-
let leastIndex = Number.MAX_SAFE_INTEGER;
|
|
1221
|
-
let greatestIndex = 0;
|
|
1222
|
-
let leastIndexItem = input[0];
|
|
1223
|
-
let greatestIndexItem = input[0];
|
|
1224
|
-
for (let i = 0; i < input.length; i += 1) {
|
|
1225
|
-
const range = input[i];
|
|
1226
|
-
const leastRangeIndex = range.i;
|
|
1227
|
-
const greatestRangeIndex = range.to || range.i;
|
|
1228
|
-
if (leastRangeIndex < leastIndex) {
|
|
1229
|
-
leastIndex = leastRangeIndex;
|
|
1230
|
-
leastIndexItem = range;
|
|
1231
|
-
}
|
|
1232
|
-
if (greatestRangeIndex > greatestIndex) {
|
|
1233
|
-
greatestIndex = greatestRangeIndex;
|
|
1234
|
-
greatestIndexItem = range;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return {
|
|
1238
|
-
leastIndex,
|
|
1239
|
-
leastIndexItem,
|
|
1240
|
-
greatestIndex,
|
|
1241
|
-
greatestIndexItem
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
exports.getLeastAndGreatestDateBlockIndexInDateBlockRanges = getLeastAndGreatestDateBlockIndexInDateBlockRanges;
|
|
1245
|
-
/**
|
|
1246
|
-
* Creates a DateBlockRange
|
|
1247
|
-
*
|
|
1248
|
-
* @deprecated use DateCell implementation instead.
|
|
1249
|
-
* @param i
|
|
1250
|
-
* @param to
|
|
1251
|
-
* @returns
|
|
1252
|
-
*/
|
|
1253
|
-
function dateBlockRange(i, to) {
|
|
1254
|
-
return { i, to: to !== null && to !== void 0 ? to : i };
|
|
1255
|
-
}
|
|
1256
|
-
exports.dateBlockRange = dateBlockRange;
|
|
1257
|
-
/**
|
|
1258
|
-
* Creates a DateBlockRangeWithRange from the input DateBlockIndex.
|
|
1259
|
-
*
|
|
1260
|
-
* @deprecated use DateCell implementation instead.
|
|
1261
|
-
* @param dateBlockIndex
|
|
1262
|
-
* @returns
|
|
1263
|
-
*/
|
|
1264
|
-
function dateBlockRangeWithRangeFromIndex(dateBlockIndex) {
|
|
1265
|
-
return dateBlockRange(dateBlockIndex, dateBlockIndex);
|
|
1266
|
-
}
|
|
1267
|
-
exports.dateBlockRangeWithRangeFromIndex = dateBlockRangeWithRangeFromIndex;
|
|
1268
|
-
/**
|
|
1269
|
-
* Creates a DateBlockRangeWithRange from the input DateBlockIndex, DateBlock, or DateBlockRange.
|
|
1270
|
-
*
|
|
1271
|
-
* @deprecated use DateCell implementation instead.
|
|
1272
|
-
* @param input
|
|
1273
|
-
* @returns
|
|
1274
|
-
*/
|
|
1275
|
-
function dateBlockRangeWithRange(input) {
|
|
1276
|
-
if (typeof input === 'number') {
|
|
1277
|
-
return dateBlockRangeWithRangeFromIndex(input);
|
|
1278
|
-
}
|
|
1279
|
-
else {
|
|
1280
|
-
return dateBlockRange(input.i, input.to);
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
exports.dateBlockRangeWithRange = dateBlockRangeWithRange;
|
|
1284
|
-
/**
|
|
1285
|
-
* Creates a DateBlockRangeIncludedByRangeFunction
|
|
1286
|
-
*
|
|
1287
|
-
* @deprecated use DateCell implementation instead.
|
|
1288
|
-
* @param inputRange
|
|
1289
|
-
* @returns
|
|
1290
|
-
*/
|
|
1291
|
-
function dateBlockRangeIncludedByRangeFunction(inputRange) {
|
|
1292
|
-
const { i, to } = dateBlockRangeWithRange(inputRange);
|
|
1293
|
-
return (input) => {
|
|
1294
|
-
var _a;
|
|
1295
|
-
const range = dateBlockRangeWithRange(input);
|
|
1296
|
-
return range.i <= i && ((_a = range === null || range === void 0 ? void 0 : range.to) !== null && _a !== void 0 ? _a : range.i) >= to;
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
exports.dateBlockRangeIncludedByRangeFunction = dateBlockRangeIncludedByRangeFunction;
|
|
1300
|
-
/**
|
|
1301
|
-
* Creates a DateBlockRangeOverlapsRangeFunction
|
|
1302
|
-
*
|
|
1303
|
-
* @deprecated use DateCell implementation instead.
|
|
1304
|
-
* @param inputRange
|
|
1305
|
-
* @returns
|
|
1306
|
-
*/
|
|
1307
|
-
function dateBlockRangeOverlapsRangeFunction(inputRange) {
|
|
1308
|
-
const { i, to } = dateBlockRangeWithRange(inputRange);
|
|
1309
|
-
return (input) => {
|
|
1310
|
-
var _a;
|
|
1311
|
-
const range = dateBlockRangeWithRange(input);
|
|
1312
|
-
return range.i <= to && ((_a = range === null || range === void 0 ? void 0 : range.to) !== null && _a !== void 0 ? _a : range.i) >= i;
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1315
|
-
exports.dateBlockRangeOverlapsRangeFunction = dateBlockRangeOverlapsRangeFunction;
|
|
1316
|
-
/**
|
|
1317
|
-
* Returns true if either of the ranges overlap eachother.
|
|
1318
|
-
*
|
|
1319
|
-
* @deprecated use DateCell implementation instead.
|
|
1320
|
-
* @param rangeA
|
|
1321
|
-
* @param rangeB
|
|
1322
|
-
* @returns
|
|
1323
|
-
*/
|
|
1324
|
-
function dateBlockRangeOverlapsRange(rangeA, rangeB) {
|
|
1325
|
-
return dateBlockRangeOverlapsRangeFunction(rangeA)(rangeB);
|
|
1326
|
-
}
|
|
1327
|
-
exports.dateBlockRangeOverlapsRange = dateBlockRangeOverlapsRange;
|
|
1328
|
-
/**
|
|
1329
|
-
* Sorts the input ranges by index and distance (to values).
|
|
1330
|
-
*
|
|
1331
|
-
* In many cases sortAscendingIndexNumberRefFunction may be preferential since
|
|
1332
|
-
*
|
|
1333
|
-
* @deprecated use DateCell implementation instead.
|
|
1334
|
-
* @returns
|
|
1335
|
-
*/
|
|
1336
|
-
function sortDateBlockRangeAndSizeFunction() {
|
|
1337
|
-
return (a, b) => { var _a, _b; return a.i - b.i || ((_a = a.to) !== null && _a !== void 0 ? _a : a.i) - ((_b = b.to) !== null && _b !== void 0 ? _b : b.i); };
|
|
1338
|
-
}
|
|
1339
|
-
exports.sortDateBlockRangeAndSizeFunction = sortDateBlockRangeAndSizeFunction;
|
|
1340
|
-
/**
|
|
1341
|
-
* Sorts the input date ranges. This will retain the before/after order while also sorting items by index.
|
|
1342
|
-
*
|
|
1343
|
-
* @deprecated use DateCell implementation instead.
|
|
1344
|
-
* @param input
|
|
1345
|
-
* @returns
|
|
1346
|
-
*/
|
|
1347
|
-
function sortDateBlockRanges(input) {
|
|
1348
|
-
return input.sort((0, util_1.sortAscendingIndexNumberRefFunction)());
|
|
1349
|
-
}
|
|
1350
|
-
exports.sortDateBlockRanges = sortDateBlockRanges;
|
|
1351
|
-
/**
|
|
1352
|
-
* Groups the input values into DateBlockRange values.
|
|
1353
|
-
*
|
|
1354
|
-
* @deprecated use DateCell implementation instead.
|
|
1355
|
-
* @param input
|
|
1356
|
-
*/
|
|
1357
|
-
function groupToDateBlockRanges(input) {
|
|
1358
|
-
var _a;
|
|
1359
|
-
if (input.length === 0) {
|
|
1360
|
-
return [];
|
|
1361
|
-
}
|
|
1362
|
-
// sort by index in ascending order
|
|
1363
|
-
const blocks = sortDateBlockRanges(input);
|
|
1364
|
-
function newBlockFromBlocksArrayIndex(blocksArrayIndex) {
|
|
1365
|
-
const { i, to } = blocks[blocksArrayIndex];
|
|
1366
|
-
return {
|
|
1367
|
-
i,
|
|
1368
|
-
to: to !== null && to !== void 0 ? to : i
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
// start at the first block
|
|
1372
|
-
let current = newBlockFromBlocksArrayIndex(0);
|
|
1373
|
-
const results = [];
|
|
1374
|
-
for (let i = 1; i < blocks.length; i += 1) {
|
|
1375
|
-
const block = blocks[i];
|
|
1376
|
-
const isContinuous = block.i <= current.to + 1;
|
|
1377
|
-
if (isContinuous) {
|
|
1378
|
-
// extend the current block.
|
|
1379
|
-
current.to = (_a = blocks[i].to) !== null && _a !== void 0 ? _a : blocks[i].i;
|
|
1380
|
-
}
|
|
1381
|
-
else {
|
|
1382
|
-
// complete/create new block.
|
|
1383
|
-
results.push(current);
|
|
1384
|
-
current = newBlockFromBlocksArrayIndex(i);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
results.push(current);
|
|
1388
|
-
return results;
|
|
1389
|
-
}
|
|
1390
|
-
exports.groupToDateBlockRanges = groupToDateBlockRanges;
|
|
1391
|
-
/**
|
|
1392
|
-
* Returns an array containing all indexes in the date block range.
|
|
1393
|
-
*
|
|
1394
|
-
* @deprecated use DateCell implementation instead.
|
|
1395
|
-
*/
|
|
1396
|
-
function allIndexesInDateBlockRange(input) {
|
|
1397
|
-
return input.to != null ? (0, util_1.range)(input.i, input.to + 1) : [input.i];
|
|
1398
|
-
}
|
|
1399
|
-
exports.allIndexesInDateBlockRange = allIndexesInDateBlockRange;
|
|
1400
|
-
/**
|
|
1401
|
-
* Returns the set of all indexes within the input.
|
|
1402
|
-
*
|
|
1403
|
-
* @deprecated use DateCell implementation instead.
|
|
1404
|
-
* @param input
|
|
1405
|
-
* @returns
|
|
1406
|
-
*/
|
|
1407
|
-
function allIndexesInDateBlockRanges(input) {
|
|
1408
|
-
const set = new Set();
|
|
1409
|
-
input.forEach((x) => {
|
|
1410
|
-
if (typeof x === 'number') {
|
|
1411
|
-
set.add(x);
|
|
1412
|
-
}
|
|
1413
|
-
else {
|
|
1414
|
-
const allIndexes = allIndexesInDateBlockRange(x);
|
|
1415
|
-
(0, util_1.addToSet)(set, allIndexes);
|
|
1416
|
-
}
|
|
1417
|
-
});
|
|
1418
|
-
return set;
|
|
1419
|
-
}
|
|
1420
|
-
exports.allIndexesInDateBlockRanges = allIndexesInDateBlockRanges;
|
|
1421
|
-
/**
|
|
1422
|
-
* Counts the number of blocks in the input range.
|
|
1423
|
-
*
|
|
1424
|
-
* @deprecated use DateCell implementation instead.
|
|
1425
|
-
* @param inputDateBlockRange
|
|
1426
|
-
* @returns
|
|
1427
|
-
*/
|
|
1428
|
-
function dateBlockRangeBlocksCountInfo(inputDateBlockRange) {
|
|
1429
|
-
const group = groupToDateBlockRanges((0, util_1.asArray)(inputDateBlockRange));
|
|
1430
|
-
let count = 0;
|
|
1431
|
-
let total = 0;
|
|
1432
|
-
group.forEach((x) => {
|
|
1433
|
-
const blocks = Math.abs(x.to - x.i) + 1; // +1 for inclusivity
|
|
1434
|
-
count += blocks;
|
|
1435
|
-
const size = (0, util_1.sumOfIntegersBetween)(x.i, x.to);
|
|
1436
|
-
total += size;
|
|
1437
|
-
});
|
|
1438
|
-
return {
|
|
1439
|
-
count,
|
|
1440
|
-
total,
|
|
1441
|
-
average: count > 0 ? total / count : 0
|
|
1442
|
-
};
|
|
1443
|
-
}
|
|
1444
|
-
exports.dateBlockRangeBlocksCountInfo = dateBlockRangeBlocksCountInfo;
|
|
1445
|
-
/**
|
|
1446
|
-
* Counts the number of blocks in the input range.
|
|
1447
|
-
*
|
|
1448
|
-
* @deprecated use DateCell implementation instead.
|
|
1449
|
-
* @param inputDateBlockRange
|
|
1450
|
-
* @returns
|
|
1451
|
-
*/
|
|
1452
|
-
function dateBlockRangeBlocksCount(inputDateBlockRange) {
|
|
1453
|
-
return dateBlockRangeBlocksCountInfo(inputDateBlockRange).count;
|
|
1454
|
-
}
|
|
1455
|
-
exports.dateBlockRangeBlocksCount = dateBlockRangeBlocksCount;
|
|
1456
|
-
/**
|
|
1457
|
-
* Creates a dateBlockRangesFullyCoverDateBlockRangeFunction
|
|
1458
|
-
*
|
|
1459
|
-
* @deprecated use DateCell implementation instead.
|
|
1460
|
-
* @param ranges
|
|
1461
|
-
* @returns
|
|
1462
|
-
*/
|
|
1463
|
-
function dateBlockRangesFullyCoverDateBlockRangeFunction(ranges) {
|
|
1464
|
-
const groupedRanges = Array.isArray(ranges) ? groupToDateBlockRanges(ranges) : [dateBlockRangeWithRange(ranges)];
|
|
1465
|
-
return (inputRange) => {
|
|
1466
|
-
const fn = dateBlockRangeIncludedByRangeFunction(inputRange);
|
|
1467
|
-
return groupedRanges.findIndex(fn) !== -1;
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1470
|
-
exports.dateBlockRangesFullyCoverDateBlockRangeFunction = dateBlockRangesFullyCoverDateBlockRangeFunction;
|
|
1471
|
-
/**
|
|
1472
|
-
* Expands a DateBlockRange into an array of DateBlock values.
|
|
1473
|
-
*
|
|
1474
|
-
* @deprecated use DateCell implementation instead.
|
|
1475
|
-
* @param block
|
|
1476
|
-
* @returns
|
|
1477
|
-
*/
|
|
1478
|
-
function expandDateBlockRange(block) {
|
|
1479
|
-
return (0, util_1.range)(block.i, dateBlockEndIndex(block) + 1).map((i) => {
|
|
1480
|
-
return Object.assign(Object.assign({}, block), { i, to: i }); // copy block, set to as i
|
|
1481
|
-
});
|
|
1482
|
-
}
|
|
1483
|
-
exports.expandDateBlockRange = expandDateBlockRange;
|
|
1484
|
-
/**
|
|
1485
|
-
* Returns true if the input DateBlockRange is longer than 1 block (I.E. has a "to" value greater than it's "i" value).
|
|
1486
|
-
*
|
|
1487
|
-
* @deprecated use DateCell implementation instead.
|
|
1488
|
-
* @param input
|
|
1489
|
-
*/
|
|
1490
|
-
function dateBlockRangeHasRange(input) {
|
|
1491
|
-
return input.to != null && input.to > input.i;
|
|
1492
|
-
}
|
|
1493
|
-
exports.dateBlockRangeHasRange = dateBlockRangeHasRange;
|
|
1494
|
-
/**
|
|
1495
|
-
* Reads the to index if it exists, or returns the block's index itself.
|
|
1496
|
-
*
|
|
1497
|
-
* @deprecated use DateCell implementation instead.
|
|
1498
|
-
* @param input
|
|
1499
|
-
* @returns
|
|
1500
|
-
*/
|
|
1501
|
-
function dateBlockEndIndex(input) {
|
|
1502
|
-
var _a;
|
|
1503
|
-
return (_a = input.to) !== null && _a !== void 0 ? _a : input.i;
|
|
1504
|
-
}
|
|
1505
|
-
exports.dateBlockEndIndex = dateBlockEndIndex;
|
|
1506
|
-
/**
|
|
1507
|
-
* Groups all input DateBlockRange or UniqueDateBlock values into a UniqueDateBlockRangeGroup value amd sorts the input.
|
|
1508
|
-
*
|
|
1509
|
-
* @deprecated use DateCell implementation instead.
|
|
1510
|
-
*/
|
|
1511
|
-
function groupUniqueDateBlocks(input) {
|
|
1512
|
-
var _a;
|
|
1513
|
-
const blocks = sortDateBlockRanges([...input]);
|
|
1514
|
-
const i = 0;
|
|
1515
|
-
let to;
|
|
1516
|
-
if (blocks.length === 0) {
|
|
1517
|
-
to = i;
|
|
1518
|
-
}
|
|
1519
|
-
else {
|
|
1520
|
-
const lastBlock = (0, util_1.lastValue)(blocks);
|
|
1521
|
-
to = (_a = lastBlock.to) !== null && _a !== void 0 ? _a : lastBlock.i;
|
|
1522
|
-
}
|
|
1523
|
-
return {
|
|
1524
|
-
i,
|
|
1525
|
-
to,
|
|
1526
|
-
blocks
|
|
1527
|
-
};
|
|
1528
|
-
}
|
|
1529
|
-
exports.groupUniqueDateBlocks = groupUniqueDateBlocks;
|
|
1530
|
-
/**
|
|
1531
|
-
*
|
|
1532
|
-
* @deprecated use DateCell implementation instead.
|
|
1533
|
-
* @param config
|
|
1534
|
-
* @returns
|
|
1535
|
-
*/
|
|
1536
|
-
function expandUniqueDateBlocksFunction(config) {
|
|
1537
|
-
const { startAtIndex = 0, endAtIndex, fillOption: fill, fillFactory: inputFillFactory, retainOnOverlap: inputRetainOnOverlap } = config;
|
|
1538
|
-
const retainOnOverlap = inputRetainOnOverlap !== null && inputRetainOnOverlap !== void 0 ? inputRetainOnOverlap : 'next';
|
|
1539
|
-
const maxAllowedIndex = endAtIndex !== null && endAtIndex !== void 0 ? endAtIndex : Number.MAX_SAFE_INTEGER;
|
|
1540
|
-
const fillFactory = inputFillFactory;
|
|
1541
|
-
if (!fillFactory && fill === 'fill') {
|
|
1542
|
-
throw new Error('fillFactory is required when fillOption is "fill".');
|
|
1543
|
-
}
|
|
1544
|
-
return (input, newBlocks) => {
|
|
1545
|
-
const inputGroup = Array.isArray(input) ? groupUniqueDateBlocks(input) : input;
|
|
1546
|
-
const sorted = inputGroup.blocks.map((block) => ({ priority: 'current', block }));
|
|
1547
|
-
if (newBlocks != null) {
|
|
1548
|
-
const inputOverwriteGroup = Array.isArray(newBlocks) ? groupUniqueDateBlocks(newBlocks) : newBlocks;
|
|
1549
|
-
(0, util_1.mergeArrayIntoArray)(sorted, inputOverwriteGroup.blocks.map((block) => ({ priority: 'next', block }))).sort((a, b) => a.block.i - b.block.i);
|
|
1550
|
-
}
|
|
1551
|
-
const blocks = [];
|
|
1552
|
-
const discarded = [];
|
|
1553
|
-
let current = sorted[0];
|
|
1554
|
-
let currentNextIndex;
|
|
1555
|
-
let next = sorted[1];
|
|
1556
|
-
let nextStartIndex;
|
|
1557
|
-
let i = 0;
|
|
1558
|
-
let latestTo = startAtIndex - 1;
|
|
1559
|
-
function addBlockWithRange(inputBlock, i, inputTo = i) {
|
|
1560
|
-
// Add in any necessary gap block first
|
|
1561
|
-
const gapSizeBetweenBlocks = i - (latestTo + 1);
|
|
1562
|
-
if (gapSizeBetweenBlocks > 0) {
|
|
1563
|
-
// start at the startAtIndex at a minimum
|
|
1564
|
-
const gapStartIndex = Math.max(latestTo + 1, startAtIndex);
|
|
1565
|
-
addGapBlock(gapStartIndex, i - 1);
|
|
1566
|
-
}
|
|
1567
|
-
const to = Math.min(inputTo, maxAllowedIndex) || 0;
|
|
1568
|
-
const block = Object.assign(Object.assign({}, inputBlock), { i,
|
|
1569
|
-
to });
|
|
1570
|
-
blocks.push(block);
|
|
1571
|
-
latestTo = to;
|
|
1572
|
-
return block;
|
|
1573
|
-
}
|
|
1574
|
-
function completeBlocks() {
|
|
1575
|
-
// extend or fill if there is an endAtIndex value present
|
|
1576
|
-
if (endAtIndex != null && latestTo < endAtIndex) {
|
|
1577
|
-
addGapBlock(latestTo + 1, endAtIndex);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
function addGapBlock(i, inputTo = i) {
|
|
1581
|
-
const to = Math.min(inputTo, maxAllowedIndex);
|
|
1582
|
-
if (fill === 'fill') {
|
|
1583
|
-
const dateBlockRange = {
|
|
1584
|
-
i,
|
|
1585
|
-
to
|
|
1586
|
-
};
|
|
1587
|
-
const block = fillFactory(dateBlockRange);
|
|
1588
|
-
addBlockWithRange(block, i, to !== null && to !== void 0 ? to : i);
|
|
1589
|
-
}
|
|
1590
|
-
else if (blocks.length > 0) {
|
|
1591
|
-
// do not extend if no blocks have been pushed.
|
|
1592
|
-
const blockToExtend = (0, util_1.lastValue)(blocks);
|
|
1593
|
-
blockToExtend.to = inputTo;
|
|
1594
|
-
}
|
|
1595
|
-
latestTo = to;
|
|
1596
|
-
}
|
|
1597
|
-
function continueToNext(use, priority) {
|
|
1598
|
-
i += 1;
|
|
1599
|
-
current = use != null ? { block: use, priority } : sorted[i];
|
|
1600
|
-
next = sorted[i + 1];
|
|
1601
|
-
if (next) {
|
|
1602
|
-
nextStartIndex = next.block.i;
|
|
1603
|
-
// complete loop once past the max allowed index
|
|
1604
|
-
if (nextStartIndex > maxAllowedIndex) {
|
|
1605
|
-
continueLoop = false;
|
|
1606
|
-
}
|
|
1607
|
-
else {
|
|
1608
|
-
const nextEndIndex = dateBlockEndIndex(next.block);
|
|
1609
|
-
if (nextEndIndex <= latestTo) {
|
|
1610
|
-
discardCurrent(); // skip until next is not less than or equal to the latest to
|
|
1611
|
-
continueToNext();
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
else {
|
|
1616
|
-
continueLoop = false;
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
function discard(pair) {
|
|
1620
|
-
discarded.push(pair.block);
|
|
1621
|
-
}
|
|
1622
|
-
function discardCurrent() {
|
|
1623
|
-
discard(current);
|
|
1624
|
-
}
|
|
1625
|
-
function discardNext() {
|
|
1626
|
-
discard(next);
|
|
1627
|
-
i += 1;
|
|
1628
|
-
continueToNext();
|
|
1629
|
-
}
|
|
1630
|
-
let continueLoop = Boolean(next); // only loop if next is defined, otherwise we just add the final item.
|
|
1631
|
-
/**
|
|
1632
|
-
* Used to determine how to handle two neighboring objects.
|
|
1633
|
-
*/
|
|
1634
|
-
function shouldRetainCurrentOverNext() {
|
|
1635
|
-
if (current.priority === next.priority) {
|
|
1636
|
-
return retainOnOverlap === 'current';
|
|
1637
|
-
}
|
|
1638
|
-
else {
|
|
1639
|
-
return current.priority === retainOnOverlap;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
while (continueLoop) {
|
|
1643
|
-
currentNextIndex = current.block.i;
|
|
1644
|
-
nextStartIndex = next.block.i;
|
|
1645
|
-
const currentEndIndex = dateBlockEndIndex(current.block);
|
|
1646
|
-
const nextEndIndex = dateBlockEndIndex(next.block);
|
|
1647
|
-
if (nextStartIndex < startAtIndex || currentEndIndex < startAtIndex) {
|
|
1648
|
-
// do nothing if the next index is still before the current start index.
|
|
1649
|
-
discardCurrent();
|
|
1650
|
-
continueToNext();
|
|
1651
|
-
}
|
|
1652
|
-
else if (currentNextIndex === nextStartIndex) {
|
|
1653
|
-
// if next has the same range as current, then look at the tie-breaker
|
|
1654
|
-
if (nextEndIndex === currentEndIndex) {
|
|
1655
|
-
// if they're both on the same index, then take the one based on the overwrite value
|
|
1656
|
-
if (shouldRetainCurrentOverNext()) {
|
|
1657
|
-
// add current
|
|
1658
|
-
addBlockWithRange(current.block, currentNextIndex, nextEndIndex);
|
|
1659
|
-
// discard and skip the "next" value
|
|
1660
|
-
discardNext();
|
|
1661
|
-
}
|
|
1662
|
-
else {
|
|
1663
|
-
// discard the current
|
|
1664
|
-
discardCurrent();
|
|
1665
|
-
// move on to next
|
|
1666
|
-
continueToNext();
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
else if (nextEndIndex > currentEndIndex) {
|
|
1670
|
-
// handle overlap
|
|
1671
|
-
if (shouldRetainCurrentOverNext()) {
|
|
1672
|
-
// add current
|
|
1673
|
-
addBlockWithRange(current.block, currentNextIndex, currentEndIndex);
|
|
1674
|
-
// change next to start at the next range
|
|
1675
|
-
continueToNext(Object.assign(Object.assign({}, next.block), { i: currentEndIndex + 1, to: nextEndIndex }), next.priority);
|
|
1676
|
-
}
|
|
1677
|
-
else {
|
|
1678
|
-
//
|
|
1679
|
-
discardCurrent();
|
|
1680
|
-
continueToNext();
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
else {
|
|
1684
|
-
// the next item ends before the current item.
|
|
1685
|
-
if (shouldRetainCurrentOverNext()) {
|
|
1686
|
-
// discard the next value.
|
|
1687
|
-
discard(next);
|
|
1688
|
-
// continue with the current value
|
|
1689
|
-
continueToNext(current.block, current.priority);
|
|
1690
|
-
}
|
|
1691
|
-
else {
|
|
1692
|
-
// add the next item first since it overwrites the current
|
|
1693
|
-
addBlockWithRange(next.block, nextStartIndex, nextEndIndex);
|
|
1694
|
-
// continue with the current item as next.
|
|
1695
|
-
continueToNext(Object.assign(Object.assign({}, current.block), { i: nextEndIndex + 1, to: currentEndIndex }), current.priority);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
else {
|
|
1700
|
-
// Check for any overlap
|
|
1701
|
-
if (currentEndIndex >= nextStartIndex) {
|
|
1702
|
-
// handle overlap
|
|
1703
|
-
if (shouldRetainCurrentOverNext()) {
|
|
1704
|
-
// add current
|
|
1705
|
-
addBlockWithRange(current.block, currentNextIndex, currentEndIndex);
|
|
1706
|
-
if (nextEndIndex > currentEndIndex) {
|
|
1707
|
-
// change next to start at the next range
|
|
1708
|
-
continueToNext(Object.assign(Object.assign({}, next.block), { i: currentEndIndex + 1, to: nextEndIndex }), next.priority);
|
|
1709
|
-
}
|
|
1710
|
-
else {
|
|
1711
|
-
// continue normally
|
|
1712
|
-
continueToNext();
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
else {
|
|
1716
|
-
// add current up to the start index of next
|
|
1717
|
-
addBlockWithRange(current.block, currentNextIndex, nextStartIndex - 1);
|
|
1718
|
-
// check if the next one is fully contained
|
|
1719
|
-
if (nextEndIndex < currentEndIndex) {
|
|
1720
|
-
// add the next
|
|
1721
|
-
addBlockWithRange(next.block, nextStartIndex, nextEndIndex);
|
|
1722
|
-
// continue with the current
|
|
1723
|
-
continueToNext(Object.assign(Object.assign({}, current.block), { i: nextEndIndex + 1, to: currentEndIndex }), next.priority);
|
|
1724
|
-
}
|
|
1725
|
-
else {
|
|
1726
|
-
// continue to next
|
|
1727
|
-
continueToNext();
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
else {
|
|
1732
|
-
// no overlap
|
|
1733
|
-
// add the current block
|
|
1734
|
-
addBlockWithRange(current.block, currentNextIndex, currentEndIndex);
|
|
1735
|
-
// continue to next
|
|
1736
|
-
continueToNext();
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
if (current != null) {
|
|
1741
|
-
// if current != null, then atleast one block was input/remaining.
|
|
1742
|
-
const lastStartIndex = current.block.i;
|
|
1743
|
-
const lastEndIndex = dateBlockEndIndex(current.block);
|
|
1744
|
-
if (lastEndIndex < startAtIndex || lastEndIndex <= latestTo || lastStartIndex > maxAllowedIndex) {
|
|
1745
|
-
// if the block ends before the start index, then do nothing.
|
|
1746
|
-
discardCurrent();
|
|
1747
|
-
}
|
|
1748
|
-
else {
|
|
1749
|
-
addBlockWithRange(current.block, Math.max(startAtIndex, lastStartIndex), Math.min(lastEndIndex, maxAllowedIndex));
|
|
1750
|
-
}
|
|
1751
|
-
completeBlocks();
|
|
1752
|
-
}
|
|
1753
|
-
else if (fill === 'fill') {
|
|
1754
|
-
completeBlocks();
|
|
1755
|
-
}
|
|
1756
|
-
const result = {
|
|
1757
|
-
i: 0,
|
|
1758
|
-
blocks,
|
|
1759
|
-
discarded
|
|
1760
|
-
};
|
|
1761
|
-
return result;
|
|
1762
|
-
};
|
|
1763
|
-
}
|
|
1764
|
-
exports.expandUniqueDateBlocksFunction = expandUniqueDateBlocksFunction;
|
|
1765
|
-
/**
|
|
1766
|
-
* Creatse a ModifyDateBlocksToFitRangeFunction
|
|
1767
|
-
*
|
|
1768
|
-
* @deprecated use DateCell implementation instead.
|
|
1769
|
-
*/
|
|
1770
|
-
function modifyDateBlocksToFitRangeFunction(range) {
|
|
1771
|
-
const { i, to } = dateBlockRangeWithRange(range);
|
|
1772
|
-
const dateBlockIsWithinDateBlockRange = isDateBlockWithinDateBlockRangeFunction(range);
|
|
1773
|
-
const overlapsRange = dateBlockRangeOverlapsRangeFunction(range);
|
|
1774
|
-
return (input) => (0, util_1.filterMaybeValues)(input.map((x) => {
|
|
1775
|
-
let result;
|
|
1776
|
-
const inRange = dateBlockIsWithinDateBlockRange(x);
|
|
1777
|
-
if (inRange) {
|
|
1778
|
-
// if contained within the range then return as-is
|
|
1779
|
-
result = x;
|
|
1780
|
-
}
|
|
1781
|
-
else {
|
|
1782
|
-
// fit to the range otherwise
|
|
1783
|
-
const asRange = dateBlockRangeWithRange(x);
|
|
1784
|
-
const rangesOverlap = overlapsRange(asRange);
|
|
1785
|
-
if (rangesOverlap) {
|
|
1786
|
-
result = Object.assign(Object.assign({}, x), { i: Math.max(i, asRange.i), to: Math.min(to, asRange.to) // should be no larger than to
|
|
1787
|
-
});
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return result;
|
|
1791
|
-
}));
|
|
1792
|
-
}
|
|
1793
|
-
exports.modifyDateBlocksToFitRangeFunction = modifyDateBlocksToFitRangeFunction;
|
|
1794
|
-
/**
|
|
1795
|
-
*
|
|
1796
|
-
* @deprecated use DateCell implementation instead.
|
|
1797
|
-
* @param range
|
|
1798
|
-
* @param input
|
|
1799
|
-
* @returns
|
|
1800
|
-
*/
|
|
1801
|
-
function modifyDateBlocksToFitRange(range, input) {
|
|
1802
|
-
return modifyDateBlocksToFitRangeFunction(range)(input);
|
|
1803
|
-
}
|
|
1804
|
-
exports.modifyDateBlocksToFitRange = modifyDateBlocksToFitRange;
|
|
1805
|
-
/**
|
|
1806
|
-
*
|
|
1807
|
-
* @deprecated use DateCell implementation instead.
|
|
1808
|
-
* @param range
|
|
1809
|
-
* @param input
|
|
1810
|
-
* @returns
|
|
1811
|
-
*/
|
|
1812
|
-
function modifyDateBlockToFitRange(range, input) {
|
|
1813
|
-
return modifyDateBlocksToFitRange(range, [input])[0];
|
|
1814
|
-
}
|
|
1815
|
-
exports.modifyDateBlockToFitRange = modifyDateBlockToFitRange;
|
|
1816
|
-
// MARK: Compat
|
|
1817
|
-
/**
|
|
1818
|
-
* @deprecated use dateBlocksInDateBlockRange instead.
|
|
1819
|
-
*/
|
|
1820
|
-
exports.dateBlocksInDateBlockRange = filterDateBlocksInDateBlockRange;
|
|
1821
|
-
/**
|
|
1822
|
-
* @deprecated use isDateBlockWithinDateBlockRangeFunction() instead.
|
|
1823
|
-
*/
|
|
1824
|
-
exports.dateBlockIsWithinDateBlockRangeFunction = isDateBlockWithinDateBlockRangeFunction;
|
|
1825
|
-
/**
|
|
1826
|
-
* @deprecated use isDateBlockWithinDateBlockRange() instead.
|
|
1827
|
-
*/
|
|
1828
|
-
exports.dateBlockRangeContainsDateBlock = isDateBlockWithinDateBlockRange;
|
|
1829
|
-
/**
|
|
1830
|
-
* @deprecated use dateBlocksDayTimingInfoFactory instead.
|
|
1831
|
-
*/
|
|
1832
|
-
exports.dateBlocksDayInfoFactory = dateBlockDayTimingInfoFactory;
|
|
1833
|
-
/**
|
|
1834
|
-
* @deprecated use isDateBlockTimingRelativeIndexFactory instead.
|
|
1835
|
-
*/
|
|
1836
|
-
exports.isDateTimingRelativeIndexFactory = isDateBlockTimingRelativeIndexFactory;
|
|
1837
|
-
/**
|
|
1838
|
-
* @deprecated use dateBlockTimingRelativeIndexFactory instead.
|
|
1839
|
-
*/
|
|
1840
|
-
exports.dateTimingRelativeIndexFactory = dateBlockTimingRelativeIndexFactory;
|
|
1841
|
-
/**
|
|
1842
|
-
* @deprecated use dateBlockTimingRelativeIndexArrayFactory instead.
|
|
1843
|
-
*/
|
|
1844
|
-
exports.dateTimingRelativeIndexArrayFactory = dateBlockTimingRelativeIndexArrayFactory;
|
|
1845
|
-
/**
|
|
1846
|
-
* @deprecated use getRelativeIndexForDateBlockTiming instead.
|
|
1847
|
-
*/
|
|
1848
|
-
exports.getRelativeIndexForDateTiming = getRelativeIndexForDateBlockTiming;
|
|
1849
|
-
//# sourceMappingURL=date.block.js.map
|