comparison python/utils.py @ 261:4aa792cb0fa9

changing framesToTime to return a datetime.time
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 25 Jul 2012 18:02:36 -0400
parents 571ba5ed22e2
children a048066bd20f
comparison
equal deleted inserted replaced
260:36cb40c51a5e 261:4aa792cb0fa9
165 ######################### 165 #########################
166 166
167 def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)): 167 def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)):
168 'returns hour, minutes and seconds' 168 'returns hour, minutes and seconds'
169 from math import floor 169 from math import floor
170 seconds = floor(float(nFrames)/float(frameRate)) 170 from datetime import time
171 h = floor(seconds/3600.) 171 seconds = int(floor(float(nFrames)/float(frameRate)))
172 h = int(floor(seconds/3600.))
172 seconds = seconds - h*3600 173 seconds = seconds - h*3600
173 m = floor(seconds/60) 174 m = int(floor(seconds/60))
174 seconds = seconds - m*60 175 seconds = seconds - m*60
175 return (h+initialTime[0], m+initialTime[1], seconds+initialTime[2]) 176 return time(h+int(initialTime[0]), m+int(initialTime[1]), seconds+int(initialTime[2]))
176 177
177 def sortXY(X,Y): 178 def sortXY(X,Y):
178 'returns the sorted (x, Y(x)) sorted on X' 179 'returns the sorted (x, Y(x)) sorted on X'
179 D = {} 180 D = {}
180 for x, y in zip(X,Y): 181 for x, y in zip(X,Y):