@forcecalendar/core 2.1.47 → 2.1.48
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/events/Event.js +26 -8
- package/package.json +1 -1
package/core/events/Event.js
CHANGED
|
@@ -473,14 +473,32 @@ export class Event {
|
|
|
473
473
|
* @throws {Error} If otherEvent is not an Event instance or doesn't have start/end
|
|
474
474
|
*/
|
|
475
475
|
overlaps(otherEvent) {
|
|
476
|
-
if (otherEvent instanceof Event) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
476
|
+
if (!otherEvent || (!otherEvent.start && !(otherEvent instanceof Event))) {
|
|
477
|
+
throw new Error('Parameter must be an Event instance or have start/end properties');
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
let thisStart = this.start;
|
|
481
|
+
let thisEnd = this.end;
|
|
482
|
+
let otherStart = otherEvent.start;
|
|
483
|
+
let otherEnd = otherEvent.end;
|
|
484
|
+
|
|
485
|
+
// Normalize all-day event boundaries for consistent comparison.
|
|
486
|
+
// All-day events use end=23:59:59.999, but a timed event ending at
|
|
487
|
+
// exactly midnight (00:00:00) of the next day should overlap with
|
|
488
|
+
// an all-day event on the previous day.
|
|
489
|
+
if (this.allDay) {
|
|
490
|
+
thisEnd = new Date(thisEnd);
|
|
491
|
+
thisEnd.setDate(thisEnd.getDate() + 1);
|
|
492
|
+
thisEnd.setHours(0, 0, 0, 0);
|
|
493
|
+
}
|
|
494
|
+
if (otherEvent.allDay) {
|
|
495
|
+
otherEnd = new Date(otherEnd);
|
|
496
|
+
otherEnd.setDate(otherEnd.getDate() + 1);
|
|
497
|
+
otherEnd.setHours(0, 0, 0, 0);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Standard interval overlap: NOT (one ends before or when the other starts)
|
|
501
|
+
return !(thisEnd <= otherStart || thisStart >= otherEnd);
|
|
484
502
|
}
|
|
485
503
|
|
|
486
504
|
/**
|