Skip to content
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: selects incorrect date for yyyy-mm-dd format #6111

Closed
hblieb opened this issue Jul 28, 2017 · 2 comments
Closed

datepicker: selects incorrect date for yyyy-mm-dd format #6111

hblieb opened this issue Jul 28, 2017 · 2 comments
Assignees

Comments

@hblieb
Copy link

hblieb commented Jul 28, 2017

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Keying in, for example, 2017-06-30 should result in June 30th 2017 being selected in the calendar popup..

What is the current behavior?

Examples:
Entering 2017-06-24 selects the 23rd
Entering 2017-6-08 selects the 7th
Entering 2017-06-08 selects the 7th
Entering 2017-6-8 works correctly
Entering 2017-06-8 works correctly

The problem only occurs when entry is in YYYY/MM/DD format and a 2-digit day is entered.

These other formats work correctly: mm-dd-yyyy (i.e. 6-30-2017) and dd-MMM-yyyy (i.e. 30-JUN-2017)

What are the steps to reproduce?

What is the use-case or motivation for changing an existing behavior?

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

Current version (Angular Material beta-8) at material.angular.io

Is there anything else we should know?

@mmalerba
Copy link
Contributor

The NativeDateAdapter is currently only able to parse mm-dd-yyyy due to limitations of JavaScript's Date object. We do have plans to make NativeDateAdapter more robust once the new i18n API arrives in Angular core (#6030). We also plan to add DateAdapters for libraries like Moment.js which give more control over the parse format (#5972). Neither of these is ready yet, if you need a quick solution immediately, I recommend extending NatvieDateAdapter and overriding the parse method to meet your needs.

Closing since #6030 is already tracking improved parsing in NativeDateAdapter

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants