|
-
Jul 19th, 2009, 08:02 AM
#1
Thread Starter
Addicted Member
[RESOLVED] how to add up total time [HELP]
Ok I am making a program that shows how long you were gone for basically.
It will send a message to a chat you are in every 5, 10, 20, 30, 40, 50, or 60 minutes (you get to pick the time)
I would like it to add up the total time they are gone (in minutes)
so if they are gone for 2 hours and they choose 30 it will add up in a label saying "60". and when you stop it, it will send a message saying "Back from idle gone for "time" minutes.
And if I can, Can I convert the minutes into like instead of "gone for 60 minutes" it would be "gone for 1 hour" (if not that's fine, that is just and extra I would like)
-
Jul 19th, 2009, 08:15 AM
#2
Re: how to add up total time [HELP]
Create a local variable Count and initialise it to zero. Create a timer and set its interval to the desired duration in milliseconds (5 mins = 5 x 60 x 1000).
In the tick event increment Count by one (and you can display the elapsed time if you wish)
When the user has returned stop the timer, and the number of minutes would be Count * (timer interval / 1000 / 60). This will of course only be good up to the last completed interval of the timer tick, ie if duration was 5 mins and the user was away for 14 minutes it would report that they had been away 10 mins.
If you want the accurate total you can store the value of Now in a starttime variable and at eny point subtract Now from your stored starttime.
To convert that to hours you can get complete hours by using hrs = mins \ 60
-
Jul 19th, 2009, 01:06 PM
#3
Thread Starter
Addicted Member
Re: how to add up total time [HELP]
im a little confused, can you put this in a bit of a code version if you don't mind please.
-
Jul 19th, 2009, 01:11 PM
#4
Re: how to add up total time [HELP]
Which bit are you stuck with?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|