-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
md-datepicker does not respect locale on manual input #5792
Comments
Take a look: https://plnkr.co/edit/GFTZ2Y7GfbUlNUWE3KLR?p=preview 😄 I think this is what you want, am I right? (look at the |
thanks a lot for your sample! :) with your workaroung now this works as expected. |
This is a limitation of the javascript Date object used by the NativeDateAdapter, @adoris. The original plans of the material guys is to provide one or two date adapters and left the apps developers with the choice to make others for themselves. One of these adapters is the NativeDateAdapter, that works with javascript Date object and its limitations concerning locales and formats configuration. There are future plans to suport Moment.js (a MomentDateAdapter). |
If NativeDateAdapter will not support user locale - all material components have no chance to be used in production code. Components from other manufacturer will be used. |
For now, de NativeDateAdapter is the only prebuilt DateAdapter. But the component is in its very early stages (it was released in beta 6, IIRC). The MomentDateAdapter will come up for more complex scenarios (where you want to give the final user a chance to define the interface locale, for example). |
@julianobrasil you solution seems not to work for date times. |
for anyone interested I modified the plunkr a bit to support hour, minute and second parsing. It's not pretty but until the Moment adapter is implemented it should be enought..
|
\o/ Just make sure you don't use the calendar popup to set the date. It will overide your time. There are plans for a timepicker in the future. |
proposed workaround with DateAdapter is very dirty hack, not for production code: for example, i can write "31.31.2017" and this will be accepted as a valid date. |
Why date format on selection by mouse are different from date format for keyboard input? |
This is not a bug. You can control the date chosen with mouse selection by overriding the format function in the NativeDateAdapter. |
This is currently working as expected. We recommend using a custom |
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. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
if german locale set - input date typed from keyboard must recognized in local format ("dd.mm.yyyy").
What is the current behavior?
if date selected by mouse - right date in right format will be diaplayed (german locale - displayed 21.07.2017).
If date will be typed from keyboard - "21.07.2017" - date will not be accepted.
If date will be typed from keyboard - "07/21/2017" - date will be accepted.
Input date will be accepted only in "mm/dd/yyyy" format, not in "dd.mm.yyyy".
What are the steps to reproduce?
here is a sample with locale "de-DE":
https://plnkr.co/edit/FNdibHY1y77mXrSiMTfL
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
@angular/core 4.3.0 @angular/material 2.0.0 beta8
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: