ocarina/src/core/ct/times.py

42 lines
690 B
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Mar 16, 2010 7:36:48 PM$"
def ftime(time):
time = int(time)
#print time
# Find hour
length = ""
if time >= 3600:
hour = time/3600
time = time - (hour * 3600)
if hour > 0:
length=str(hour)+":"
# Find minute
if time >= 60:
min = time/60
time = time - (min * 60)
if min < 10:
length+="0"
length+=str(min)+":"
else:
length+="00:"
# Remainder is seconds
sec = time
if sec < 10:
length+="0"
length+=str(sec)
return length
def ms2str(ms):
# Convert ms to s
time = int(ms) / 1000000000
return ftime(time)