Fix M, T, W... days

This commit is contained in:
Zachary
2024-11-13 17:15:59 +01:00
parent 37f69739f9
commit 1b862710d7
2 changed files with 4 additions and 13 deletions

View File

@@ -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));
</script>
<div class="calendar">

View File

@@ -37,7 +37,7 @@
$: selectedCountryCode = Object.keys(countriesList).find(code => countriesList[code] === selectedCountry);
$: if (selectedCountryCode || selectedStateCode ) {
$: if (selectedCountryCode || selectedStateCode || daysOff || year) {
updateHolidays();
}