added formatTimeCompact

This commit is contained in:
Darren Ranalli 2008-06-19 21:05:31 +00:00
parent 838fe42ba7
commit ad5749c61e

View File

@ -29,7 +29,7 @@ __all__ = ['enumerate', 'unique', 'indent', 'nonRepeatingRandomList',
'GoldenRectangle', 'pivotScalar', 'rad90', 'rad180', 'rad270', 'rad360',
'nullGen', 'loopGen', 'makeFlywheelGen', 'flywheel', 'choice',
'printStack', 'printReverseStack', 'listToIndex2item', 'listToItem2index',
'pandaBreak','pandaTrace']
'pandaBreak','pandaTrace','formatTimeCompact']
import types
import string
@ -3315,6 +3315,26 @@ def recordFunctorCreationStacks():
Functor._functorCreationStacksRecorded = True
Functor.__call__ = Functor._exceptionLoggedCreationStack__call__
def formatTimeCompact(seconds):
# returns string in format '1d3h22m43s'
result = ''
a = int(seconds)
seconds = a % 60
a /= 60
if a > 0:
minutes = a % 60
a /= 60
if a > 0:
hours = a % 24
a /= 24
if a > 0:
days = a
result += '%sd' % days
result += '%sh' % hours
result += '%sm' % minutes
result += '%ss' % seconds
return result
globalPdb = None
traceCalled = False