Opened 5 years ago

Closed 5 years ago

#14973 closed defect (fixed)

wxDateTime::GetWeekOfYear() with Monday_First give wrong week number

Reported by: aimo Owned by: vadz
Priority: normal Milestone: 2.9.5
Component: base Version: stable-latest
Keywords: wxDateTime GetWeekOfYear Cc:
Blocked By: Blocking:
Patch: yes


v2.9.4 and trunk return wrong value with day 2012-12-31. This day is Monday and week number it gives is 53. Week number should be 1.

Attachments (1)

getweekofyear.patch download (1.9 KB) - added by aimo 5 years ago.
Week number calculation fix

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by aimo

Week number calculation fix

comment:1 Changed 5 years ago by vadz

  • Milestone set to 2.9.5
  • Owner set to vadz
  • Status changed from new to accepted

Embarrassing to be in the same company as Apple :-( Thanks for finding the bug, I'll commit it soon after adding some more tests.

comment:2 Changed 5 years ago by vadz

This does look correct, thanks again, I'll push your fix soon.

But thinking more about this, we really ought to have GetYearOfWeekOfYear() or something like this because the week number is not very useful if you don't which year it refers to... Or perhaps add an output parameter int* year to GetWeekOfYear() itself.

comment:3 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [73402]) Fix wxDateTime::GetWeekOfYear() for the days in the last week of the year.

The code took into account the possibility that the days in the beginning of
the year might belong to the last week of the previous year but not that the
days at the end of the year could belong to the first week of the next year.

Closes #14973.

Note: See TracTickets for help on using tickets.