Untitled
unknown
plain_text
2 years ago
1.6 kB
6
Indexable
const matchInputWithBusySlots = (inputDate, inputTime, busyTimeSlots) => {
const inputDateTime = new Date(`${inputDate}T${inputTime}`);
const inputDateString = inputDateTime.toLocaleDateString('en-US', {
timeZone: "Asia/Kolkata",
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
const inputTimeString = inputDateTime.toLocaleTimeString('en-US', {
timeZone: "Asia/Kolkata",
hour: '2-digit',
minute: '2-digit',
hour12: false
});
// Log input date and time for debugging
console.log("Input Date String:", inputDateString);
console.log("Input Time String:", inputTimeString);
const isMatch = busyTimeSlots?.some((busySlot) => {
const busyStartDateTimeString = busySlot.start.dateTime;
const busyEndDateTimeString = busySlot.end.dateTime;
const [busyStartDate, busyStartTime] = busyStartDateTimeString.split(', ');
const [_, busyEndTime] = busyEndDateTimeString.split(', ');
console.log("Checking Busy Start:", busyStartDateTimeString);
console.log("Checking Busy End:", busyEndDateTimeString);
// Check if the input date matches the busy date and if input time falls within the busy time range
if (inputDateString === busyStartDate && inputTimeString >= busyStartTime && inputTimeString <= busyEndTime) {
return true; // Match found, input time is within a busy slot
}
return false; // No match found
});
// Set the global matching variable based on the result
matching = isMatch;
console.log("Matching result:", matching);
};
Editor is loading...
Leave a Comment