Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Help! How to calculate elapsed seconds between two times and dates?

Author
Message
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 10th May 2017 14:04
Hi, all, i need some conceptual help.

This is for an "incremental game" (clicker game) prototype : the kind where you do something and it takes 20 seconds to complete, or you get +9 metal per second.
In these games, you make progress even while you are *NOT* actively playing.

I do *not* want to use "getmilliseconds()" for this, since users might close and reopen the app, and i want the actual time elapsed since they last played.

So AppGameKit reports time and date like this:
09:01:52
2017-05-10

I can't wrap my head around how to calculate the difference in time (base 24/60/60) ,
and then the date is even worse, with variable-length months...

I googled this, and found lots of ways to do it using built-in commands in other languages, but nothing about how it's actually *accomplished*

so, insight?

Thanks!
Bob
JohnnyMeek
11
Years of Service
User Offline
Joined: 23rd Apr 2013
Location: Slovenia
Posted: 10th May 2017 14:24
use something like this...


Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 10th May 2017 14:41
what happens if a user changes the system time/date ?


PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 10th May 2017 14:48
@JohnnyMeek :

That is exactly the sort of thing i need, and i did not know about it. THANK YOU!

@Kevin Picone :

That is something in the back of my mind, but accurate timekeeping was more important.

I suppose i could write times and dates to a file, where the latest (most futuristic) time+date would be saved,
and if the user ever accessed the game at a time that was BEFORE that "latest time",
the game would not accept it. That should never happen if someone does *not* mess with their clock, except possibly on "time change days" in USA...
- although i'm not sure what form the "punishment" should take.

Thanks all!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th May 2017 15:42
"time change days" occur usually at 0300 in the morning officially, so shouldn't be a problem, unless the player is currently playing the app at, or around the time. It's only twice a year, so shouldn't be a big issue.
Signature removed by mod because it's larger than 600x120... please resize and try again.

Login to post a reply

Server time is: 2024-04-24 12:30:36
Your offset time is: 2024-04-24 12:30:36