Fix off by one date error
This commit is contained in:
@@ -27,9 +27,13 @@
|
||||
let currentYear = $state(parseInt(year));
|
||||
let currentMonth = $state(parseInt(month));
|
||||
|
||||
function toISODate(year: number, month: number, date: number) {
|
||||
return `${year}-${String(month + 1).padStart(2, '0')}-${String(date).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function getEntryForDay(year: number, month: number, date: number) {
|
||||
if (!entries) return undefined;
|
||||
const dateStr = new Date(year, month, date).toISOString().split("T")[0];
|
||||
const dateStr = toISODate(year, month, date);
|
||||
return entries.find((e) => e.date.split("T")[0] === dateStr);
|
||||
}
|
||||
|
||||
@@ -44,7 +48,7 @@
|
||||
date: date.getDate(),
|
||||
month: date.getMonth(),
|
||||
year: date.getFullYear(),
|
||||
iso: date.toISOString().split('T')[0],
|
||||
iso: toISODate(date.getFullYear(), date.getMonth(), date.getDate()),
|
||||
dayName: headers[date.getDay() === 0 ? 6 : date.getDay() - 1],
|
||||
isCurrentMonth,
|
||||
isToday: date.toDateString() === today.toDateString(),
|
||||
|
||||
Reference in New Issue
Block a user