-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Datepicker value is off by a day when date format is different from the datepicker's date format #2906
Comments
Could you please set up a Plunker that demonstrates this issue? |
Hi Chris, I create the plunker at: http://plnkr.co/edit/HGL5835WyhMQLibwDX3F Thanks Trish From: Chris Chua Could you please set up a Plunker that demonstrates this issue? — |
It looks like when the format is wrong it defaults using I think perhaps in this case, it makes sense to mark the input as invalid. |
Thanks Chris, we are looking into using a mask to ensure a correct date format. What do you mean by breaking change. On 11/03/14, Chris [email protected] wrote: It looks like when the format is wrong it defaults using new Date(viewValue) to create the date. And when there's a leading 0 in the day, the Date constructor treats it as if it's the UTC timezone (perhaps treating it like the ISO8601 date string format).I think perhaps in this case, it makes sense to mark the input as invalid.We could also add an option to make the string parsing relaxed as it is now, but it does lead to unusual errors like this and should only be opt-in. However, that will be a breaking change.—Reply to this email directly or view it on GitHub. |
This is a breaking change because users who are expecting a relaxed format (allowing strings that don't fit the dateParser format) are now going to see an invalid input and a null or empty value. As such, perhaps it can be a new option to validate the format strictly. |
Do you know of a good angular mask directive that would work with this datepicker? Thanks On 11/04/14, Chris [email protected] wrote: This is a breaking change because users who are expecting a relaxed format (allowing strings that don't fit the dateParser format) are now going to see an invalid input and a null or empty value. As such, perhaps it can be a new option to validate the format strictly.—Reply to this email directly or view it on GitHub. |
+1 for exposing a configuration option to allow 'strict' parsing, we've just encountered this issue with 'relaxed' parsing too on a multi-locale app. |
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting * codepen: http://codepen.io/davious/pen/gpyVQm related angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) related angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm?editors=101) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm?editors=101) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm?editors=101) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm?editors=101) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting [codepen](http://codepen.io/davious/pen/gpyVQm?editors=101) Related: angular-ui#1891, angular-ui#2702, angular-ui#2906, angular-ui#2952
datepickerConfig option timelessJsonMode for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format (1st load): converts model to date before normal formatting * timelessJsonUtils constant with method jsonDateToTicks for use with min-date, max-date * alias jsonDateAddDays * set timelessJsonMode = 'withUtils' to add methods to parent scope * also: jsonToDate -- used internally [codepen](http://codepen.io/davious/pen/XmMbma?editors=101) Related: angular-ui#1891, angular-ui#2906, angular-ui#2952
datepickerConfig option timelessJsonMode for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format (1st load): converts model to date before normal formatting * timelessJsonUtils constant with method jsonDateToTicks for use with min-date, max-date * alias jsonDateAddDays * set timelessJsonMode = 'withUtils' to add methods to parent scope * also: jsonToDate -- used internally [codepen](http://codepen.io/davious/pen/XmMbma?editors=101) Related: angular-ui#1891, angular-ui#2906, angular-ui#2952
datepickerConfig option timelessJsonMode for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format (1st load): converts model to date before normal formatting * timelessJsonUtils constant with method jsonDateToTicks for use with min-date, max-date * alias jsonDateAddDays * set timelessJsonMode = 'withUtils' to add methods to parent scope * also: jsonToDate -- used internally [codepen](http://codepen.io/davious/pen/XmMbma?editors=101) Related: angular-ui#1891, angular-ui#2906, angular-ui#2952
datepickerConfig option timelessJsonMode for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting * timelessJsonUtils constant with method jsonDateToTicks for use with min-date, max-date * alias jsonDateAddDays * set timelessJsonMode = 'withUtils' to add methods to parent scope * also: jsonToDate -- used internally [codepen](http://codepen.io/davious/pen/XmMbma?editors=101) Related: angular-ui#1891, angular-ui#2906, angular-ui#2952
datepickerConfig option timelessJsonMode for json models when we don't care about the time. * on init and parse: sets model to 'yyyy-MM-dd' format * on format: converts model to date before normal formatting * timelessJsonUtils constant with method jsonDateToTicks for use with min-date, max-date * alias jsonDateAddDays * set timelessJsonMode = 'withUtils' to add methods to parent scope * also: jsonToDate -- used internally [codepen](http://codepen.io/davious/pen/XmMbma?editors=101) Related: angular-ui#1891, angular-ui#2906, angular-ui#2952
This should now be fixed in |
I have my date picker format set to: datepicker-popup="MM/dd/yyyy".
If a user types in a date in a different format the date ends as the day before.
i.e. User types in 2013-10-07 date value is 2013/10/06. But if the user types in 2013-10-7 the date is correct.
User types in 2014-08-09 date value is 2014-08-08 but if the user types in 2014-9-09 the date is correct.
Here is an example using your the datepicker example on your website. It would seem it doesn't like the leading zeros.
The text was updated successfully, but these errors were encountered: