diff --git a/src/lib/CalendarMonth.svelte b/src/lib/CalendarMonth.svelte index 40e5262..326dc9a 100644 --- a/src/lib/CalendarMonth.svelte +++ b/src/lib/CalendarMonth.svelte @@ -8,6 +8,8 @@ export let consecutiveDaysOff: Array<{ startDate: Date; endDate: Date; totalDays: number }>; export let selectedCountryCode: string; export let weekendDays: number[] = [6, 0]; + export let startDate: Date = new Date(year, 0, 1); + export let isActive: boolean = true; // Function to determine the first day of the week based on locale function getFirstDayOfWeek(locale: string): number { @@ -84,12 +86,19 @@ return weekendDays.includes(date.getDay()); } + function isPastDate(day: number): boolean { + const date = new Date(year, month, day); + // Normalize startDate to current year for comparison + const startDateInYear = new Date(year, startDate.getMonth(), startDate.getDate()); + return date < startDateInYear; + } + const dayInitials = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; $: orderedDayInitials = dayInitials.slice(firstDayOfWeek).concat(dayInitials.slice(0, firstDayOfWeek)); -