@forcecalendar/core 2.1.53 → 2.1.55
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.
|
@@ -500,13 +500,36 @@ export class ConflictDetector {
|
|
|
500
500
|
* @private
|
|
501
501
|
*/
|
|
502
502
|
_isWithinBusinessHours(start, end, options) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
503
|
+
if (options.excludeWeekends) {
|
|
504
|
+
const day = start.getDay();
|
|
505
|
+
if (day === 0 || day === 6) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Business hours describe a window within a single day, so a period
|
|
511
|
+
// spanning multiple calendar days can never fit inside them
|
|
512
|
+
if (
|
|
513
|
+
start.getFullYear() !== end.getFullYear() ||
|
|
514
|
+
start.getMonth() !== end.getMonth() ||
|
|
515
|
+
start.getDate() !== end.getDate()
|
|
516
|
+
) {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const [businessStartHour, businessStartMinute = 0] = options.businessHours.start
|
|
521
|
+
.split(':')
|
|
522
|
+
.map(Number);
|
|
523
|
+
const [businessEndHour, businessEndMinute = 0] = options.businessHours.end
|
|
524
|
+
.split(':')
|
|
525
|
+
.map(Number);
|
|
526
|
+
|
|
527
|
+
const businessStart = businessStartHour * 60 + businessStartMinute;
|
|
528
|
+
const businessEnd = businessEndHour * 60 + businessEndMinute;
|
|
506
529
|
|
|
507
|
-
const
|
|
508
|
-
const
|
|
530
|
+
const startMinutes = start.getHours() * 60 + start.getMinutes();
|
|
531
|
+
const endMinutes = end.getHours() * 60 + end.getMinutes();
|
|
509
532
|
|
|
510
|
-
return
|
|
533
|
+
return startMinutes >= businessStart && endMinutes <= businessEnd;
|
|
511
534
|
}
|
|
512
535
|
}
|