| 10 | "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]; |
| 11 | |
| 12 | const renderCalendar = () => { |
| 13 | let firstDayofMonth = new Date(currYear, currMonth, 1).getDay(), |
| 14 | lastDateofMonth = new Date(currYear, currMonth + 1, 0).getDate(), |
| 15 | lastDayofMonth = new Date(currYear, currMonth, lastDateofMonth).getDay(), |
| 16 | lastDateofLastMonth = new Date(currYear, currMonth, 0).getDate(); |
| 17 | let liTag = ""; |
| 18 | |
| 19 | for (let i = firstDayofMonth; i > 0; i--) { |
| 20 | liTag += `<li class="inactive">${lastDateofLastMonth - i + 1}</li>`; |
| 21 | } |
| 22 | |
| 23 | for (let i = 1; i <= lastDateofMonth; i++) { |
| 24 | |
| 25 | let isToday = i === date.getDate() && currMonth === new Date().getMonth() |
| 26 | && currYear === new Date().getFullYear() ? "active" : ""; |
| 27 | liTag += `<li class="${isToday}">${i}</li>`; |
| 28 | } |
| 29 | |
| 30 | for (let i = lastDayofMonth; i < 6; i++) { |
| 31 | liTag += `<li class="inactive">${i - lastDayofMonth + 1}</li>` |
| 32 | } |
| 33 | currentDate.innerText = `${months[currMonth]} ${currYear}`; |
| 34 | daysTag.innerHTML = liTag; |
| 35 | } |
| 36 | renderCalendar(); |
| 37 | |
| 38 | prevNextIcon.forEach(icon => { |