Django

Code

Ticket #7944 (assigned)

Opened 6 months ago

Last modified 5 months ago

Generic date based views get confused with a numeric month_format

Reported by: SmileyChris Assigned to: justinlilly (accepted)
Milestone: Component: Generic views
Version: SVN Keywords:
Cc: justinlilly@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

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

strptime_delimiters.patch (1.8 kB) - added by justinlilly@gmail.com on 07/24/08 23:22:57.
added strptime delimiters
strptime_delimiters2.patch (1.8 kB) - added by justinlilly@gmail.com on 07/25/08 06:29:16.
now with - delimiters instead of delimiters
strptime_delimiters3.patch (4.1 kB) - added by justinlilly on 08/31/08 01:06:34.
Testing added.
strptime_delimiters4.patch (4.4 kB) - added by Alex on 10/31/08 15:19:49.
added a templae for the day view

Change History

07/24/08 16:55:50 changed by SmileyChris

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

07/24/08 17:02:47 changed by SmileyChris

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

07/24/08 21:48:25 changed by anonymous

  • cc set to justinlilly@gmail.com.

07/24/08 23:22:57 changed by justinlilly@gmail.com

  • attachment strptime_delimiters.patch added.

added strptime delimiters

07/25/08 00:19:22 changed by SmileyChris

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.

07/25/08 06:29:16 changed by justinlilly@gmail.com

  • attachment strptime_delimiters2.patch added.

now with - delimiters instead of delimiters

07/25/08 17:27:44 changed by SmileyChris

  • has_patch set to 1.
  • needs_tests set to 1.

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

08/09/08 15:54:51 changed by justinlilly

  • owner changed from nobody to justinlilly.
  • status changed from new to assigned.

08/31/08 01:06:34 changed by justinlilly

  • attachment strptime_delimiters3.patch added.

Testing added.

10/31/08 15:19:49 changed by Alex

  • attachment strptime_delimiters4.patch added.

added a templae for the day view


Add/Change #7944 (Generic date based views get confused with a numeric month_format)




Change Properties
Action