1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| var date = new Date();
var yues = document.querySelector('#yue>span'); yues.innerHTML = date.getMonth() + 1;
function getDays(year, month) { let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if ((year % 4 === 0) && (year % 100 !== 0 || year % 400 === 0)) { days[1] = 29; } return days[month] }
var yue = date.getMonth(); var qi = getDays(date.getFullYear(), yue);
var xingqi = date.getDay(); xingqi = xingqi === 0 ? 7 : xingqi; for (let i = 0; i < parseInt(date.getDate() % 7) - 1; i++) { xingqi--; if (xingqi === 0) xingqi = 7; }
xingqi--; var td = document.querySelectorAll('#rl>div>div span'); for (let i = 0; i < xingqi; i++) { td[i].innerText = '😈'; } for (let i = xingqi; i <= qi + xingqi; i++) { td[i].innerText = i - xingqi + 1; if (i === xingqi + date.getDate() - 1) td[i].style.borderBottom = "2px solid pink"; } for (let i = xingqi + qi; i < td.length; i++) { td[i].innerText = '👿'; }
|