md-datepicker date returned can be different if date entered as text or via calendar drop down
Two issues.
[1] Selecting date via drop down shows a different value compared to entering same date as text.
I define (via .config of $mdDateLocaleProvider) a date format of YYYY-MM-DD.
I select a date via calendar drop down of October 1, 2015. ... the value returned is: 2015-10-01T04:00:00.000Z ... correct.
I enter a date via the text input: 10/01/2015 ... the value returned is: 2015-10-01T04:00:00.000Z ... also correct
I enter a date via the text input: 10-01-2015 ... the value returned is: 2015-10-01T04:00:00.000Z ... also correct
I enter a date via the text input: 2015/10/01 ... the value returned is: 2015-10-01T04:00:00.000Z ... also correct
So, it appears that the '/' and the '-' are interchangeable...
Note: I took the liberty of testing 'new Date(string)' directly to see if the problem was in the Date constructor.
new Date('2015/10/01') generated: 2015-10-01T04:00:00.000Z new Date('2015-10-01') generated: 2015-10-01T04:00:00.000Z
So the problem does not appear to be in the Date constructor.
BUT I enter a date via the text input: 2015-10-01 (which conforms to the 'YYYY-MM-DD' set in the .config) ... the value returned is: 2015-09-30T04:00:00.000Z ... WHICH IS WRONG!
The use of the '/' in the date works differently than using a '-' as a separator (remember, I used the '-' in the .config setting).
[2] Unrelated issue:
<md-datepicker ...></md-datepicker> ... works
but
<md-datepicker .../> does not work.
In the 'does not work case' the HTML after the datepicker is not recognized as such.
See codepen for demonstration of both issues: http://codepen.io/djmarcus/pen/RWpJNe
@djmarcus1 are you using a custom date parser/formatter with $mdDateLocaleProvider? If not, it's just using the browser's default parsing, which leave a lot to be desired.
Yes, I am using a custom date formatter... see original post on Oct 3 (above).
I define (via .config of $mdDateLocaleProvider) a date format of YYYY-MM-DD.
+1
+1
+1