more date math

This commit is contained in:
Sundog Jones 2024-09-09 10:49:07 -04:00
parent 2f66270bd0
commit 708bec0930

View File

@ -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 <strong>${day_of_schedule.toDateString()}</strong>`;
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);
}