This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
2021-07-25 10:45:17 +00:00
|
|
|
export function calculateNearestHours(currentDate: Date = new Date()): number {
|
2020-11-28 13:59:27 +00:00
|
|
|
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
|
|
|
|
}
|
2021-07-25 10:45:17 +00:00
|
|
|
|
|
|
|
// Same case as in the first if, will never be called
|
|
|
|
return 9
|
2020-11-28 13:59:27 +00:00
|
|
|
}
|