Skip to content

Commit

Permalink
Datepicker: Made the day of year calculator be more accurate. Fixes #…
Browse files Browse the repository at this point in the history
…6827 - Datepicker: Incorrect value for "oo" during Daylight Saving Time.

(cherry picked from commit 41205ce)
  • Loading branch information
fracmak authored and scottgonzalez committed May 16, 2011
1 parent 1866905 commit c147049
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/unit/datepicker/datepicker_tickets.js
Expand Up @@ -29,4 +29,9 @@ test('beforeShowDay-getDate', function() {
inp.datepicker('hide');
});

test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
equals(time, "089");
});

})(jQuery);
2 changes: 1 addition & 1 deletion ui/jquery.ui.datepicker.js
Expand Up @@ -1181,7 +1181,7 @@ $.extend(Datepicker.prototype, {
break;
case 'o':
output += formatNumber('o',
(date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
break;
case 'm':
output += formatNumber('m', date.getMonth() + 1, 2);
Expand Down

0 comments on commit c147049

Please sign in to comment.