#14752 closed (fixed)
WeekArchiveView gives incorrect results when using weeks beginning with Monday
Reported by: | Mark Sundstrom | Owned by: | nobody |
---|---|---|---|
Component: | Generic views | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
WeekArchiveView defaults to weeks defined as beginning on Sunday (the strptime '%U' format) and this works correctly. Using weeks defined as beginning on Monday ('%W'), gives incorrect results. This is because BaseWeekArchiveView.get_dated_items calls the helper function, _date_from_string, with the wrong format.
For example, for the 10th week in 2009, beginning on Sunday, it correctly constructs the following:
time.strptime('2009__0__10', '%Y__%w__%U')
However, for the 10th week in 2009, beginning on Monday, it incorrectly constructs:
time.strptime('2009__0__10', '%Y__%w__%W')
This can be fixed by using:
time.strptime('2009__1__10', '%Y__%w__%W')
The '1' refers to the day of the week being Monday (Sunday = 0).
I've attached a patch, tests.diff, which demonstrates the problem, and another patch, dates.diff, with the correction.
Attachments (3)
Change History (7)
by , 14 years ago
Attachment: | tests.diff added |
---|
by , 14 years ago
Attachment: | dates.diff added |
---|
follow-up: 2 comment:1 by , 14 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
Attachment: | combined.diff added |
---|
comment:2 by , 14 years ago
Replying to lrekucki:
The patch looks ok, but both tests and the fix should be in a single diff - it's easier to test that way.
Okay, see combined.diff
I had separated them because I thought it would be easier to demonstrate the problem, i.e.: apply the test patch, see the bug, apply the fix, see the bug go away.
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The patch looks ok, but both tests and the fix should be in a single diff - it's easier to test that way.