Refactor the timedelta_isoformat

This commit is contained in:
iory 2020-04-18 18:24:57 +09:00 committed by Ram Rachum
parent 35d3bc2db1
commit 444ea17314
2 changed files with 3 additions and 6 deletions

View file

@ -90,9 +90,6 @@ else:
return datetime_module.time(hour, minute, second, microsecond)
def timedelta_isoformat(timedelta, timespec='microseconds'):
assert isinstance(timedelta, datetime_module.timedelta)
if timespec != 'microseconds':
raise NotImplementedError
def timedelta_isoformat(timedelta):
time = (datetime_module.datetime.min + timedelta).time()
return time_isoformat(time, timespec)
return time_isoformat(time)

View file

@ -368,7 +368,7 @@ class Tracer:
if self.elapsed_time:
duration = datetime_module.datetime.now() - self.start_times[-1]
now_string = pycompat.timedelta_isoformat(
duration, timespec='microseconds') if not self.normalize else ' ' * 15
duration) if not self.normalize else ' ' * 15
else:
now = datetime_module.datetime.now().time()
now_string = pycompat.time_isoformat(now, timespec='microseconds') if not self.normalize else ' ' * 15