Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date parser: Assert numeric token.value is not NaN #733

Merged
merged 1 commit into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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