Fix M, T, W... days
This commit is contained in:
@@ -91,20 +91,11 @@
|
|||||||
return dayOfWeek === saturdayIndex || dayOfWeek === sundayIndex;
|
return dayOfWeek === saturdayIndex || dayOfWeek === sundayIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to get the localized day initials based on the first day of the week
|
// Fixed array of day initials starting from Sunday
|
||||||
function getLocalizedDayInitials(locale) {
|
const dayInitials = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reactive declaration to get the ordered day initials
|
// 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>
|
</script>
|
||||||
|
|
||||||
<div class="calendar">
|
<div class="calendar">
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
$: selectedCountryCode = Object.keys(countriesList).find(code => countriesList[code] === selectedCountry);
|
$: selectedCountryCode = Object.keys(countriesList).find(code => countriesList[code] === selectedCountry);
|
||||||
|
|
||||||
$: if (selectedCountryCode || selectedStateCode ) {
|
$: if (selectedCountryCode || selectedStateCode || daysOff || year) {
|
||||||
updateHolidays();
|
updateHolidays();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user