As I want to set the game time depending on the current real time I was looking through the time code in here (that is probably also inspired by vSync).
I found some weird time calculations as the following (I'm assuming baseTime is in seconds):
local newBaseTime = os.time(os.date("!*t"))/2 + 360
OR
hour = math.floor(((baseTime+timeOffset)/60)%24)
The first (under my assumption) does not make any sence as dividing the time by 2 will make every time that was calculated based on newBaseTime inaccurate (hours won't match at all). Also I can't think of a good idea why you have to add 360.
For the second line of code it is just simply wrong. As you would have to calculate the hours by dividing the time by 3600 and then modulo 24 (based on the assumption of time in seconds).
TLDR
Time calculations seem wrong. Am I right? Should I rewrite this whole thing to make useful time calculation?
As I want to set the game time depending on the current real time I was looking through the time code in here (that is probably also inspired by vSync).
I found some weird time calculations as the following (I'm assuming
baseTime
is in seconds):OR
The first (under my assumption) does not make any sence as dividing the time by 2 will make every time that was calculated based on
newBaseTime
inaccurate (hours won't match at all). Also I can't think of a good idea why you have to add 360.For the second line of code it is just simply wrong. As you would have to calculate the hours by dividing the time by 3600 and then modulo 24 (based on the assumption of time in seconds).
TLDR
Time calculations seem wrong. Am I right? Should I rewrite this whole thing to make useful time calculation?