Hong-Phuc Bui
2025-01-16 2889de7f0c2d587a17fbd322af57c29e84238620
calendar/src/lib/calendar-view.js
@@ -64,4 +64,41 @@
    }
    htmlSegment += "</table>";
    return htmlSegment;
}
}
export function verticalCalendar(calendar, location){
    const days = [
        [],
        [],
        [],
        [],
        [],
        [],
        []
    ];
    /*
    0 -> 1
    1 -> 2
    2 -> 3
    3 -> 4
    4 -> 5
    5 -> 6
    6 -> 0
    * */
    for(const [idx,day] of days.entries() ) {
        const idxOfWeekdays = (idx + location.firstDayOfWeek) % 7;
        const dayName = location.weekDays[idxOfWeekdays];
        day.push(`<td>${dayName}</td>`);
    }
    for(const week of calendar.weeks) {
        for(const [idx, day] of week.entries() ) {
            days[idx].push(`<td>${day}</td>`);
        }
    }
    let cal = "<table>\n";
    for(const day of days) {
        cal += "<tr>" + day.join("") + "</tr>\n"
    }
    cal += "</table>";
    return cal;
}