### Eclipse Workspace Patch 1.0
#P djangotrunk
|
|
|
311 | 311 | raise ValidationError(self.error_messages['invalid']) |
312 | 312 | |
313 | 313 | DEFAULT_TIME_INPUT_FORMATS = ( |
| 314 | '%H:%M:%S.%f', # '14:30:59.123456' |
314 | 315 | '%H:%M:%S', # '14:30:59' |
315 | 316 | '%H:%M', # '14:30' |
316 | 317 | ) |
… |
… |
|
337 | 338 | return value |
338 | 339 | for format in self.input_formats: |
339 | 340 | try: |
340 | | return datetime.time(*time.strptime(value, format)[3:6]) |
| 341 | # split usecs, because they are not recognized by strptime. |
| 342 | if '.' in value: |
| 343 | usecs = int(value.split('.')[-1]) |
| 344 | else: |
| 345 | usecs = 0 |
| 346 | return datetime.time(*time.strptime(value, format)[3:6],**{'microsecond':usecs}) |
341 | 347 | except ValueError: |
342 | 348 | continue |
343 | 349 | raise ValidationError(self.error_messages['invalid']) |
344 | 350 | |
345 | 351 | DEFAULT_DATETIME_INPUT_FORMATS = ( |
| 352 | '%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.123456' |
346 | 353 | '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' |
347 | 354 | '%Y-%m-%d %H:%M', # '2006-10-25 14:30' |
348 | 355 | '%Y-%m-%d', # '2006-10-25' |
… |
… |
|
384 | 391 | value = '%s %s' % tuple(value) |
385 | 392 | for format in self.input_formats: |
386 | 393 | try: |
387 | | return datetime.datetime(*time.strptime(value, format)[:6]) |
| 394 | # split usecs, because they are not recognized by strptime. |
| 395 | if '.' in value: |
| 396 | usecs = int(value.split('.')[-1]) |
| 397 | else: |
| 398 | usecs = 0 |
| 399 | return datetime.datetime(*time.strptime(value, format)[:6],**{'microsecond':usecs}) |
388 | 400 | except ValueError: |
389 | 401 | continue |
390 | 402 | raise ValidationError(self.error_messages['invalid']) |