From 1b862710d780bb0d52dc3b71b69e6daf76661f24 Mon Sep 17 00:00:00 2001 From: Zachary Date: Wed, 13 Nov 2024 17:15:59 +0100 Subject: [PATCH] Fix M, T, W... days --- src/lib/CalendarMonth.svelte | 15 +++------------ src/routes/+page.svelte | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/lib/CalendarMonth.svelte b/src/lib/CalendarMonth.svelte index 87ff74e..d546ad6 100644 --- a/src/lib/CalendarMonth.svelte +++ b/src/lib/CalendarMonth.svelte @@ -91,20 +91,11 @@ return dayOfWeek === saturdayIndex || dayOfWeek === sundayIndex; } - // Function to get the localized day initials based on the first day of the week - function getLocalizedDayInitials(locale) { - const formatter = new Intl.DateTimeFormat(locale, { weekday: 'short' }); - const dayInitials = []; - for (let i = 0; i < 7; i++) { - const date = new Date(Date.UTC(2021, 0, i + 3)); // Start from a known Thursday to ensure full week coverage - const dayName = formatter.format(date); - dayInitials.push(dayName.charAt(0).toUpperCase()); - } - return dayInitials; - } + // Fixed array of day initials starting from Sunday + const dayInitials = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; // Reactive declaration to get the ordered day initials - $: orderedDayInitials = getLocalizedDayInitials(locale).slice(firstDayOfWeek).concat(getLocalizedDayInitials(locale).slice(0, firstDayOfWeek)); + $: orderedDayInitials = dayInitials.slice(firstDayOfWeek).concat(dayInitials.slice(0, firstDayOfWeek));
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7be357f..273042b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -37,7 +37,7 @@ $: selectedCountryCode = Object.keys(countriesList).find(code => countriesList[code] === selectedCountry); - $: if (selectedCountryCode || selectedStateCode ) { + $: if (selectedCountryCode || selectedStateCode || daysOff || year) { updateHolidays(); }