Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Bad resulting dates when typing incorrect date formats #3196

Closed
emb opened this issue Jan 16, 2015 · 4 comments
Closed

Bad resulting dates when typing incorrect date formats #3196

emb opened this issue Jan 16, 2015 · 4 comments

Comments

@emb
Copy link

emb commented Jan 16, 2015

Libraries

  1. Angular: 1.2.28
  2. Bootstrap: 0.12.0

Test Case

  1. Set datepicker format dd/MM/yyyy
  2. Type a date with a single digit month (notice bad-formatted date). Example: 04/1/2015

Expected Results

Invalid date. Or at least a date corresponding to the 4th of January 2015.

Observed Results

The date we find in the model is 1st of April 2015. This is obviously an incorrect date.

Working Example

http://plnkr.co/edit/3VHHBX?p=preview

@emb
Copy link
Author

emb commented Feb 19, 2015

I noticed in Firefox a date like 27/29/1956 is valid and converted to March 29th 1956.

@mirow
Copy link

mirow commented Apr 9, 2015

+1
The offending line in the code is:

var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue);

So if the date doesn't match the given format, bootstrap tests whether the value happens to produce a valid js date, which of course it shouldn't try to do at all.

@karianna
Copy link
Contributor

karianna commented Apr 9, 2015

suspect that this is now fixed on master if you'd like to give the bleeding edge a try

@RobJacobs
Copy link
Contributor

Here's a plunk with the latest version from master demonstrating the problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants