WeekArchiveView gives incorrect results when using weeks beginning with Monday
|Reported by:||msundstr||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
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:
However, for the 10th week in 2009, beginning on Monday, it incorrectly constructs:
This can be fixed by using:
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.
Change History (7)
comment:1 follow-up: ↓ 2 Changed 6 years ago by lrekucki
- Needs documentation unset
- Needs tests unset
- Patch needs improvement set
- Triage Stage changed from Unreviewed to Accepted