more scheduler work

This commit is contained in:
Sundog Jones 2024-09-03 16:02:37 -04:00
parent 5081ff28bc
commit 869d1d9359

View File

@ -601,9 +601,28 @@
init_schedules();
});
const init_schedules = () => {
const init_schedules = (first_day_of_week) => {
if (first_day_of_week === undefined) {
const today = new Date(Date.now()).getDay();
console.log(today);
let first_day_of_schedule = new Date(Date.now());
if (today < 1) {
// today is Sunday, the week started six days ago
first_day_of_schedule.setDate(first_day_of_schedule.getDate() - 6);
} else if (today > 1) {
// monday already passed, go back
offset = today - 1;
first_day_of_schedule.setDate(first_day_of_schedule.getDate() - offset);
} else {
// today is monday, the week has begun!
}
current_day = first_day_of_schedule;
for (let i = 0; i < 7; i++) {
console.log(current_day.toISOString());
current_day.setDate(current_day.getDate() + 1);
}
}
}
const tag_editor_handlers = () => {