Components: Bug (mdDatepicker) Date editing problem

Created on 6 Jun 2017  路  7Comments  路  Source: angular/components

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When editing the date, the selected value is incorrect and this is due to the language of the browser used.

What is the current behavior?

fireshot capture 397 - plunker - https___plnkr co_edit__p preview

navigator.language
"fr"

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 4.1.3, Material 2.0.0-beta.6

Is there anything else we should know?

The bug is due to the language of the browser for the written in french the month becomes the day and the day becomes the month.

Most helpful comment

@naoufelus , take a look at this plunker, it's working: https://plnkr.co/edit/FlgGpjqyDlypas0VZJzo?p=preview

Basically it's a CustomAdapter class extending the Native one. It's configured to Brazilian portuguese, but you can change the language to french. I think it will work for you (because the date format is simillar - dd/MM/yyyy).

All 7 comments

Maybe this discussion will help https://github.com/angular/material2/issues/4985

@willshowell , I think you'd like to reference this other one: #4832

Oh lol thanks @julianobrasil

@naoufelus , take a look at this plunker, it's working: https://plnkr.co/edit/FlgGpjqyDlypas0VZJzo?p=preview

Basically it's a CustomAdapter class extending the Native one. It's configured to Brazilian portuguese, but you can change the language to french. I think it will work for you (because the date format is simillar - dd/MM/yyyy).

I owe you a beer @julianobrasil

@dan-lennox , if you're setting the locale globaly you can also look for a better place for doing it than the classes where you're using the datepicker, like in the plunk (it's a singleton and you have to do it just once in the application. I changed the plunk to better show it (put the setLocale in the main.ts).

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

constantinlucian picture constantinlucian  路  3Comments

jelbourn picture jelbourn  路  3Comments

vitaly-t picture vitaly-t  路  3Comments

savaryt picture savaryt  路  3Comments

crutchcorn picture crutchcorn  路  3Comments