Simplfy TimeField passing through strings (#4197)

* Simplfy TimeField passing through strings
This commit is contained in:
Tom Christie 2016-06-14 16:05:00 +01:00 committed by GitHub
parent 9406e45b2c
commit 798a971f20

View File

@ -1196,7 +1196,7 @@ class TimeField(Field):
output_format = getattr(self, 'format', api_settings.TIME_FORMAT) output_format = getattr(self, 'format', api_settings.TIME_FORMAT)
if output_format is None: if output_format is None or isinstance(value, six.string_types):
return value return value
# Applying a `TimeField` to a datetime value is almost always # Applying a `TimeField` to a datetime value is almost always
@ -1209,8 +1209,6 @@ class TimeField(Field):
) )
if output_format.lower() == ISO_8601: if output_format.lower() == ISO_8601:
if isinstance(value, six.string_types):
value = datetime.datetime.strptime(value, '%H:%M:%S').time()
return value.isoformat() return value.isoformat()
return value.strftime(output_format) return value.strftime(output_format)