Highlight the current hour
FIXME: only do this on the current day
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user