Project

General

Profile

Actions

Defect #4857

closed

Week number calculation in date picker is wrong if a week starts with Sunday

Added by Holger Just about 14 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
UI
Target version:
Start date:
2010-01-17
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

The date-picker always displays the wrong week-number if you set the week to start with Sunday.

This behavior comes from the fact that the date-picker tries to find the week number based on the nearest Thursday to the first day of the respective week. It selects the following Thursday if the week starts with a Monday but the previous one if it starts with Sunday.

This however is the wrong approach as it should always select the Thursday of the current week (i.e. the following Thursday for this purpose). Otherwise the week number is always one off (or at least in 2009 and 2010).

The attached patch fixes this behavior and always selects the Thursday of the week of the given date. It thus provides the correct ISO 8601 week.

Note that you will still get in trouble in 2011, as the definition of the ISO 8601 week number as used in Europe (first week is the week which includes the Jan 4th) differs from the US week numbers (first week is the week which includes Jan 1st). So it might be a good idea to make the week-base configurable.


Files

calender.patch (607 Bytes) calender.patch Holger Just, 2010-02-17 12:57

Related issues

Related to Redmine - Defect #17625: Wrong week number in JQuery datepicker if start of week day is SundayClosed

Actions
Has duplicate Redmine - Defect #3271: Wrong week number in CalendarClosed2009-04-30

Actions
Has duplicate Redmine - Defect #3060: Week numbers dont match in reports and calendar popupsClosed2009-03-27

Actions
Actions #1

Updated by Jean-Philippe Lang about 14 years ago

  • Category set to UI
Actions #2

Updated by Holger Just over 13 years ago

Weeks in Redmine are always according ISO 8601. That means, the first week of the year is the one with the first Thursday of the year (or equivalently January 4). US-weeks on the other hand start at the week containing January 1.

Regarding the BugMash-10, I think, the patch is save, as it always selects the Thursday of the current week (rather than the nearest one). It should maybe made clear in the docs, that Redmine always uses ISO weeks.

See also #5329 for a related issue.

Actions #3

Updated by Eric Davis over 13 years ago

  • Status changed from New to Closed
  • Assignee set to Eric Davis
  • Target version set to 1.0.0 (RC)
  • Resolution set to Fixed

Fix committed in r3789. Thanks for researching this Holger.

Actions #4

Updated by Toshi MARUYAMA over 9 years ago

  • Related to Defect #17625: Wrong week number in JQuery datepicker if start of week day is Sunday added
Actions

Also available in: Atom PDF