Replace week notation with day.month date format; fix leap year M2-M9 DOY offset and holiday count

This commit is contained in:
2026-03-08 23:51:26 +00:00
parent a6b3f039d8
commit 9bd245d870
3 changed files with 66 additions and 51 deletions
+6 -14
View File
@@ -408,11 +408,15 @@ function renderTabs() {
function renderMonth(year, month) {
const leap = isLeapYear(year);
const monthStart = month * 36 + 1; // doy of Month N Day 0 (N=0..9)
// doy of Month N Day 0. In a leap year, months 2-9 start one DOY later
// because leap day (DOY 60) sits inside Month 1.
const monthStart = month * 36 + 1 + (leap && month >= 2 ? 1 : 0);
// Approx gregorian range for subtitle
// Leap M1 ends at DOY 73 (Mar 13) not 72, because the split cell adds 1
const isLeapM1 = leap && month === 1;
const gStart = gregLabel(year, monthStart);
const gEnd = gregLabel(year, monthStart + 35);
const gEnd = gregLabel(year, monthStart + 35 + (isLeapM1 ? 1 : 0));
navTitle.childNodes[0].textContent = `${year} · Month ${month}`;
navSub.textContent = `${gStart} ${gEnd}`;
@@ -431,7 +435,6 @@ function renderMonth(year, month) {
// In a leap year, M1 W3 D4 is split: top=Feb28(DOY59), bottom=LeapDay(DOY60)
// All cells from dayInMonth>=23 (W3 D5 onward) get doy+1 to skip over leap day
const isLeapM1 = leap && month === 1;
for (let week = 0; week <= 5; week++) {
for (let wd = 0; wd <= 5; wd++) {
@@ -488,13 +491,8 @@ function renderMonth(year, month) {
const topGreg = document.createElement("div");
topGreg.className = "greg-date";
topGreg.textContent = `${gregWd} ${gregLabel(year, doy)}`;
const topWd = document.createElement("div");
topWd.className = "greg-date";
topWd.style.color = "#555";
topWd.textContent = `W${week} D${wd}`;
topHalf.appendChild(topNum);
topHalf.appendChild(topGreg);
topHalf.appendChild(topWd);
cell.appendChild(topHalf);
// ── Bottom half: Leap Day (Feb 29), its own independent mini-cell ──
@@ -540,14 +538,8 @@ function renderMonth(year, month) {
greg.className = "greg-date";
greg.textContent = `${gregWd} ${gregLabel(year, doy)}`;
const wdLabel = document.createElement("div");
wdLabel.className = "greg-date";
wdLabel.style.color = "#555";
wdLabel.textContent = `W${week} D${wd}`;
cell.appendChild(dayNum);
cell.appendChild(greg);
cell.appendChild(wdLabel);
}
// Holiday markers — for split cells, attach to topHalf (Feb 28); otherwise to cell