Project

General

Profile

Actions

Defect #2462

closed

Incorrect Week Number in Spent Time Report

Added by Barry Goodsell almost 16 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Time tracking
Target version:
-
Start date:
2009-01-07
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate
Affected version:

Description

Whilst using the Spent Time Report, I have noticed that the Week display is incorrect for the first week of 2009. I set a date range of 2008-12-17 to 2009-01-07 and set the Report to show Weeks. The Weeks that are displayed are:
  • 2008-51
  • 2008-52
  • 2008-1
  • 2009-2

I asssume that the third week ought to show as 2009-1


Files

RedmineSpentTime.JPG (119 KB) RedmineSpentTime.JPG Barry Goodsell, 2009-01-07 18:41

Related issues

Has duplicate Redmine - Defect #2480: Spend time report small issueClosed2009-01-09

Actions
Has duplicate Redmine - Defect #3618: KW’s are not following ISO8601 > http://en.wikipedia.org/wiki/ISO_8601#Week_datesClosed2009-07-15

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

Actions
Is duplicate of Redmine - Defect #5329: Time entries report broken on first week of yearClosedJean-Philippe Lang2010-04-15

Actions
Actions #1

Updated by Anonymous over 15 years ago

Also affects calendar. I found that problem in our redmine installation and it turns out it's related to the start of the week. Problem is that week 1 of 2009 starts on december 2008,

If you go to calendar for January 2009, the first week is week 52 of 2008, when it should be week 1 of 2009. This doesn't happen if week starts on Monday.

For any week number calculation you should use Monday as first day of week. I would submit a patch, but I don't see any quick way to fix it, I just hacked it to force monday as first day of week, regardless which language you are using.

>> d-=1
=> Thu, 01 Jan 2009
>> [d.cweek,d.year,d.to_s]
=> [1, 2009, "2009-01-01"]
>> d-=1
=> Wed, 31 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [1, 2008, "2008-12-31"]
>> d-=1
=> Tue, 30 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [1, 2008, "2008-12-30"]
>> d-=1
=> Mon, 29 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [1, 2008, "2008-12-29"]
>> d-=1
=> Sun, 28 Dec 2008
>> [d.cweek,d.year,d.to_s]
=> [52, 2008, "2008-12-28"]

More info about week counting at http://en.wikipedia.org/wiki/ISO_week_date
Quoting:

Mutually equivalent definitions for week 01 are:
  • the week with the year's first Thursday in it (the ISO 8601 definition)
  • the week starting with the Monday which is nearest in time to 1 January
  • the week with the year's first working day in it (if Saturdays, Sundays, and 1 January are not working days)
  • the week with January 4 in it
  • the first week with the majority (four or more) of its days in the starting year
  • the week starting with the Monday in the period 29 December - 4 January
  • the week with the Thursday in the period 1 - 7 January
  • If 1 January is on a Monday, Tuesday, Wednesday or Thursday, it is in week 01. If 1 January is on a Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year.

I hope this helps fixing the problem. Also, fixing #2884 would allow a quick workaround

Actions #2

Updated by Anonymous over 15 years ago

Actually, it seems this bug can be fixed by using Date#cwyear instead of Date#year:

=> Fri, 26 Dec 2008
>> 7.times {d+=1; puts [d.cweek,d.cwyear,d.year,d.to_s].inspect}
[52, 2008, 2008, "2008-12-27"]
[52, 2008, 2008, "2008-12-28"]
[1, 2009, 2008, "2008-12-29"]
[1, 2009, 2008, "2008-12-30"]
[1, 2009, 2008, "2008-12-31"]
[1, 2009, 2009, "2009-01-01"]
[1, 2009, 2009, "2009-01-02"]

So in TimelogController#report change

        when 'week'
          @periods << "#{date_from.year}-#{date_from.to_date.cweek}" 
          date_from = (date_from + 7.day).at_beginning_of_week

to

        when 'week'
          @periods << "#{date_from.cwyear}-#{date_from.to_date.cweek}" 
          date_from = (date_from + 7.day).at_beginning_of_week

Actions #3

Updated by Holger Just over 14 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

This issue is being worked in in #5329.

Unfortunately, there are some more subtly difficulties to solve...

Actions

Also available in: Atom PDF