Defect #4857

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

Added by Holger Just almost 8 years ago. Updated over 7 years ago.

Status:ClosedStart date:2010-01-17
Priority:HighDue date:
Assignee:Eric Davis% Done:

0%

Category:UI
Target version:1.0.0 (RC)
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.

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


Related issues

Related to Redmine - Defect #17625: Wrong week number in JQuery datepicker if start of week d... Confirmed
Duplicated by Redmine - Defect #3271: Wrong week number in Calendar Closed 2009-04-30
Duplicated by Redmine - Defect #3060: Week numbers dont match in reports and calendar popups Closed 2009-03-27

Associated revisions

Revision 3789
Added by Eric Davis over 7 years ago

Calculate the correct week number for weeks starting at any date. #4857

http://en.wikipedia.org/wiki/ISO_week

Contributed by Holger Just

History

#1 Updated by Jean-Philippe Lang almost 8 years ago

  • Category set to UI

#2 Updated by Holger Just over 7 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.

#3 Updated by Eric Davis over 7 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.

#4 Updated by Toshi MARUYAMA over 3 years ago

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

Also available in: Atom PDF