fix format_timecode
This commit is contained in:
parent
8e696b1da3
commit
645cc0ff04
1 changed files with 4 additions and 10 deletions
14
ox/format.py
14
ox/format.py
|
@ -408,21 +408,15 @@ def format_duration(ms, verbosity=0, years=True, hours=True, milliseconds=True):
|
|||
|
||||
def format_timecode(seconds):
|
||||
'''
|
||||
>>> format_timecode(60 * 60 * 24 * 366)
|
||||
'1:001:00:00:00.000'
|
||||
>>> format_timecode(30)
|
||||
'00:30:00'
|
||||
>>> format_timecode(3599.999)
|
||||
'00:59:59.999'
|
||||
'''
|
||||
seconds = float(seconds)
|
||||
d = int(seconds / 86400)
|
||||
h = int(seconds % 86400 / 3600)
|
||||
m = int(seconds % 36000 / 60)
|
||||
m = int(seconds % 3600 / 60)
|
||||
s = float(seconds % 60)
|
||||
duration = "%02d:%02d:%06.3f" % (h, m, s)
|
||||
if d:
|
||||
duration = '%d:'%d + duration
|
||||
while duration.startswith('00:'):
|
||||
duration = duration[3:]
|
||||
duration = "%s%02d:%02d:%06.3f" % ('%d:' % d if d else '', h, m, s)
|
||||
return duration
|
||||
|
||||
def parse_timecode(string):
|
||||
|
|
Loading…
Reference in a new issue