frontend/src/helpers/time/calculateNearestHours.js

21 lines
360 B
JavaScript

export function calculateNearestHours(currentDate = new Date()) {
if (currentDate.getHours() <= 9 || currentDate.getHours() > 21) {
return 9
}
if (currentDate.getHours() <= 12) {
return 12
}
if (currentDate.getHours() <= 15) {
return 15
}
if (currentDate.getHours() <= 18) {
return 18
}
if (currentDate.getHours() <= 21) {
return 21
}
}