This commit is contained in:
Sundog Jones 2024-09-09 11:48:50 -04:00
parent 6615a10efe
commit ebc210d091

View File

@ -616,7 +616,7 @@
}); });
const init_schedules = (day) => { 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); console.dir(day_of_schedule);
for (let i = 0; i < 8; i++) { for (let i = 0; i < 8; i++) {
@ -624,7 +624,7 @@
// first column of schedule, set up the grid // first column of schedule, set up the grid
const current_day_indicator = document.querySelector("#current_day_indicator"); const current_day_indicator = document.querySelector("#current_day_indicator");
current_day_indicator.innerHTML = `Schedule for <strong>${day_of_schedule.toDateString()}</strong>`; current_day_indicator.innerHTML = `Schedule for <strong>${day_of_schedule.toDateString()}</strong>`;
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 // set up previous/next buttons
document.querySelector('#previous_day_button').addEventListener("click", previous_day_schedule); document.querySelector('#previous_day_button').addEventListener("click", previous_day_schedule);
document.querySelector('#next_day_button').addEventListener("click", next_day_schedule); document.querySelector('#next_day_button').addEventListener("click", next_day_schedule);
@ -639,12 +639,14 @@
const previous_day_schedule = (e) => { const previous_day_schedule = (e) => {
e.preventDefault(); 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); init_schedules(day);
} }
const next_day_schedule = (e) => { const next_day_schedule = (e) => {
e.preventDefault(); 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); init_schedules(day);
} }