Highlight the current hour

FIXME: only do this on the current day
This commit is contained in:
Jason Zimdars
2025-01-22 21:57:38 -06:00
parent 4674a45820
commit 1c20872b83
2 changed files with 13 additions and 1 deletions
@@ -9,6 +9,7 @@ export default class extends Controller {
cellTargetConnected(target) {
const dt = new Date(target.dataset.datetime)
target.classList.toggle("future", dt > new Date())
target.classList.toggle("current-hour", this.#isCurrentHour(dt))
}
itemTargetConnected(target) {
@@ -23,4 +24,11 @@ export default class extends Controller {
dt.getMonth() == date.getMonth() &&
dt.getDay() == date.getDay()
}
#isCurrentHour(dt) {
const now = new Date()
const utcHour = dt.getUTCHours()
const localHour = now.getHours()
return utcHour === localHour
}
}