bug(datepicker): Luxon date adapter consider by default Sunday as the first day of week for any locale #30278
Labels
area: material/datepicker
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When using the Luxon date adapter, the first day of the week is always set to Sunday, regardless of the selected locale. However, in certain locales (e.g., French), the first day of the week should be Monday. This behavior can cause inconsistencies in applications relying on localized date formats.
To address this issue, we can provide custom options for the Luxon date adapter by using a factory function. This factory dynamically calculates the correct firstDayOfWeek based on the current locale, leveraging Luxon’s Info.getStartOfWeek method.
Here's how to configure it:
Luxon relies on the Intl.Locale.prototype.getWeekInfo API to determine the first day of the week. Unfortunately, this API is not supported in Firefox (as of now). However, Luxon includes a fallback mechanism that assumes Monday as the first day of the week, which aligns with the ISO standard.
For more details on getWeekInfo, refer to the MDN documentation.
Reproduction
StackBlitz link: https://stackblitz.com/edit/gao3m1fm?file=src%2Fexample%2Fdatepicker-overview-example.ts,src%2Fmain.ts
Steps to reproduce:
bootstrapApplication
Expected Behavior
First day of week should depends on selected locale.
Actual Behavior
The first day of the week is always set to Sunday, regardless of the selected locale.
Environment
The text was updated successfully, but these errors were encountered: