Django

Code

Ticket #1188 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: Cheng <czhang.cmu+web@gmail.com> Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

formfields.TimeField.patch (1.4 kB) - added by Cheng <czhang.cmu+web@gmail.com> on 01/08/06 01:03:50.

Change History

01/08/06 01:02:56 changed by Cheng <czhang.cmu+web@gmail.com>

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.

01/08/06 01:03:50 changed by Cheng <czhang.cmu+web@gmail.com>

  • attachment formfields.TimeField.patch added.

01/08/06 01:08:15 changed by Cheng <czhang.cmu+web@gmail.com>

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)

01/08/06 17:59:40 changed by Cheng <czhang.cmu+web@gmail.com>

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

01/08/06 18:54:36 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #1188 ([patch] django.core.formfields.TimeField.html2python can't handle time string with microsecond)




Change Properties
Action