Permalink
Browse files

fix #3 Off-by-1 month when coercing a date if the coerced month has …

…fewer days than the current month
  • Loading branch information...
constantology
constantology committed Jun 5, 2013
1 parent 3310d6f commit b25855ad2d03435dfa6110fecc024805fc8f1fe8
Showing with 4 additions and 4 deletions.
  1. +2 −2 d8.js
  2. +1 −1 d8.min.js
  3. +1 −1 src/coerce.js
View
4 d8.js
@@ -97,7 +97,7 @@
}
function parse( re, keys, fn, s ) {
- var date = new Type( 0 ), parts = s.match( re ),
+ var date = new Type( 0, 0, 1, 0, 0, 0, 0 ), parts = s.match( re ),
parsers = associate( parts.slice( 1 ), keys );
Object.reduce( parsers, function( n, v, k ) {
@@ -152,7 +152,7 @@
if ( isNaN( parsers[DAY] ) ) parsers[DAY] = 1;
- date.setDate( parsers[DAY] ); date.setMonth( parsers[MONTH] ); date.setYear( parsers[YEAR] );
+ date.setYear( parsers[YEAR] ); date.setMonth( parsers[MONTH] ); date.setDate( parsers[DAY] );
}
function parse_setTime( date, hr, min, sec, ms ) {
Oops, something went wrong.

0 comments on commit b25855a

Please sign in to comment.