function updateCountdown(weekNumber, targetDate) {
const interval = setInterval(function() {
const now = new Date().getTime();
const distance = targetDate - now;
// Time calculations for days
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
// Display the result
const countdownElement = document.getElementById(`countdown-week-${weekNumber}`);
if (countdownElement) {
countdownElement.innerHTML = `${days} days until available`;
}
// If the countdown is over, clear the interval and update the text
if (distance < 0) {
clearInterval(interval);
if (countdownElement) {
countdownElement.innerHTML = "Available now!";
}
}
}, 1000);
}
// Example: Set target dates for each week and update countdown
updateCountdown('X', new Date("2024-02-01"));