Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#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)

strptime_delimiters.patch (1.8 KB ) - added by justinlilly@… 16 years ago.
added strptime delimiters
strptime_delimiters2.patch (1.8 KB ) - added by justinlilly@… 16 years ago.
now with - delimiters instead of delimiters
strptime_delimiters3.patch (4.1 KB ) - added by Justin Lilly 16 years ago.
Testing added.
strptime_delimiters4.patch (4.4 KB ) - added by Alex Gaynor 16 years ago.
added a templae for the day view
date_based_one_digit_month_confusion.patch (1.1 KB ) - added by Ryszard Szopa <ryszard.szopa@…> 16 years ago.

Download all attachments as: .zip

Change History (21)

comment:1 by Chris Beaven, 16 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Chris Beaven, 16 years ago

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...

comment:3 by anonymous, 16 years ago

Cc: justinlilly@… added

by justinlilly@…, 16 years ago

Attachment: strptime_delimiters.patch added

added strptime delimiters

comment:4 by Chris Beaven, 16 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 justinlilly@…, 16 years ago

Attachment: strptime_delimiters2.patch added

now with - delimiters instead of delimiters

comment:5 by Chris Beaven, 16 years ago

Has patch: set
Needs tests: set

The tests in #1282 can be augmented to test for this bug.

comment:6 by Justin Lilly, 16 years ago

Owner: changed from nobody to Justin Lilly
Status: newassigned

by Justin Lilly, 16 years ago

Attachment: strptime_delimiters3.patch added

Testing added.

by Alex Gaynor, 16 years ago

Attachment: strptime_delimiters4.patch added

added a templae for the day view

comment:7 by Ramiro Morales, 16 years ago

#10022 was a duplicate and included a patch too

by Ryszard Szopa <ryszard.szopa@…>, 16 years ago

comment:8 by Ryszard Szopa <ryszard.szopa@…>, 16 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 Ryszard Szopa <ryszard.szopa@…>, 16 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.)

in reply to:  8 comment:10 by Ramiro Morales, 16 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.

in reply to:  8 ; comment:11 by Justin Lilly, 16 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 Justin Lilly, 16 years ago

milestone: 1.1

Also, I'd like to see this in 1.1 as its an easy bugfix.

in reply to:  11 comment:13 by Ryszard Szopa <ryszard.szopa@…>, 16 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 Jacob, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [10457]) Fixed #7944: date-based generic views no longer get confused with a numeric month format. Thanks to Justin Lilly and Alex Gaynor.

comment:15 by Jacob, 16 years ago

(In [10459]) [1.0.X] Fixed #7944: date-based generic views no longer get confused with a numeric month format. Thanks to Justin Lilly and Alex Gaynor. Backport of r10457 and r10458 from trunk.

comment:16 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top