@MMRIZE I threw together the following and put it in manipulateDateCell. It mostly works for what I want. My check of cellDom.dataset.date vs holidays fails as it seems I’m getting a local time vs current which seems to become a UTC time for me?
// Calculate tumble days
const startDate = "2024-09-02"
const holidays = ["2024-09-02","2024-09-03","2024-10-14","2024-10-25","2024-11-22","2024-12-16"]
let schoolDays = 0
const cellHeader = cellDom.querySelector('.cellHeader') ?? null
if(cellHeader) {
const end = new Date(+cellDom.dataset.date)
let current = new Date(startDate)
while (current <= end) {
const dayOfWeek = current.getDay();
// Skip weekends (Saturday = 6, Sunday = 0)
if (dayOfWeek !== 0 && dayOfWeek !== 6) {
// Check if the current date is not a holiday
const isHoliday = holidays.some(holiday => {
return new Date(holiday).toDateString() === current.toDateString()
})
if (!isHoliday) {
schoolDays++;
}
}
// Move to the next day
current.setDate(current.getDate() + 1)
}
const cellTumbleDay = document.createElement('div')
cellTumbleDay.classList.add('cellTumbleDay')
if (schoolDays%5 == 4) {
cellTumbleDay.innerHTML = `Day ${(schoolDays % 5) + 1}.${((schoolDays % 20) + 1)/5}`
} else {
cellTumbleDay.innerHTML = `Day ${(schoolDays % 5) + 1}`
}
cellHeader.insertBefore(cellTumbleDay, cellHeader.childNodes[1])
}
Still need to cleanup stuff like skipping days and add more to manage the div with css.