Use stopwatches to display time differences.

Post Reply
User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Use stopwatches to display time differences.

Post by tsuujin »

Here's a small bit of code you can use to output a string of current date, and amount of time elasped since the last call to the function.
Code: [show] | [select all] lua
systemTimer = createStopWatch()
startStopWatch(systemTimer)

function printTime()
	local tm = os.date("*t")
	local td = string.format("%02d:%02d:%02d",tm.hour,tm.min,tm.sec)
	cecho(string.format("<SlateBlue>\<\<%s +%0.3f\>\>",td,stopStopWatch(systemTimer)))
	resetStopWatch(systemTimer)
	startStopWatch(systemTimer)
end

Post Reply