qbcore-framework / qb-weathersync

Weather System Used With QB-Core :sun_behind_rain_cloud:
GNU General Public License v3.0
23 stars 142 forks source link

[RFC] Confusing time calculation #51

Closed CodeRedDev closed 2 years ago

CodeRedDev commented 2 years ago

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?

w4fflz commented 2 years ago

Closing per PR request