Opened 16 years ago

Closed 13 years ago

#5714 closed Cleanup/optimization (fixed)

Date/Time fields' clean methods need strip()

Reported by: Simon Litchfield <simon@…> Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Minor, but trailing/leading spaces throw date/time fields.

Believe it or not this has come up on two separate occasions now, so I thought I'd submit the patch.

Attachments (3)

newforms-datetime-strip.diff (1.2 KB ) - added by Simon Litchfield 16 years ago.
fix5714.patch (4.3 KB ) - added by Matthias Kestenholz 13 years ago.
5714.diff (9.2 KB ) - added by Chris Beaven 13 years ago.

Download all attachments as: .zip

Change History (11)

by Simon Litchfield, 16 years ago

comment:1 by Chris Beaven, 16 years ago

Triage Stage: UnreviewedDesign decision needed

I'll push to a design decision, in the past these issues have been brushed off with a "create your own subclass" but I like the idea.

In fact, I'd be tempted to put a clean_strip attribute on Field (defaulting to False for most, overridden to True default for date/time fields) since this is a common request. But that's just me dreaming :)

comment:2 by Malcolm Tredinnick, 14 years ago

Resolution: duplicate
Status: newclosed
Triage Stage: Design decision neededAccepted

Marking as a dupe of #6362.

comment:3 by Malcolm Tredinnick, 14 years ago

Resolution: duplicate
Status: closedreopened

comment:4 by Malcolm Tredinnick, 14 years ago

The other ticket isn't a real-dupe. This particular data type is a no-brainer. We should strip the spaces before strptime'ing. Accepted.

comment:5 by Chris Beaven, 14 years ago

Needs tests: set

comment:6 by Matthias Kestenholz, 13 years ago

Needs tests: unset

by Matthias Kestenholz, 13 years ago

Attachment: fix5714.patch added

by Chris Beaven, 13 years ago

Attachment: 5714.diff added

comment:7 by Gabriel Hurley, 13 years ago

Severity: Normal
Type: Cleanup/optimization

comment:8 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: reopenedclosed

In [16137]:

Fixed #5714 -- Strip whitespaces around date and time form field values before converting it to a native type. Thanks to SmileyChris for the initial patch.

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