improved readability of time conversion

This commit is contained in:
Jonas Depoix 2021-06-07 08:52:29 +02:00
parent 6f4ab9decd
commit 99dd9126fd
1 changed files with 6 additions and 10 deletions

View File

@ -95,12 +95,8 @@ class WebVTTFormatter(Formatter):
'00:00:06.930' '00:00:06.930'
""" """
time = float(time) time = float(time)
hours= int(time) // 3600 hours, remainder = divmod(time, 3600)
time= time - hours*3600 mins, secs = divmod(remainder, 60)
mins, secs = (
int(time) // 60,
int(time) % 60,
)
ms = int(round((time - int(time))*1000, 2)) ms = int(round((time - int(time))*1000, 2))
return "{:02d}:{:02d}:{:02d}.{:03d}".format(hours, mins, secs, ms) return "{:02d}:{:02d}:{:02d}.{:03d}".format(hours, mins, secs, ms)