Skip to content

Commit 96de2aa

Browse files
committed
Merge remote branch 'pgraham/master'
2 parents effdd5d + 76e2b98 commit 96de2aa

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

tests/unit/datepicker/datepicker_tickets.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,22 @@ test('Ticket 6827: formatDate day of year calculation is wrong during day lights
3030
});
3131

3232
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
33-
expect(1);
33+
var date;
3434
try{
35-
var date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
35+
date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
36+
ok(false, "Did not properly detect an invalid date");
3637
}catch(e){
3738
ok("invalid date detected");
3839
}
40+
41+
try {
42+
date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm');
43+
equal(date.getDate(), 18);
44+
equal(date.getMonth(), 3);
45+
equal(date.getFullYear(), 1988);
46+
} catch(e) {
47+
ok(false, "Did not properly parse date with extra text separated by whitespace");
48+
}
3949
});
4050

4151
})(jQuery);

ui/jquery.ui.datepicker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,10 @@ $.extend(Datepicker.prototype, {
11021102
}
11031103
}
11041104
if (iValue < value.length){
1105-
throw "Extra/unparsed characters found in date: " + value.substring(iValue);
1105+
var extra = value.substr(iValue);
1106+
if (!/^\s+/.test(extra)) {
1107+
throw "Extra/unparsed characters found in date: " + extra;
1108+
}
11061109
}
11071110
if (year == -1)
11081111
year = new Date().getFullYear();

0 commit comments

Comments
 (0)