@forcecalendar/core 2.1.46 → 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 +30 -7
- 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
|
-
return !(this.end <= otherEvent.start || this.start >= otherEvent.end);
|
|
479
|
-
} else if (otherEvent && otherEvent.start && otherEvent.end) {
|
|
480
|
-
// Allow checking against time ranges
|
|
481
|
-
return !(this.end <= otherEvent.start || this.start >= otherEvent.end);
|
|
476
|
+
if (!otherEvent || (!otherEvent.start && !(otherEvent instanceof Event))) {
|
|
477
|
+
throw new Error('Parameter must be an Event instance or have start/end properties');
|
|
482
478
|
}
|
|
483
|
-
|
|
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
|
/**
|
|
@@ -605,6 +623,11 @@ export class Event {
|
|
|
605
623
|
throw new Error('Attendee must have an email');
|
|
606
624
|
}
|
|
607
625
|
|
|
626
|
+
// Validate email format (matches constructor validation)
|
|
627
|
+
if (!this._isValidEmail(attendee.email)) {
|
|
628
|
+
throw new Error(`Invalid email for attendee: ${attendee.email}`);
|
|
629
|
+
}
|
|
630
|
+
|
|
608
631
|
// Check if attendee already exists
|
|
609
632
|
if (this.hasAttendee(attendee.email)) {
|
|
610
633
|
return false;
|