From ebc210d091ed49262d7106f34844f279842a9bac Mon Sep 17 00:00:00 2001 From: Sundog Date: Mon, 9 Sep 2024 11:48:50 -0400 Subject: [PATCH] d --- layout.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/layout.html b/layout.html index 726842e..f0666b5 100644 --- a/layout.html +++ b/layout.html @@ -616,7 +616,7 @@ }); const init_schedules = (day) => { - const day_of_schedule = new Date(day) || new Date(); + const day_of_schedule = new Date(Date.parse(day)) || new Date(); console.dir(day_of_schedule); for (let i = 0; i < 8; i++) { @@ -624,7 +624,7 @@ // first column of schedule, set up the grid const current_day_indicator = document.querySelector("#current_day_indicator"); current_day_indicator.innerHTML = `Schedule for ${day_of_schedule.toDateString()}`; - current_day_indicator.setAttribute("data-day", day_of_schedule.getDate()); + current_day_indicator.setAttribute("data-day", day_of_schedule.toISOString()); // set up previous/next buttons document.querySelector('#previous_day_button').addEventListener("click", previous_day_schedule); document.querySelector('#next_day_button').addEventListener("click", next_day_schedule); @@ -639,12 +639,14 @@ const previous_day_schedule = (e) => { e.preventDefault(); - const day = new Date().setDate(e.target.getAttribute("data-day") - 1); + const day = new Date(e.target.getAttribute("data-day")); + day.setDate(day.getDate() - 1); init_schedules(day); } const next_day_schedule = (e) => { e.preventDefault(); - const day = new Date.setDate(e.target.getAttribute("data-day") + 86400); + const day = new Date(e.target.getAttribute("data-day")); + day.setDate(day.getDate() + 1); init_schedules(day); }