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):
|
def format_timecode(seconds):
|
||||||
'''
|
'''
|
||||||
>>> format_timecode(60 * 60 * 24 * 366)
|
>>> format_timecode(3599.999)
|
||||||
'1:001:00:00:00.000'
|
'00:59:59.999'
|
||||||
>>> format_timecode(30)
|
|
||||||
'00:30:00'
|
|
||||||
'''
|
'''
|
||||||
seconds = float(seconds)
|
seconds = float(seconds)
|
||||||
d = int(seconds / 86400)
|
d = int(seconds / 86400)
|
||||||
h = int(seconds % 86400 / 3600)
|
h = int(seconds % 86400 / 3600)
|
||||||
m = int(seconds % 36000 / 60)
|
m = int(seconds % 3600 / 60)
|
||||||
s = float(seconds % 60)
|
s = float(seconds % 60)
|
||||||
duration = "%02d:%02d:%06.3f" % (h, m, s)
|
duration = "%s%02d:%02d:%06.3f" % ('%d:' % d if d else '', h, m, s)
|
||||||
if d:
|
|
||||||
duration = '%d:'%d + duration
|
|
||||||
while duration.startswith('00:'):
|
|
||||||
duration = duration[3:]
|
|
||||||
return duration
|
return duration
|
||||||
|
|
||||||
def parse_timecode(string):
|
def parse_timecode(string):
|
||||||
|
|
Loading…
Reference in a new issue