Re: Get GamePlaying Time
- Posted by mattlewis (admin) Aug 27, 2011
- 1055 views
Lone_EverGreen_Ranger said...
Could I get a working example of that? It would be easier for me to figure out if I had a visual example.
Something like this...
-- session times include std/datetime.e datetime start, finish export procedure start_session() start = now() end procedure export procedure finish_session() finish = now() end procedure export function session_duration() return diff( finish, start ) end function -- convert seconds into a datetime export function convert_seconds( integer seconds ) datetime duration = datetime:new() duration[SECOND] = remainder( seconds, 60 ) seconds = floor( seconds / 60 ) duration[HOUR] = remainder( seconds, 60 ) seconds = floor( seconds / 60 ) duration[DAY] = seconds return end function -- only works with DAY, HOUR, MINUTE, SECOND export function format( datetime duration ) return sprintf( "%d Days %02d:%02d:%02d", duration[DAY..$] ) end function
Matt