diff python/utils.py @ 395:6fba1ab040f1

minor modification to framestotime
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 26 Jul 2013 17:52:23 -0400
parents 03dbecd3a887
children b36b00dd27c3
line wrap: on
line diff
--- a/python/utils.py	Fri Jul 26 17:24:33 2013 -0400
+++ b/python/utils.py	Fri Jul 26 17:52:23 2013 -0400
@@ -3,6 +3,7 @@
 
 #from numpy import *
 #from pylab import *
+from datetime import time
 
 __metaclass__ = type
 
@@ -144,11 +145,12 @@
 def argMaxDict(d):
     return max(d.iterkeys(), key=(lambda key: d[key]))
 
-def framesToTime(nFrames, frameRate, initialTime = (0.,0.,0.)):
-    'returns hour, minutes and seconds'
+def framesToTime(nFrames, frameRate, initialTime = time()):
+    '''returns a datetime.time for the time in hour, minutes and seconds
+    initialTime is a datetime.time'''
     from math import floor
     from datetime import time
-    seconds = int(floor(float(nFrames)/float(frameRate))+initialTime[0]*3600+initialTime[1]*60+initialTime[2])
+    seconds = int(floor(float(nFrames)/float(frameRate))+initialTime.hour*3600+initialTime.minute*60+initialTime.second)
     h = int(floor(seconds/3600.))
     seconds = seconds - h*3600
     m = int(floor(seconds/60))