Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#6827 closed bug (fixed)

Datepicker: Incorrect value for "oo" during Daylight Saving Time

Reported by: thinkterry Owned by:
Priority: minor Milestone: 1.8.14
Component: ui.datepicker Version: 1.8.7
Keywords: Cc:
Blocked by: Blocking:

Description

Datepicker's formatDate (http://docs.jquery.com/UI/Datepicker/formatDate) renders dates that occur during Daylight Saving Time as fractions when using the format string 'oo' (three-digit day of the year).

To replicate, attach a Datepicker with the problematic format string to a text (input) box:

$('input#date').datepicker({ dateFormat: 'yy-oo' });

Here is a jsFiddle that does just that: http://jsfiddle.net/X8qDb/

Try to change the date in the text box to "2010-074" (15 March 2010). The Datepicker formats the value using the format string 'yy-oo'. Therefore the text box should display "2010-074" (00:00 15 March 2010). However, the text box displays "2010-73.95833333333333" (23:00 14 March 2010). This is the bug.

The Datepicker behaves this way for all dates that occurred during Daylight Saving Time, which began at 02:00 14 March 2010 and ended at 02:00 7 November 2010 (source: http://eclipse.gsfc.nasa.gov/SEhelp/daylightsaving.html).

The Datepicker also behaves this way for other years such as 2009 and 2011.

A possible explanation of the bug is that Daylight Saving Time made March 14, 2010 last 25 hours instead of 24. Therefore, 00:00 15 March 2010 is in fact 23:00 14 March 2010. If Datepicker selects 00:00 15 March 2010, it will in fact be choosing 23:00 14 March 2010, leading to "2010-73.95833333333333" being displayed.

This bug affects every version of jQuery and jQuery UI (at least up until 1.4.4 and 1.8.7, respectively), on all browsers and operating systems.

Change History (5)

comment:2 Changed 12 years ago by Scott González

Summary: Datepicker's formatDate renders dates as fractions if they are formatted as 'oo' and occur during Daylight Saving TimeDatepicker: Incorrect value for "oo" during Daylight Saving Time

comment:3 Changed 12 years ago by Jay Merrifield

Resolution: fixed
Status: newclosed

Datepicker: Made the day of year calculator be more accurate. Fixes #6827 - Datepicker: Incorrect value for "oo" during Daylight Saving Time.

Changeset: 41205cef4b23749592c832605452af6575970623

comment:4 Changed 12 years ago by Jay Merrifield

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 41205cef4b23749592c832605452af6575970623)

Changeset: c1470492bd902738a54b994ee29ff4eecedae855

comment:5 Changed 12 years ago by Scott González

Milestone: 1.91.8.14
Note: See TracTickets for help on using tickets.