def to_python(self, value):
if value in validators.EMPTY_VALUES:<EOL><INDENT>return None<EOL><DEDENT>if isinstance(value, datetime.datetime):<EOL><INDENT>return value.time()<EOL><DEDENT>if isinstance(value, datetime.time):<EOL><INDENT>return value<EOL><DEDENT>if isinstance(value, list):<EOL><INDENT>if len(value) != <NUM_LIT:2>:<EOL><INDENT>raise ValidationError(self.error_messages['<STR_LIT>'])<EOL><DEDENT>if value[<NUM_LIT:0>] in validators.EMPTY_VALUES and value[<NUM_LIT:1>] invalidators.EMPTY_VALUES:<EOL><INDENT>return None<EOL><DEDENT>start_value = value[<NUM_LIT:0>]<EOL>end_value = value[<NUM_LIT:1>]<EOL><DEDENT>start_time = None<EOL>end_time = None<EOL>for format in self.input_formats or formats.get_format('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>start_time = datetime.datetime(<EOL>*time.strptime(start_value, format)[:<NUM_LIT:6>]<EOL>).time()<EOL><DEDENT>except ValueError:<EOL><INDENT>if start_time:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>raise ValidationError(self.error_messages['<STR_LIT>'])<EOL><DEDENT><DEDENT><DEDENT>for format in self.input_formats or formats.get_format('<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>end_time = datetime.datetime(<EOL>*time.strptime(end_value, format)[:<NUM_LIT:6>]<EOL>).time()<EOL><DEDENT>except ValueError:<EOL><INDENT>if end_time:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>raise ValidationError(self.error_messages['<STR_LIT>'])<EOL><DEDENT><DEDENT><DEDENT>return (start_time, end_time)<EOL>
Validates that the input can be converted to a time. Returns a
Python datetime.time object.