MU
Size: a a a
MU
ab
s
ab
ab
IS
IS
BB
BB
IS
MU
IS
АЕ
IS
IS
IS
АЕ
IS
АЕ
IS
const timeToMinutes = (time) => {
const [hours, minutes] = time.split(":").map(Number);
return hours * 60 + minutes;
}
const minutesToTime = (minutes) =>
${~~(minutes / 60)}:${minutes % 60}
;
const getClosestLowerTime = (time, times) => {
const current = timeToMinutes(time);
let closest = 0;
times.map(timeToMinutes).forEach(item => item < current && item > closest && (closest = item));
return minutesToTime(closest);
};
const time = "9:45" ;
const times = ["9:30", "9:45", "10:30"];
const closest = getClosestLowerTime(time, times);