Skip to content

Commit c147049

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.
(cherry picked from commit 41205ce)
1 parent 1866905 commit c147049

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
@@ -29,4 +29,9 @@ test('beforeShowDay-getDate', function() {
2929
inp.datepicker('hide');
3030
});
3131

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

ui/jquery.ui.datepicker.js

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

0 commit comments

Comments
 (0)