#7944 closed (fixed)
Generic date based views get confused with a numeric month_format
| Reported by: | Chris Beaven | Owned by: | Justin Lilly |
|---|---|---|---|
| Component: | Generic views | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | justinlilly@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Currently, the views are doing
*time.strptime(year+month+day, '%Y'+month_format+day_format)[:3])
Which causes problems if someone is using a numeric month_format.
a date of 2008-1-14 is converted to "2008114", which is read as 2008-11-4
Easy fix, just use a delimiter in the strptime method
Attachments (5)
Change History (21)
comment:1 by , 17 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 17 years ago
comment:3 by , 17 years ago
| Cc: | added |
|---|
comment:4 by , 17 years ago
I've had problems in the past doing this with just spaces (some weird bug with strptime).
To be safer, I'd use a dash as the delimiter.
by , 17 years ago
| Attachment: | strptime_delimiters2.patch added |
|---|
now with - delimiters instead of delimiters
comment:5 by , 17 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
The tests in #1282 can be augmented to test for this bug.
comment:6 by , 17 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
by , 17 years ago
| Attachment: | date_based_one_digit_month_confusion.patch added |
|---|
follow-ups: 10 11 comment:8 by , 17 years ago
I attached my patch from the closed #10022. It may do a better job as it will keep working no matter what is put into month_format, which could include the delimiter.
comment:9 by , 17 years ago
BTW when a fix for this bug is going to make it to the repo? (Please excuse me if this is the wrong place to ask such a question.)
comment:10 by , 17 years ago
Replying to Ryszard Szopa <ryszard.szopa@gmail.com>:
I attached my patch from the closed #10022. It may do a better job as it will keep working no matter what is put into month_format, which could include the delimiter.
Then you may want to include the tests already included in the other patches and possibly expand them to demonstrate the distinctive feature you describe. This (the existence of tests) would increase the probabilities of this ticket being fixed with a commit.
follow-up: 13 comment:11 by , 17 years ago
Replying to Ryszard Szopa <ryszard.szopa@gmail.com>:
I attached my patch from the closed #10022. It may do a better job as it will keep working no matter what is put into month_format, which could include the delimiter.
I'm not quite sure what your patch offers that mine does not. And unless I'm missing something else, you shouldn't be accepting delimiters from month_format. According to the docs, month_format should only accept strftime style arguments like %m or %b.
As it stands now, this ticket should be RFC, it just needs to be reviewed by someone and marked that way. If there is a flaw in my thinking, please let me know, but I don't think your patch solves the problem.
comment:12 by , 17 years ago
| milestone: | → 1.1 |
|---|
Also, I'd like to see this in 1.1 as its an easy bugfix.
comment:13 by , 17 years ago
Replying to justinlilly:
I'm not quite sure what your patch offers that mine does not. And unless I'm missing something else, you shouldn't be accepting delimiters from month_format. According to the docs, month_format should only accept strftime style arguments like %m or %b.
As it stands now, this ticket should be RFC, it just needs to be reviewed by someone and marked that way. If there is a flaw in my thinking, please let me know, but I don't think your patch solves the problem.
Both patches seem to fix the problem. You've included a test case, so you should be the winner ;-)
(Whatever gets into the release, I will be happy to see that bug finally fixed.)
comment:14 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Tests for day-related views (which are the only ones which will have this bug) can be found in #1282. It'd be easier if that was merged and then the patch written against that...