diff options
author | Keith Wood <kbwood.au@gmail.com> | 2008-06-16 09:56:43 +0000 |
---|---|---|
committer | Keith Wood <kbwood.au@gmail.com> | 2008-06-16 09:56:43 +0000 |
commit | 837699c7e0d2d444a17a2357aafe8d9649eb4987 (patch) | |
tree | 36846679d8c97edb5ceed2babbfb1e808d73a6ba /ui | |
parent | 74b7cde93963e09ca8012d62d470f23130a38c3b (diff) | |
download | jquery-ui-837699c7e0d2d444a17a2357aafe8d9649eb4987.tar.gz jquery-ui-837699c7e0d2d444a17a2357aafe8d9649eb4987.zip |
Allow relative dates with multiple periods
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.datepicker.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ui/ui.datepicker.js b/ui/ui.datepicker.js index 1a1dc1187..643f6de04 100644 --- a/ui/ui.datepicker.js +++ b/ui/ui.datepicker.js @@ -1054,11 +1054,12 @@ $.extend(DatepickerInstance.prototype, { }; var offsetString = function(offset, getDaysInMonth) { var date = new Date(); - var matches = /^([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?$/.exec(offset); - if (matches) { - var year = date.getFullYear(); - var month = date.getMonth(); - var day = date.getDate(); + var year = date.getFullYear(); + var month = date.getMonth(); + var day = date.getDate(); + var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g; + var matches = pattern.exec(offset); + while (matches) { switch (matches[2] || 'd') { case 'd' : case 'D' : day += (matches[1] - 0); break; @@ -1073,9 +1074,9 @@ $.extend(DatepickerInstance.prototype, { day = Math.min(day, getDaysInMonth(year, month)); break; } - date = new Date(year, month, day); + matches = pattern.exec(offset); } - return date; + return new Date(year, month, day); }; var date = this._get(name); return (date == null ? defaultDate : |