Skip to content
Browse files

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.
  • Loading branch information...
1 parent 7a6e5f0 commit b0b8458e5763b85d83958c5dffb4bf9e1148dfe2 @NetForce1 NetForce1 committed
Showing with 10 additions and 2 deletions.
  1. +10 −2 jquery-ui-timepicker-addon.js
View
12 jquery-ui-timepicker-addon.js
@@ -1425,8 +1425,16 @@
*/
$.datepicker._base_parseDate = $.datepicker.parseDate;
$.datepicker.parseDate = function(format, value, settings) {
- var splitRes = splitDateTime(format, value, settings);
- return $.datepicker._base_parseDate(format, splitRes[0], settings);
+ var date;
+ try {
+ date = this._base_parseDate(format, value, settings);
+ } catch (err) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ }
+ return date;
};
/*

0 comments on commit b0b8458

Please sign in to comment.
Something went wrong with that request. Please try again.