text: Opened 11 years ago
  Closed 11 years ago
  Last modified 10 years ago
  #1188 closed defect (fixed)
  [patch] django.core.formfields.TimeField.html2python can't handle time string with microsecond
  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 Changed 11 years ago by
  Changed 11 years ago by
  comment:2 Changed 11 years ago by
  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 11 years ago by
  comment:4 Changed 11 years ago by
  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.