Skip to content

Commit b0b8458

Browse files
committed
parseDate fails when dateFormat contains separator
When the dateFormat contains the separator that is used to split date and time, parseDate fails. Also, since parseDate has no access to the instance, it does not know the correct timeFormat, so splitting is not always correct.  Restoring the old hack of relying on datepickers error message seems to fix these issues.
1 parent 7a6e5f0 commit b0b8458

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,16 @@
14251425
*/
14261426
$.datepicker._base_parseDate = $.datepicker.parseDate;
14271427
$.datepicker.parseDate = function(format, value, settings) {
1428-
var splitRes = splitDateTime(format, value, settings);
1429-
return $.datepicker._base_parseDate(format, splitRes[0], settings);
1428+
var date;
1429+
try {
1430+
date = this._base_parseDate(format, value, settings);
1431+
} catch (err) {
1432+
// Hack! The error message ends with a colon, a space, and
1433+
// the "extra" characters. We rely on that instead of
1434+
// attempting to perfectly reproduce the parsing algorithm.
1435+
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1436+
}
1437+
return date;
14301438
};
14311439

14321440
/*

0 commit comments

Comments
 (0)