|
@@ -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)
|