GNOME Bugzilla – Bug 415160
getElapsedTime counts mistaken time.
Last modified: 2007-03-07 06:43:58 UTC
The number of hour was error when _endTime great then 60. Fixed here :) def getElapsedTime (_endTime, _startTime): timeDiff = _endTime - _startTime hours = int (timeDiff / 3600) seconds = int (timeDiff - hours*3600) minutes = int (seconds / 60) seconds = int (seconds - minutes*60) days = 0 fmt = '' if hours > 24: hours = int (hours % 24) days = int (hours / 24) fmt = str (days) + ' day(s) ' fmt = fmt + str (hours) + ':' + str (minutes) + ':' + str (seconds) return fmt
Sorry, fixed again. def getElapsedTime (_endTime, _startTime): timeDiff = _endTime - _startTime minbaseon = 60 hourbaseon = minbaseon*60 daybaseon = hourbaseon*24 days = int (timeDiff / daybaseon) hours = int ((timeDiff - days*daybaseon) / hourbaseon) seconds = int (timeDiff - days*daybaseon - hours*hourbaseon) minutes = int (seconds / minbaseon) seconds = int (seconds - minutes*minbaseon) return ('%s day(s) %s:%s:%s' % (str (days), str (hours), str (minutes), str (seconds)))
def getElapsedTime (_endTime, _startTime): timeDiff = _endTime - _startTime minbaseon = 60 hourbaseon = minbaseon*60 daybaseon = hourbaseon*24 days = int (timeDiff / daybaseon) hours = int ((timeDiff - days*daybaseon) / hourbaseon) minutes = int ((timeDiff - days*daybaseon - hours*hourbaseon) / minbaseon) seconds = int (timeDiff - days*daybaseon - hours*hourbaseon - minutes*minbaseon) if days > 0: return ('%s day(s) %s:%s:%s' % (str (days), str (hours), str (minutes), str (seconds))) else: return ('%s:%s:%s' % (str (hours), str (minutes), str (seconds)))
Fixed in CVS. Thanks for the patch :)