]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Made the day of year calculator be more accurate. Fixes #6827 - Datepicke...
authorJay Merrifield <fracmak@gmail.com>
Sat, 14 May 2011 22:20:06 +0000 (18:20 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 16 May 2011 11:54:38 +0000 (07:54 -0400)
(cherry picked from commit 41205cef4b23749592c832605452af6575970623)

tests/unit/datepicker/datepicker_tickets.js
ui/jquery.ui.datepicker.js

index d00dc912cde60752852cec9152ee28aad9d9abc9..841e404057a41afa978fb7e13d8df180d3252912 100644 (file)
@@ -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);
index 93d468c36352383ddf66f154c1e7b1b25a15cfe7..e6ca5d984af38b4d23256b0f4d870bb0de563b6d 100644 (file)
@@ -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);