Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

mdDatepicker: is one day off when typing #11250

Closed
luninroman opened this issue Apr 21, 2018 · 4 comments
Closed

mdDatepicker: is one day off when typing #11250

luninroman opened this issue Apr 21, 2018 · 4 comments
Assignees
Labels
needs: feedback The issue creator or community need to respond to questions in this issue resolution: works as expected The functionality works as designed and documented. type: bug

Comments

@luninroman
Copy link

luninroman commented Apr 21, 2018

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Date when typing should not be one day off

What is the current behavior?

So when I select a date via calendar pop-up and pick a day it gives me a correct day, but when I type a date - it gives me one day off, e.g. typing 2012-12-12 gives me Tue Dec 11 2012 00:00:00 GMT-0500 (EST)

CodePen and steps to reproduce the issue:

CodePen Demo which shows the issue: https://codepen.io/luninroman/pen/gzaPvR
Detailed Reproduction Steps:

Pick a date via input field, but not a calendar

Which versions of AngularJS, Material, OS, and browsers are affected?

AngularJS 1.6.9
Chrome 66.0.3359.117

Is there anything else we should know? Stack Traces, Screenshots, etc.

download
As you may see date is different from the one I typed
My current timezone Easter, not sure if it matters

@Splaktar
Copy link
Contributor

I believe that this is the same general issue that is tracked in, even though ng-model-options is not used:
#10431
#10598

@Splaktar Splaktar added needs: feedback The issue creator or community need to respond to questions in this issue type: bug labels Apr 21, 2018
@Splaktar Splaktar self-assigned this Apr 21, 2018
@Splaktar Splaktar added the needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community label Apr 21, 2018
@Splaktar Splaktar added this to the - Backlog milestone Apr 21, 2018
@codymikol
Copy link
Contributor

Looks like this occurs only if the $mdDateLocaleProvider.formatDate is set. If the config block is removed, everything works fine.

@codymikol
Copy link
Contributor

Can confirm this is actually not a bug.

What happened here is you overwrote $mdDateLocaleProvider.formatDate which tells angular material how to convert a date object into a string. You also need to overwrite the $mdDateLocaleProvider.parseDate functionality in order to tell angular material how to parse your date string back into a date object.

Here is a fixed pen: https://codepen.io/codymikol/pen/JBpzpz

@Splaktar Splaktar removed this from the - Backlog milestone Aug 1, 2018
@Splaktar Splaktar added resolution: works as expected The functionality works as designed and documented. and removed needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community labels Aug 1, 2018
@Splaktar
Copy link
Contributor

Splaktar commented Aug 1, 2018

@codymikol thank you for looking into this! Your suggestion looks good.

@Splaktar Splaktar closed this as completed Aug 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: feedback The issue creator or community need to respond to questions in this issue resolution: works as expected The functionality works as designed and documented. type: bug
Projects
None yet
Development

No branches or pull requests

3 participants