Skip to content

Commit 1a15262

Browse files
Merge pull request trentrichardson#284 from RichardBradley/dev
Fix error parsing date when setting option defaultDate
2 parents 3ac151f + 8e45662 commit 1a15262

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,10 +1207,15 @@ $.datepicker.parseDate = function(format, value, settings) {
12071207
try {
12081208
date = this._base_parseDate(format, value, settings);
12091209
} catch (err) {
1210-
// Hack! The error message ends with a colon, a space, and
1211-
// the "extra" characters. We rely on that instead of
1212-
// attempting to perfectly reproduce the parsing algorithm.
1213-
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1210+
if (err.indexOf(":") >= 0) {
1211+
// Hack! The error message ends with a colon, a space, and
1212+
// the "extra" characters. We rely on that instead of
1213+
// attempting to perfectly reproduce the parsing algorithm.
1214+
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1215+
} else {
1216+
// The underlying error was not related to the time
1217+
throw err;
1218+
}
12141219
}
12151220
return date;
12161221
};

0 commit comments

Comments
 (0)