Skip to content

Commit 41205ce

Browse files
fracmakscottgonzalez
authored andcommitted
Datepicker: Made the day of year calculator be more accurate. Fixes #6827 - Datepicker: Incorrect value for "oo" during Daylight Saving Time.
1 parent 463849e commit 41205ce

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tests/unit/datepicker/datepicker_tickets.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ test('beforeShowDay-getDate', function() {
2424
inp.datepicker('hide');
2525
});
2626

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

ui/jquery.ui.datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ $.extend(Datepicker.prototype, {
11851185
break;
11861186
case 'o':
11871187
output += formatNumber('o',
1188-
(date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3);
1188+
Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
11891189
break;
11901190
case 'm':
11911191
output += formatNumber('m', date.getMonth() + 1, 2);

0 commit comments

Comments
 (0)