Validate that the input can be converted to a time. Return a Python datetime.time object.
(self, value)
| 509 | default_error_messages = {"invalid": _("Enter a valid time.")} |
| 510 | |
| 511 | def to_python(self, value): |
| 512 | """ |
| 513 | Validate that the input can be converted to a time. Return a Python |
| 514 | datetime.time object. |
| 515 | """ |
| 516 | if value in self.empty_values: |
| 517 | return None |
| 518 | if isinstance(value, datetime.time): |
| 519 | return value |
| 520 | return super().to_python(value) |
| 521 | |
| 522 | def strptime(self, value, format): |
| 523 | return datetime.datetime.strptime(value, format).time() |