diff -r 0323b4125cec django/forms/fields.py
|
a
|
b
|
|
| 340 | 340 | return self.strptime(value, format) |
| 341 | 341 | except ValueError: |
| 342 | 342 | if format.endswith('.%f'): |
| 343 | | if value.count('.') != 1: |
| | 343 | # Compatibility with datetime in pythons < 2.6. |
| | 344 | # See: http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior |
| | 345 | if value.count('.') != format.count('.'): |
| 344 | 346 | continue |
| 345 | 347 | try: |
| 346 | 348 | datetime_str, usecs_str = value.rsplit('.', 1) |
| 347 | | usecs = int(usecs_str) |
| | 349 | usecs = int(usecs_str[:6].ljust(6, '0')) |
| 348 | 350 | dt = datetime.datetime.strptime(datetime_str, format[:-3]) |
| 349 | 351 | return dt.replace(microsecond=usecs) |
| 350 | 352 | except ValueError: |