mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
add formatElapsedSeconds
This commit is contained in:
parent
775fb9c086
commit
b747b3133e
@ -528,3 +528,22 @@ def lineupPos(i, num, spacing):
|
|||||||
assert i >= 0 and i < num
|
assert i >= 0 and i < num
|
||||||
pos = float(i) * spacing
|
pos = float(i) * spacing
|
||||||
return pos - ((float(spacing) * (num-1))/2.)
|
return pos - ((float(spacing) * (num-1))/2.)
|
||||||
|
|
||||||
|
def formatElapsedSeconds(seconds):
|
||||||
|
"""
|
||||||
|
Returns a string of the form "mm:ss" or "hh:mm:ss" or "n days",
|
||||||
|
representing the indicated elapsed time in seconds.
|
||||||
|
"""
|
||||||
|
seconds = (int)(seconds)
|
||||||
|
hours = (int)(seconds / (60 * 60))
|
||||||
|
if hours > 36:
|
||||||
|
days = (int)((hours + 12) / 24)
|
||||||
|
return "%d days" % (days)
|
||||||
|
|
||||||
|
seconds -= hours * (60 * 60)
|
||||||
|
minutes = (int)(seconds / 60)
|
||||||
|
seconds -= minutes * 60
|
||||||
|
if hours != 0:
|
||||||
|
return "%d:%02d:%02d" % (hours, minutes, seconds)
|
||||||
|
else:
|
||||||
|
return "%d:%02d" % (minutes, seconds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user