JSONEncoder: Don’t strip microseconds from time

Closes #4749.

This is the matching commit to the fix for `datetime` in #4256
This commit is contained in:
Carlton Gibson 2017-09-22 12:03:05 +02:00 committed by Carlton Gibson
parent ea894cd90a
commit e29ad1e7b3
2 changed files with 1 additions and 3 deletions

View File

@ -37,8 +37,6 @@ class JSONEncoder(json.JSONEncoder):
if timezone and timezone.is_aware(obj):
raise ValueError("JSON can't represent timezone-aware times.")
representation = obj.isoformat()
if obj.microsecond:
representation = representation[:12]
return representation
elif isinstance(obj, datetime.timedelta):
return six.text_type(total_seconds(obj))

View File

@ -44,7 +44,7 @@ class JSONEncoderTests(TestCase):
Tests encoding a timezone
"""
current_time = datetime.now().time()
assert self.encoder.default(current_time) == current_time.isoformat()[:12]
assert self.encoder.default(current_time) == current_time.isoformat()
def test_encode_time_tz(self):
"""