-
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
datepicker bugs when Primary language is different from the Region #5492
Comments
We should be able to manually select the language of the datepicker too. |
Use the DateAdapter setLocale to select your region. Also build a custom date adapter to present it in the desired format. Take a look at this plunker (working for Brazilian Portuguese): http://plnkr.co/edit/jc4Ywu?p=preview If you search for datepicker here among the repo issues, you'll see a lot of topics with similar questions. It's a component still under construction, so somethings aren't done yet, like timepiker and possibly a more flexible library to deal with dates, like Moment.js. |
I don't want to hardcode it to a region or language just to solve it's internal bugs. The point on using this control is exactly because it automatically displays the systems date formats whatever they are. Expecting a bug fix and no workarounds. |
@PhilipSultanescu, actually, this behavior is not really a bug, is a design choice of a flexible component in its very early stages of development (Material 2 is on beta.7 and the datepicker was first relased in beta.5 if I rebember it right - and of course they are improving it). It is possible for you to try to detect the final user's browser locale (in a not reliable way, using For now I think you're asking for a feature (automatic locale detection, I guess), not a bug. I'd like it too. Even if it fails in some cases, it's better to have a way to tell the component to gess the locale (the app developer would provide the user ways to change it later), than have nothing. If want to follow some of the discussions arround the component, take a look at this (and other comments of the conversation): #675 (comment) |
#5419 will make the datepicker use the locale specified by angular's |
Thanks, will give it a try today. |
@PhilipSultanescu The |
IMHO still this is a design flaw. Take for example native date input. All browsers in all locales use ISO string as value (YYYY-MM-DD), but every browser in every locale presents this value in the specific format. Another example would be native number input. Value is always of type Number (xxx[.xxx]). But presentation varies for each locale (US: 1,234,567.89)(ES: 1.234.567,89). |
@mestremuten the |
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 when the OS Primary language (English) is different from the Region (Germany)
What is the expected behavior?
What is the current behavior?
Bad formatting, and wrong month shown when opening the datepicker like this:
What are the steps to reproduce?
On MacOS goto Language & Region preferences -> Set English - Primary -> Select Region: Germany, like this:
Open Plunker template: https://plnkr.co/edit/29fGaJ8uUQNsYoWDeXk4?p=preview
Just select a date in the datepicker, it will be wrongly formatted and you will get the above behavior.
If you then match the Deutsch - Primary to the Region: Germany region all is OK. Same for English - Primary to the Region: United States, but not when you mix them up like above.
What is the use-case or motivation for changing an existing behavior?
Datepicker should consistently work with the system formats, also when Language doesn't match the region.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
"@angular/core": "^4.2.3",
"@angular/material": "2.0.0-beta.7":
"typescript": "2.3.4"
MacOS Sierra
Chrome, Firefox, Safari
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: