import { isToday, isPast, dayOfWeek } from '../utils.js'; import { t } from '../i18n.js'; export function renderQuarter(container, currentDate, events, onDayClick, onEventClick, weekStartDay = 'monday') { const year = currentDate.getFullYear(); // Quarter: Q1=0, Q2=1, Q3=2, Q4=3 const quarter = Math.floor(currentDate.getMonth() / 3); const firstMonthOfQ = quarter * 3; // Build event map keyed by date string const evMap = {}; events.forEach(ev => { const s = new Date(ev.start); const e = new Date(ev.end); const cur = new Date(s); cur.setHours(0, 0, 0, 0); const endNorm = new Date(e); endNorm.setHours(0, 0, 0, 0); if (ev.allDay && endNorm > cur) endNorm.setDate(endNorm.getDate() - 1); while (cur <= endNorm) { const key = dateKey(cur); if (!evMap[key]) evMap[key] = []; evMap[key].push(ev); cur.setDate(cur.getDate() + 1); } }); const DOW = weekStartDay === 'sunday' ? t('dow_sunday') : t('dow_monday'); const MONTHS = t('months'); const monthsHtml = [0, 1, 2].map(offset => { const month = firstMonthOfQ + offset; const firstDay = new Date(year, month, 1); const lastDay = new Date(year, month + 1, 0); // Start grid on correct weekday const gridStart = new Date(firstDay); const startOffset = dayOfWeek(firstDay, weekStartDay); gridStart.setDate(gridStart.getDate() - startOffset); const cells = []; const d = new Date(gridStart); for (let i = 0; i < 42; i++) { cells.push(new Date(d)); d.setDate(d.getDate() + 1); } // DOW header const dowHeader = DOW.map(d => `