Skip to content

Commit

Permalink
Date parser: Assert numeric token.value is not NaN
Browse files Browse the repository at this point in the history
Fixes #696
  • Loading branch information
rxaviers committed May 24, 2017
1 parent b32457c commit f97a34d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/date/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ return function( value, numberParser, properties ) {
return false;
}

if ( numeric && isNaN( token.value ) ) {
return false;
}

tokens.push( token );
return true;
});
Expand Down
3 changes: 3 additions & 0 deletions test/unit/date/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ QUnit.test( "should parse composite of date fields", function( assert ) {
// Loose matching: ignore control characters.
date1 = new Date( 2010, 8, 15 );
assert.dateParse( "15/9/2010", "d\u200f/M\u200f/y", cldr, date1 );

// Test #696 - Mix of numbering systems.
assert.dateParse( "15/٧/2010", "d/M/y", cldr, null );
});

/**
Expand Down
3 changes: 3 additions & 0 deletions test/unit/date/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ QUnit.test( "should tokenize day (d) with no padding", function( assert ) {
lexeme: "2",
value: 2
}] );

// Test #696 - Mix of numbering systems.
assert.dateTokenizer( "٧", "d", cldr, [] );
});

QUnit.test( "should tokenize day (dd) with padding", function( assert ) {
Expand Down

0 comments on commit f97a34d

Please sign in to comment.