fix: correct isToday check in DateTimePicker
getMonth() returns 0-11, but the comparison string was not adjusting for this, so the "today" highlight in the calendar never matched. https://claude.ai/code/session_013ooJht2HrZUTXgNJFU79cV
This commit is contained in:
parent
ec6f35ad02
commit
24a62b6685
|
|
@ -18,7 +18,7 @@
|
||||||
let selectedMinute = $state(existing ? existing.getMinutes() : 0);
|
let selectedMinute = $state(existing ? existing.getMinutes() : 0);
|
||||||
let visible = $state(false);
|
let visible = $state(false);
|
||||||
|
|
||||||
let todayStr = `${now.getFullYear()}-${now.getMonth()}-${now.getDate()}`;
|
let todayStr = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
|
||||||
|
|
||||||
let daysInMonth = $derived(new Date(viewYear, viewMonth + 1, 0).getDate());
|
let daysInMonth = $derived(new Date(viewYear, viewMonth + 1, 0).getDate());
|
||||||
let firstDayOfWeek = $derived(new Date(viewYear, viewMonth, 1).getDay());
|
let firstDayOfWeek = $derived(new Date(viewYear, viewMonth, 1).getDay());
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function isToday(day: number): boolean {
|
function isToday(day: number): boolean {
|
||||||
return `${viewYear}-${viewMonth}-${day}` === todayStr;
|
return `${viewYear}-${viewMonth + 1}-${day}` === todayStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSelected(day: number): boolean {
|
function isSelected(day: number): boolean {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue