Opened 10 years ago

Closed 10 years ago

Last modified 9 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
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: UI/UX:

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@…> 10 years ago.

Download all attachments as: .zip

Change History (5)

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

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.

Changed 10 years ago by Cheng <czhang.cmu+web@…>

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

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 Changed 10 years ago by Cheng <czhang.cmu+web@…>

  • Summary changed from django.core.formfields.TimeField.html2python can't handle time string with microsecond to [patch] django.core.formfields.TimeField.html2python can't handle time string with microsecond

comment:4 Changed 10 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

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