[Gambas-user] arithmetic operations on dates and times

Kevin Fishburne kevinfishburne at ...1887...
Tue Jun 21 07:40:54 CEST 2011


On 06/08/2011 10:27 PM, Kevin Fishburne wrote:
> Alright, I wouldn't bother the list but this is blowing my mind a little
> bit.
>
> The date and time in the game world should start at an arbitrary point
> and be modified by the system clock on the server and a scale value
> ((timebase + timeserver) * timescale = gameworldtime). So if the base
> time starts at the year 1000, the server clock's year is 2011 and the
> time scale is 4 then the game world time should be in the year 12044
> ((1000 + 2011) * 4). The date and time ideally would be treated as a
> single entity so everything is scaled by four proportionally.
>
> How in the world would one do this? It's not really important that the
> client know the actual date, but it does need to know the time. The
> client should be able to add "Timer" to the game world time so it can
> keep an accurate 24-hour time while the player is playing. Basically the
> client would receive the game world time upon authentication, then look
> at "gameworldtime + Timer" to determine what time of day it was until
> the player stopped playing.
>
> I noticed that adding and subtracting to a date or time prints a
> floating point number, but multiplying or dividing complains about
> expected datatypes. Any insight or outright solutions would bring light
> and dark to the world. :

Thank you everyone who responded. I got it working. :) There's a ten 
second discrepancy between the server time and the client time that I've 
been unable to rectify, but the two times stay in perfect sync other 
than that unexpected offset. I'll deal with it later since it's a minor 
issue. Again, thanks for the excellent information.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list