Feature request
The developer should be able to set the first day of a week in a datepicker.
The first day of the week is always sunday.
In north america it is common that a week starts with sunday, but for example in germany (and i guess most european countries) the first day of the week is usually considered monday.
Angular Material 2.0.0-beta.10
First day of the week in ISO 8601 is also defined to be monday.
You can do it by creating your custom date adapter. If there's no special needs, just extends the Material NativeDateAdapter and overide the getFirstDayOfWeek() function. It must return the number of the first day of the week (0 - Sunday, 1 - Monday etc).
Here is a plunk, setting Tuesday as the first day of the week: https://plnkr.co/edit/9hEJki?p=preview
getFirstDayOfWeek(): number {
return 2;
}
Thank you, i didn't expected it to be part of the date adapter so i didn't searched there.
Currently in the NativeDateAdapter implementation it defaults to 0 because it can't be defined using native JS dates:
getFirstDayOfWeek(): number {
// We can't tell using native JS Date what the first day of the week is, we default to Sunday.
return 0;
}
I think setting the first day of a week is part of i18n. So maybe there could be a property for that on the MdDatepickerIntl service?
Closing, working as intended to use the DateAdapter as mentioned
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You can do it by creating your custom date adapter. If there's no special needs, just extends the Material NativeDateAdapter and overide the
getFirstDayOfWeek()function. It must return the number of the first day of the week (0 - Sunday, 1 - Monday etc).Here is a plunk, setting Tuesday as the first day of the week: https://plnkr.co/edit/9hEJki?p=preview