diff options
author | Ivan Peters <ivan@ivanpeters.com> | 2011-01-18 16:25:58 +1300 |
---|---|---|
committer | Ivan Peters <ivan@ivanpeters.com> | 2011-01-18 16:25:58 +1300 |
commit | 67b070f97a6dc4907cbb5e69b8899c0b5c716684 (patch) | |
tree | 989ebe7d66813ea863fb30c05e6c1ed8f8c50cbc /tests | |
parent | 7608e4a1d604d6215693f88526947ecc61e8b8ed (diff) | |
download | jquery-ui-67b070f97a6dc4907cbb5e69b8899c0b5c716684.tar.gz jquery-ui-67b070f97a6dc4907cbb5e69b8899c0b5c716684.zip |
Datepicker: Update parseDate to properly handle a string value in shortYearCutoff. Fixed #6872: parseDate does not default shortYearCutoff correctly.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/datepicker/datepicker_options.js | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index af561a783..33b07d694 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -796,16 +796,21 @@ test('parseDate', function() { equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', 'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3), 'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy'); - equalsDate($.datepicker.parseDate('ymmdd', '010203'), - new Date(2001, 2 - 1, 3), 'Parse date ymmdd - default cutoff'); - equalsDate($.datepicker.parseDate('y-m-d', '01-02-03'), - new Date(2001, 2 - 1, 3), 'Parse date y-m-d - default cutoff'); - equalsDate($.datepicker.parseDate('y-m-d', '51-02-03'), - new Date(1951, 2 - 1, 3), 'Parse date y-m-d - default cutoff'); - equalsDate($.datepicker.parseDate('y-m-d', '51-02-03', {shortYearCutoff: 80}), - new Date(2051, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); - equalsDate($.datepicker.parseDate('y-m-d', '51-02-03', {shortYearCutoff: '+60'}), - new Date(2051, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); + var currentYear = new Date().getFullYear(); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'), + new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'), + new Date(currentYear+10, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 11) + '-02-03'), + new Date(currentYear-89, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); + equalsDate($.datepicker.parseDate('y-m-d', '80-02-03', {shortYearCutoff: 80}), + new Date(2080, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); + equalsDate($.datepicker.parseDate('y-m-d', '81-02-03', {shortYearCutoff: 80}), + new Date(1981, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 60) + '-02-03', {shortYearCutoff: '+60'}), + new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); + equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}), + new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); var gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @'); |