Time

Functions dealing with time.

GetFormattedTime
Takes a time in seconds and returns a string in the form "0h:0m:0s".
IsDateNewer
Checks if dateA is more recent than dateB.
jbTimer struct
obsolete. Use LapTimer instead.
LapTimer struct
A handy timer struct, useful for timing or profiling.

GetFormattedTime:

Takes a time in seconds and returns a string in the form "0h:0m:0s".

Returns:

A string in the form "0h:0m:0s".

Arguments:
<seconds>
An float value representing a time in seconds.

Back to top...


IsDateNewer:

Checks if dateA is more recent than dateB.
The dates should be in the format returned by the localTime global, or the external file methods like getFileModDate.

Returns:

True if dateA is more recent than dateB, false if opposite, or undefined on failure.

Arguments:
<dateA>
A date to compare.
<dateB>
A date to compare.

Back to top...


LapTimer struct:

A handy timer struct, useful for timing or profiling.
Think of it as a stopwatched used to record times of a runner around a track.
Use it as follows:

t = LapTimer() -- Create a timer
t.CleanStart() -- Start timing
(...) -- do somthing here
print (t.Lap()) -- Returns how long it's been since Start() was called
(...) -- do some more stuff
print (t.Lap()) -- Returns how long it's been since the last Lap() call
(...) -- do even more stuff
print (getFormattedTime(t.Stop())) -- Stops timing, returns total time since start was called.

NOTE: If you use lap to time large time periods, be aware that it can't handle going across midnight twice between lap calls.
NOTE2: You can't time periods totaling more than 24 days or so. Live with it.

Available Functions:
Start
Starts the timer.
CleanStart
Garbage collect and then start the timer, for more accurate timing.
Lap
Records and returns how long it's been since Lap was last called (or Start, if Lap had not been previously called).
GetLastTime
Returns the value of the last Lap timed, or -1 on failure.
GetLapTime n
Returns the value of the Nth timed Lap, or -1 on failure.
GetNumLaps
Returns the number of laps timed so far.
GetAllTimes
Returns an array of all the timed laps so far.
GetTotalTime
Gets the total time of all the recorded laps so far.
Stop
Stop the timer and return the total time of all the laps.
Reset
Resets the timer to all the default values and erases any lap times recorded.

Back to top...