-
Notifications
You must be signed in to change notification settings - Fork 6.8k
docs(material/datepicker): add note about locale data in date-fns #24067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
**Note:** if you're using the `MatDateFnsModule`, you have to provide the data object for your | ||
locale to `MAT_DATE_LOCALE`, instead of the locale code. Locale data for `date-fns` can be imported | ||
from `date-fns/locale`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also MAT_DATE_FORMATS to provide (Otherwise an error occurs: RangeError: Format string contains an unescaped latin alphabet character o
). Full working example:
import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns-adapter';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
import { deAT } from 'date-fns/locale';
{ provide: DateAdapter, useClass: DateFnsAdapter },
{ provide: MAT_DATE_LOCALE, useValue: deAT },
{ provide: MAT_DATE_FORMATS, useValue: MAT_DATE_FNS_FORMATS },
@crisbeto - is this one ready for review? |
Adds a note about how locale data should be provided for users that consume the `date-fns` adapter. Fixes angular#24026.
c2d24ca
to
330265a
Compare
This should be good to go @andrewseguin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…gular#24067) Adds a note about how locale data should be provided for users that consume the `date-fns` adapter. Fixes angular#24026.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a note about how locale data should be provided for users that consume the
date-fns
adapter.Fixes #24026.