From 708bec09300484f0a59fc2be5a622088fa3bef4c Mon Sep 17 00:00:00 2001 From: Sundog Date: Mon, 9 Sep 2024 10:49:07 -0400 Subject: [PATCH] more date math --- layout.html | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/layout.html b/layout.html index 93d3af6..884e148 100644 --- a/layout.html +++ b/layout.html @@ -625,7 +625,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); + current_day_indicator.setAttribute("data-day", new Date(day_of_schedule).getSeconds() / 1000); // 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); @@ -635,23 +635,17 @@ const grid = document.querySelector("#schedule_grid"); grid.appendChild(template_clone); } - // put date at top of appropriate column of the grid - const header_selector = "#header_" + i; - const header_cell = document.querySelector(header_selector); - //header_cell.innerHTML = current_day.toDateString(); - current_day.setDate(current_day.getDate() + 1); } } const previous_day_schedule = (e) => { e.preventDefault(); - const day = new Date(Date.parse(e.target.getAttribute("data-day")) - 86400); + const day = new Date(e.target.getAttribute("data-day") - 86400); init_schedules(day); } - const next_day_schedule = (e) => { e.preventDefault(); - const day = new Date(Date.parse(e.target.getAttribute("data-day")) + 86400); + const day = new Date(e.target.getAttribute("data-day") + 86400); init_schedules(day); }