-
Notifications
You must be signed in to change notification settings - Fork 6.8k
datepicker doesn't open to correct month for non US date format #5665
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
Comments
If faced the same issue when trying to use the datepicker with the Dutch date format (which is dd-MM-yyyy). When opening the date picker with a date from a previous month, it opened on the current month instead of the month of the selected date. Scrolling to the previous month showed the selected date correctly (highlighted), as you stated above. My fix was to the set the LOCALE_ID to the Dutch language in app.module.ts:
After that, the datepicker opens with the month of the date (instead of the current month), showing the highlighted date correctly at once. |
Thanks for the comment and workaround for this Peter. I've seen similar workarounds, however I feel this should be addressed as a bug as the date picker clearly knows how to correctly parse the date in the correct browser without the work around, however it seems to parse it again when deciding which month to open, rather than opening the month of the date that it currently has highlighted. |
There's a similar workaround for setting locale which does work (as opposed to providing a LOCALE_ID in AppModule) in issue #4832, however this does not resolve the problem of mm/dd/yyyy vs dd/mm/yyyy. It would be superbly awesome if somebody suggested either an alternative solution so that when the datepicker input shows 01/02/2000, the date opened is 1st February, not 2nd January, as it does now. |
Take a look at this: https://plnkr.co/edit/uPNESrA5VbKDrIjP9BaS?p=preview It's configured to Brazilian Portuguese and I think it's a workaround for all the issues pointed here. It is the docs recommended setup built by extending Material NativeDateAdapter (except for the format function, that probably will be not necessary in the next beta and provides the correct display of DST dates in the past for some very specific cases). See this PR: #5747 |
Any updates on this? Was about to report the same bug, just before i noticed this issue. |
FYI #6798 makes the breakage less noticeable because it removes unnecessary calls to In order to make this work correctly you will need to use a custom |
Closing this since |
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?
When reopening the date-picker, it should always open on the selected month
What is the current behavior?
If a date can be parsed as mm/dd/yyyy it will open at the month in that format, even if though it has correctly parsed the date and has the correct date highlighted if you scroll to the correct month
What are the steps to reproduce?
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U
This behaviour can be seen in the angular material examples: https://material.angular.io/components/datepicker/examples
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
angular 4.2.4
material 2.0.0-beta.8
Windows 10, Chrome 59.0.3071.115
TS 2.4.1
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: