1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 23:24:16 +01:00

Fix bugs in timestr(), converting msec to time string

Also adds a docstring for timestr().
This commit is contained in:
Olof Johansson 2013-03-12 19:52:49 +01:00
parent b35b2513da
commit f72f195e35

View File

@ -61,12 +61,25 @@ def get_http_data(url, method="GET", header="", data="", referer=None, cookiejar
response.close() response.close()
return data return data
def timestr(seconds): def timestr(msec):
total = float(seconds) / 1000 """
hours = int(total / 3600) Convert a millisecond value to a string of the following
minutes = int(total / 60) format:
sec = total % 60
output = "%02d:%02d:%02.02f" % (hours, minutes, sec) HH:MM:SS,SS
with 10 millisecond precision. Note the , seperator in
the seconds.
"""
sec = float(msec) / 1000
hours = int(sec / 3600)
sec -= hours * 3600
minutes = int(sec / 60)
sec -= minutes * 60
output = "%02d:%02d:%05.2f" % (hours, minutes, sec)
return output.replace(".", ",") return output.replace(".", ",")
def norm(name): def norm(name):