@forcecalendar/core 2.1.49 → 2.1.51
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/core/ics/ICSParser.js +14 -14
- package/core/timezone/TimezoneManager.js +17 -2
- package/package.json +1 -1
package/core/ics/ICSParser.js
CHANGED
|
@@ -331,19 +331,19 @@ export class ICSParser {
|
|
|
331
331
|
// Check if it's a date-only value
|
|
332
332
|
if (property.includes('VALUE=DATE') || dateString.length === 8) {
|
|
333
333
|
// YYYYMMDD format
|
|
334
|
-
const year = dateString.
|
|
335
|
-
const month = dateString.
|
|
336
|
-
const day = dateString.
|
|
334
|
+
const year = dateString.substring(0, 4);
|
|
335
|
+
const month = dateString.substring(4, 6);
|
|
336
|
+
const day = dateString.substring(6, 8);
|
|
337
337
|
return new Date(year, month - 1, day);
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
// Full datetime: YYYYMMDDTHHMMSS[Z]
|
|
341
|
-
const year = parseInt(dateString.
|
|
342
|
-
const month = parseInt(dateString.
|
|
343
|
-
const day = parseInt(dateString.
|
|
344
|
-
const hour = parseInt(dateString.
|
|
345
|
-
const minute = parseInt(dateString.
|
|
346
|
-
const second = parseInt(dateString.
|
|
341
|
+
const year = parseInt(dateString.substring(0, 4));
|
|
342
|
+
const month = parseInt(dateString.substring(4, 6)) - 1;
|
|
343
|
+
const day = parseInt(dateString.substring(6, 8));
|
|
344
|
+
const hour = parseInt(dateString.substring(9, 11)) || 0;
|
|
345
|
+
const minute = parseInt(dateString.substring(11, 13)) || 0;
|
|
346
|
+
const second = parseInt(dateString.substring(13, 15)) || 0;
|
|
347
347
|
|
|
348
348
|
if (dateString.endsWith('Z')) {
|
|
349
349
|
// UTC time
|
|
@@ -396,14 +396,14 @@ export class ICSParser {
|
|
|
396
396
|
let remaining = line;
|
|
397
397
|
|
|
398
398
|
// First line
|
|
399
|
-
folded.push(remaining.
|
|
400
|
-
remaining = remaining.
|
|
399
|
+
folded.push(remaining.substring(0, this.maxLineLength));
|
|
400
|
+
remaining = remaining.substring(this.maxLineLength);
|
|
401
401
|
|
|
402
402
|
// Continuation lines (with space prefix)
|
|
403
403
|
while (remaining.length > 0) {
|
|
404
|
-
const chunk = remaining.
|
|
404
|
+
const chunk = remaining.substring(0, this.maxLineLength - 1);
|
|
405
405
|
folded.push(` ${chunk}`);
|
|
406
|
-
remaining = remaining.
|
|
406
|
+
remaining = remaining.substring(chunk.length);
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
return folded.join('\r\n');
|
|
@@ -443,7 +443,7 @@ export class ICSParser {
|
|
|
443
443
|
*/
|
|
444
444
|
generateUID() {
|
|
445
445
|
const timestamp = Date.now().toString(36);
|
|
446
|
-
const random = Math.random().toString(36).
|
|
446
|
+
const random = Math.random().toString(36).substring(2, 11);
|
|
447
447
|
return `${timestamp}-${random}@lightning-calendar`;
|
|
448
448
|
}
|
|
449
449
|
|
|
@@ -179,6 +179,14 @@ export class TimezoneManager {
|
|
|
179
179
|
* @returns {boolean} True if in DST
|
|
180
180
|
*/
|
|
181
181
|
isDST(date, timezone, dstRule = null) {
|
|
182
|
+
// Check cache first
|
|
183
|
+
const cacheKey = `${timezone}_${date.getFullYear()}_${date.getMonth()}_${date.getDate()}_${date.getHours()}`;
|
|
184
|
+
if (this.dstCache.has(cacheKey)) {
|
|
185
|
+
this.cacheHits++;
|
|
186
|
+
return this.dstCache.get(cacheKey);
|
|
187
|
+
}
|
|
188
|
+
this.cacheMisses++;
|
|
189
|
+
|
|
182
190
|
// Get DST rule if not provided
|
|
183
191
|
if (!dstRule) {
|
|
184
192
|
const tzData = this.database.getTimezone(timezone);
|
|
@@ -201,11 +209,18 @@ export class TimezoneManager {
|
|
|
201
209
|
);
|
|
202
210
|
|
|
203
211
|
// Handle Southern Hemisphere (DST crosses year boundary)
|
|
212
|
+
let result;
|
|
204
213
|
if (dstStart > dstEnd) {
|
|
205
|
-
|
|
214
|
+
result = date >= dstStart || date < dstEnd;
|
|
215
|
+
} else {
|
|
216
|
+
result = date >= dstStart && date < dstEnd;
|
|
206
217
|
}
|
|
207
218
|
|
|
208
|
-
|
|
219
|
+
// Cache the result
|
|
220
|
+
this.dstCache.set(cacheKey, result);
|
|
221
|
+
this._manageCacheSize();
|
|
222
|
+
|
|
223
|
+
return result;
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
/**
|