5 667
edições
Sem resumo de edição |
Sem resumo de edição |
||
Linha 16: | Linha 16: | ||
const currentDate = new Date(data.datetime); | const currentDate = new Date(data.datetime); | ||
let actualWeekNumber = getWeekNumber(currentDate); | let actualWeekNumber = getWeekNumber(currentDate); | ||
// Check if it's Friday and after 7 AM in local time | |||
const isFridayAfter7AM = currentDate.getDay() === 5 && currentDate.getHours() >= 7; | const isFridayAfter7AM = currentDate.getDay() === 5 && currentDate.getHours() >= 7; | ||
// Increment the week number only if it's Friday after 7 AM | |||
if (isFridayAfter7AM) { | if (isFridayAfter7AM) { | ||
actualWeekNumber++; | actualWeekNumber++; | ||
} | } | ||
// Define the weeks starting with " | // Define the weeks starting with "Sexta semana" | ||
const dzWeeks = [ | const dzWeeks = [ | ||
{ name: 'Sexta semana', image: '/images/2/23/Card_DZ_Sexta-Semana.png' }, | { name: 'Sexta semana', image: '/images/2/23/Card_DZ_Sexta-Semana.png' }, | ||
Linha 38: | Linha 40: | ||
{ name: 'Quinta semana', image: '/images/4/40/Card_DZ_Quinta-Semana.png' }, | { name: 'Quinta semana', image: '/images/4/40/Card_DZ_Quinta-Semana.png' }, | ||
]; | ]; | ||
// Offset to start at "Sexta semana" | |||
let offset = 5; | |||
let weekIndex = ((actualWeekNumber - 1) + offset) % dzWeeks.length; | |||
// Update the image only if dzCard is found | |||
if (dzCard) { | if (dzCard) { | ||
dzCard.src = url + dzWeeks[weekIndex].image; | dzCard.src = url + dzWeeks[weekIndex].image; |