Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,16 @@ export function chunkDaysIntoWeeks(
if (!day.date || typeof day.date !== 'string' || day.date.trim() === '') return false;
// Validate YYYY-MM-DD format
if (!/^\d{4}-\d{2}-\d{2}$/.test(day.date)) return false;
// Ensure it's a valid date
const dateObj = new Date(day.date);
// Validate date components (reject impossible dates like 2024-02-30)
const parts = day.date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
if (!parts) return false;
const year = parseInt(parts[1], 10);
const month = parseInt(parts[2], 10);
const dayNum = parseInt(parts[3], 10);
if (month < 1 || month > 12) return false;
const daysInMonth = new Date(year, month, 0).getDate();
if (dayNum < 1 || dayNum > daysInMonth) return false;
const dateObj = new Date(year, month - 1, dayNum);
return !isNaN(dateObj.getTime());
});

Expand Down
Loading