@forcecalendar/core 2.1.22 → 2.1.24
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.
|
@@ -256,8 +256,11 @@ export class DateUtils {
|
|
|
256
256
|
* @returns {number}
|
|
257
257
|
*/
|
|
258
258
|
static differenceInDays(date1, date2) {
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
// Normalize to midnight to avoid DST-related hour differences
|
|
260
|
+
const d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
|
|
261
|
+
const d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
|
262
|
+
const diff = d1.getTime() - d2.getTime();
|
|
263
|
+
return Math.round(diff / (1000 * 60 * 60 * 24));
|
|
261
264
|
}
|
|
262
265
|
|
|
263
266
|
/**
|
package/core/ics/ICSParser.js
CHANGED
|
@@ -10,7 +10,10 @@ export class ICSParser {
|
|
|
10
10
|
static MAX_LINES = 100000; // 100k lines
|
|
11
11
|
static MAX_EVENTS = 10000; // 10k events
|
|
12
12
|
|
|
13
|
-
constructor() {
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
// Configurable max file size (defaults to static limit)
|
|
15
|
+
this.maxFileSize = options.maxFileSize || ICSParser.MAX_INPUT_SIZE;
|
|
16
|
+
|
|
14
17
|
// ICS line folding max width
|
|
15
18
|
this.maxLineLength = 75;
|
|
16
19
|
|
|
@@ -38,10 +41,13 @@ export class ICSParser {
|
|
|
38
41
|
* @returns {Array} Array of event objects
|
|
39
42
|
*/
|
|
40
43
|
parse(icsString) {
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
if (typeof icsString !== 'string') {
|
|
45
|
+
throw new Error('ICS input must be a string');
|
|
46
|
+
}
|
|
47
|
+
// Enforce input size limit (uses instance config, falling back to static default)
|
|
48
|
+
if (icsString.length > this.maxFileSize) {
|
|
43
49
|
throw new Error(
|
|
44
|
-
`ICS input exceeds maximum size of ${
|
|
50
|
+
`ICS input exceeds maximum size of ${this.maxFileSize / (1024 * 1024)}MB`
|
|
45
51
|
);
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -306,6 +312,13 @@ export class ICSParser {
|
|
|
306
312
|
event.recurrenceRule = value;
|
|
307
313
|
event.recurring = true;
|
|
308
314
|
break;
|
|
315
|
+
|
|
316
|
+
case 'EXDATE': {
|
|
317
|
+
if (!event.excludeDates) event.excludeDates = [];
|
|
318
|
+
const dates = value.split(',').map(d => this.parseDate(d.trim(), property));
|
|
319
|
+
event.excludeDates.push(...dates.filter(d => d !== null));
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
309
322
|
}
|
|
310
323
|
}
|
|
311
324
|
|