Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#1188 closed defect (fixed)

[patch] django.core.formfields.TimeField.html2python can't handle time string with microsecond

Reported by: Cheng <czhang.cmu+web@…> Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

from django.core.formfields import TimeField
t=TimeField()
t=TimeField('abc')
t2=t.html2python('01:12:13.123453')
type(t2)

<type 'NoneType'>

t2=t.html2python('01:12:13')
t2

datetime.time(1, 12, 13)

Attachments (1)

formfields.TimeField.patch (1.4 KB ) - added by Cheng <czhang.cmu+web@…> 19 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Cheng <czhang.cmu+web@…>, 19 years ago

This bug will break a form manipulator which contains a time field whose actual time's microsecond != 0.

I think the reason is in html2python(), time.strptime() doesn't support microsecond precision. A patch will follow.

by Cheng <czhang.cmu+web@…>, 19 years ago

Attachment: formfields.TimeField.patch added

comment:2 by Cheng <czhang.cmu+web@…>, 19 years ago

After the patch:

>>> from django.core.formfields import TimeField
>>> t=TimeField()
>>> t=TimeField('abc') 
>>> t2=t.html2python('01:12:13.123453')
>>> t2
datetime.time(1, 12, 13, 123453)
>>> t2=t.html2python('01:12:13')
>>> t2
datetime.time(1, 12, 13)

comment:3 by Cheng <czhang.cmu+web@…>, 19 years ago

Summary: django.core.formfields.TimeField.html2python can't handle time string with microsecond[patch] django.core.formfields.TimeField.html2python can't handle time string with microsecond

comment:4 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [1872]) Fixed #1188 -- Changed TimeField.html2python to handle microseconds. Thanks, Cheng

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