-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Labels
P2The issue is important to a large percentage of users, with a workaroundThe issue is important to a large percentage of users, with a workaround
Description
Reproduction
Use StackBlitz to reproduce your issue:
Steps to reproduce:
- set
MAT_DATE_LOCALEto a locale from date-fns to something other thanenUS. For example:de. - run the following code
const parsed = dateAdapter.parse('02.01.2017', 'P') - observe the value of
parsedto beDate(Invalid Date)instead of an actual valid parsed date.
Expected Behavior
The value should be parsed correctly.
Actual Behavior
What behavior did you actually see?
The parsed value is Date(Invalid Date)
Proposed fix
Change line 168 in the date-fns-adapter.ts from:
const fromFormat = parse(value, currentFormat, new Date());to
const fromFormat = parse(value, currentFormat, new Date(), { locale: this.locale });Environment
- Angular: 12
- CDK/Material: next (13)
- Browser(s): Chrome
- Operating System: Windows
Additional notes:
The line 15 in the StackBlitz repro - if uncommented - gives an error due to a number of arguments. I tried installing the next version of @angular/core, but that didn't fix it. Not sure what to do about that, but it does not really affect the main described issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2The issue is important to a large percentage of users, with a workaroundThe issue is important to a large percentage of users, with a workaround