Skip to main content

Search and Top Navigation

#14907 open bug ()

Opened January 21, 2016 03:12PM UTC

Last modified October 06, 2016 10:56PM UTC

jQuery UI Datepicker showing incorrect week number

Reported by: iamdriz Owned by:
Priority: major Milestone: none
Component: ui.datepicker Version: 1.11.3
Keywords: Cc:
Blocked by: Blocking:
Description

When using the jQuery UI Datepicker and starting the week on a Sunday, the week numbers are incorrect. For example, 3rd Jan 2016 should be week 1 as all of the dates (3rd to 9th) are in the same year. But as you can see in the screenshot below, the UI shows it as week 53.

[[Image(http://i.stack.imgur.com/LEOe4.png)]]

Here is the code to render the datepicker:

$("#datepicker" ).datepicker({
    showWeek: true,
    firstDay: 0
});

So nothing special, other than showing the week numbers and starting the week on Sunday instead of Monday (as per default).

Here is a fiddle of the issue: https://jsfiddle.net/vLqabmmz/

Attachments (0)
Change History (5)

Changed January 25, 2016 10:43AM UTC by dasago87 comment:1

I got the same problem. If firstDay is set to 1 it works fine.

Changed January 25, 2016 03:23PM UTC by scottgonzalez comment:2

#14910 is a duplicate of this ticket.

Changed January 25, 2016 03:24PM UTC by scottgonzalez comment:3

status: newopen

Changed July 26, 2016 06:01PM UTC by asafjaffi comment:4

This issue happens because the print date of the work week is taken from the first date of the picker's rows.

When the first date is a Sunday (firstDay: 0), then it's passed to iso8601Week which states that it will "Find Thursday of this week starting on Monday", and Sundays just count as last week.

Changed October 06, 2016 10:56PM UTC by russellgilbert comment:5

This isn't so much a problem with the way iso8601Week calculates dates as it is the way the week number is displayed in its own column on the left side of the calendar when firstDay is set to 0 for Sunday. The ISO 8601 spec says that week numbers start on Monday, so the first day of week 1 in 2016 is Monday the 4th. But there's no good way to display Sunday the 3rd as week 53 and Monday the 4th as week 1, both on the same row. Maybe the showWeek option should be disabled when firstDay is set to 0, or maybe the week number should be displayed in each Monday cell, as Google Calendar does it, instead of in a separate column for the whole row.