Skip to content

Commit

Permalink
Fixing IE string match undefined vs empty string issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewplummer committed Aug 16, 2018
1 parent 0a77786 commit 3bed7d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
5 changes: 1 addition & 4 deletions lib/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,7 @@ function getDateParamsFromString(str) {
match = str.match(/^(-?\d*[\d.]\d*)?\s?(\w+?)s?$/i);
if (match) {
if (isUndefined(num)) {
num = +match[1];
if (isNaN(num)) {
num = 1;
}
num = match[1] ? +match[1] : 1;
}
params[match[2].toLowerCase()] = num;
}
Expand Down
16 changes: 9 additions & 7 deletions test/tests/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -1339,14 +1339,16 @@ namespace('Date', function () {
});

group('Create | Out of bounds', function() {
// TODO: Note out of bounds dates here should no longer
// parse after native fallback is removed.

// Issue #636 - Months
// Note that formats like 2/30/2018 are intentionally
// NOT considered out of bounds to simplify logic as well
// as retain parity with most browser vendors.
assertDateNotParsed('19/6/2018');
assertDateNotParsed('13/6/2018');
assertDateNotParsed('0/6/2018');
assertDateParsed('19/6/2018', new Date('19/6/2018'));
assertDateParsed('13/6/2018', new Date('13/6/2018'));
assertDateParsed('0/6/2018', new Date('0/6/2018'));

// Years
assertDateParsed('1/1/10000', new Date(10000, 0, 1));
Expand All @@ -1359,10 +1361,10 @@ namespace('Date', function () {
assertDateNotParsed('1/1/1000000');

// Dates
assertDateNotParsed('1/0/2018');
assertDateNotParsed('1/32/2018');
assertDateNotParsed('1/0/2018');
assertDateNotParsed('1/00/2018');
assertDateParsed('1/0/2018', new Date('1/0/2018'));
assertDateParsed('1/32/2018', new Date('1/32/2018'));
assertDateParsed('1/0/2018', new Date('1/0/2018'));
assertDateParsed('1/00/2018', new Date('1/00/2018'));

// Hours
assertDateNotParsed('25:00');
Expand Down
1 change: 1 addition & 0 deletions test/tests/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ namespace('Number', function () {
});

method('ordinalize', function() {
test(0, '0th');
test(1, '1st');
test(2, '2nd');
test(3, '3rd');
Expand Down

0 comments on commit 3bed7d1

Please sign in to comment.