int daysInMonth(int year, int month) { const lengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if (month == 2 && isLeapYear(year)) return 29; return lengths[month - 1]; }