#1188 closed defect (fixed)
[patch] django.core.formfields.TimeField.html2python can't handle time string with microsecond
| Reported by: | 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)
Change History (5)
comment:1 by , 20 years ago
by , 20 years ago
| Attachment: | formfields.TimeField.patch added |
|---|
comment:2 by , 20 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 , 20 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 , 20 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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.