Re: Get GamePlaying Time

new topic     » goto parent     » topic index » view thread      » older message » newer message
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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu