diff --git a/js/functions.js b/js/functions.js index 71abcf8..297c2cb 100644 --- a/js/functions.js +++ b/js/functions.js @@ -29,3 +29,23 @@ const extractDigits = (inputChar) => { } return digits ? Math.abs(parseInt(digits, 10)) : NaN; }; + +// Функция для проверки, укладывается ли встреча в рамки рабочего дня. + +function isMeetingWithinWorkHours (workStart, workEnd, meetingStart, meetingDuration) { + + const timeToMinutes = (time) => { + const [hours, minutes] = time.split(':').map(Number); + return hours * 60 + minutes; + }; + + const workStartMinutes = timeToMinutes(workStart); + const workEndMinutes = timeToMinutes(workEnd); + const meetingStartMinutes = timeToMinutes(meetingStart); + const meetingEndMinutes = meetingStartMinutes + meetingDuration; + + return ( + meetingStartMinutes >= workStartMinutes && + meetingEndMinutes <= workEndMinutes + ); +}