Skip to content

Commit 2654bd1

Browse files
MatthiasKunnenjelbourn
authored andcommitted
docs(moment-date-adapter): document formats (#16463)
Closes #14116.
1 parent 60d570b commit 2654bd1

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/material/datepicker/datepicker.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ requires. This is accomplished by subclassing `DateAdapter` and providing your s
262262
`DateAdapter` implementation. You will also want to make sure that the `MAT_DATE_FORMATS` provided
263263
in your app are formats that can be understood by your date implementation. See
264264
[_Customizing the parse and display formats_](#customizing-the-parse-and-display-formats)for more
265-
information about `MAT_DATE_FORMATS`. <!-- TODO(mmalerba): Add a guide about this -->
265+
information about `MAT_DATE_FORMATS`.
266266

267267
```ts
268268
@NgModule({
@@ -298,6 +298,37 @@ export class MyApp {}
298298

299299
<!-- example(datepicker-formats) -->
300300

301+
##### MomentDateModule formats
302+
303+
To use custom formats with the `MomentDateModule` you can pick from the parse formats documented
304+
[here](https://momentjs.com/docs/#/parsing/string-format/) and the display formats documented
305+
[here](https://momentjs.com/docs/#/displaying/format/).
306+
307+
It is also possible to support multiple parse formats. For example:
308+
309+
```ts
310+
@NgModule({
311+
imports: [MatDatepickerModule, MomentDateModule],
312+
providers: [
313+
{
314+
provide: MAT_DATE_FORMATS,
315+
useValue: {
316+
parse: {
317+
dateInput: ['l', 'LL'],
318+
},
319+
display: {
320+
dateInput: 'L',
321+
monthYearLabel: 'MMM YYYY',
322+
dateA11yLabel: 'LL',
323+
monthYearA11yLabel: 'MMMM YYYY',
324+
},
325+
},
326+
},
327+
],
328+
})
329+
export class MyApp {}
330+
```
331+
301332
#### Customizing the calendar header
302333

303334
The header section of the calendar (the part containing the view switcher and previous and next

0 commit comments

Comments
 (0)