Show tooltipText in foreground of the Status Chart - Vision

Looking at this, it looks a little silly to me displaying elapsed time in seconds over timespans that cover days or even weeks, so remembering a function I recently developed for summing timespans in power tables, I figured it could be easily applied to this as well. If the following function is added to the above script:

def format_time(timestamp):
	days = int(timestamp / 86400)
	hours = int((timestamp % 86400) / 3600)
	minutes = int((timestamp % 3600) / 60)
	seconds = int(timestamp % 60)
	output = []
	if days > 0:
		output.append(str(days) + 'd')
	if hours > 0:
		output.append(str(hours) + 'h')
	if minutes > 0:
		output.append(str(minutes) + 'm')
	if seconds > 0:
		output.append(str(seconds) + 's')
	return ' : '.join(output) if output else '0s'

and the timeDiff = line is changed from str((float(endDate) - float(startDate)) / 1000) to format_time((float(endDate) - float(startDate)) / 1000)

The result will look like this:

Edit: added missing return statement to function

1 Like