diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-05-04 14:00:20 -0700 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-05-04 14:00:20 -0700 |
commit | 511b86b31efd16e2966a1155cdb47b951f01c204 (patch) | |
tree | 01eaf63e550d31c3e005d67bd1216e95d70ef09a /ui | |
parent | 0678d604a3cdfb6cb557c7f3d4be5ffb3c281e22 (diff) | |
parent | a891e81e06c7ce491ae9058aea2fa7fbd51eddb6 (diff) | |
download | jquery-ui-511b86b31efd16e2966a1155cdb47b951f01c204.tar.gz jquery-ui-511b86b31efd16e2966a1155cdb47b951f01c204.zip |
Merge pull request #201 from kzys/trac-7062
Fixed #7062 - $.datepicker.parseDate does not work for some locale date strings.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.datepicker.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 3437d0bda..d49fb7781 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -996,14 +996,24 @@ $.extend(Datepicker.prototype, { }; // Extract a name from the string value and convert to an index var getName = function(match, shortNames, longNames) { - var names = (lookAhead(match) ? longNames : shortNames); - for (var i = 0; i < names.length; i++) { - if (value.substr(iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) { - iValue += names[i].length; - return i + 1; + var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { + return [ [k, v] ]; + }).sort(function (a, b) { + return -(a[1].length - b[1].length); + }); + var index = -1; + $.each(names, function (i, pair) { + var name = pair[1]; + if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) { + index = pair[0]; + iValue += name.length; + return false; } - } - throw 'Unknown name at position ' + iValue; + }); + if (index != -1) + return index + 1; + else + throw 'Unknown name at position ' + iValue; }; // Confirm that a literal character matches the string value var checkLiteral = function() { |