Skip to main content

Search and Top Navigation

#6827 closed bug (fixed)

Opened January 10, 2011 08:42PM UTC

Closed May 16, 2011 11:54AM UTC

Last modified May 16, 2011 11:54AM UTC

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.

Attachments (0)
Change History (5)

Changed May 14, 2011 10:21PM UTC by fracmak comment:1

Changed May 16, 2011 11:54AM UTC by scottgonzalez comment:2

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

Changed May 16, 2011 11:54AM UTC by Jay Merrifield comment:3

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

Changed May 16, 2011 11:54AM UTC by Jay Merrifield comment:4

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

Changed May 16, 2011 11:54AM UTC by scottgonzalez comment:5

milestone: 1.91.8.14