no edit summary
No edit summary |
No edit summary |
||
| Line 25: | Line 25: | ||
So for example you log into US Ysera EST at 18:00, and enter Ulduar runing on an instance server that is PST. Suddenly the time returned will be 3 hours behind the time you were getting. Confusing but important :) Please keep this in mind if using this time for anything important functionally, such as diffing times or using as part of functional historical data. | So for example you log into US Ysera EST at 18:00, and enter Ulduar runing on an instance server that is PST. Suddenly the time returned will be 3 hours behind the time you were getting. Confusing but important :) Please keep this in mind if using this time for anything important functionally, such as diffing times or using as part of functional historical data. | ||
For getting consistant times you have two basic choices use server or use local client time. Server time is good because all players in a realm will have the same time within more or less a mintue accuracy. Client time is good because you have second precision, but everyones times are different, as not only do people log into realm servers from other timezones, but you also have no idea how correct their local time is, from unset clocks to bad user | For getting consistant times you have two basic choices use server or use local client time. Server time is good because all players in a realm will have the same time within more or less a mintue accuracy. Client time is good because you have second precision, but everyones times are different, as not only do people log into realm servers from other timezones, but you also have no idea how correct their local time is, from unset clocks to bad user timezone, and lots of variance. The "instance server not same time as login server" problem suddenly makes the server time much less valuable for consistancy. Two reasons: even if the server is in the same timezone as the login server, you might have variance between the two server like 5-10 mintues, though not typicaly the case. Using local time for most apps where a univeral time isnt important is the way to go. | ||
A third choice for consistant times is to mix the two and run a timer correction update event in the background, where you get a base time difference between local and server time as to correct local time to server time, and base seconds (plus diff) purely off of local time. So: seed base -> use local time + base as time value in addon (server time with second precision) -> continue every fraction of second or so to see if server time has rolled over to next minute -> reconcile and update base -> and on and on... The update event basically corrects the base difference over time to keep it acruate with server time. The base correction update is necessary because users computers can drift dramatically depending on the computer, and because users can choose to change their timezone or clock at any time. Also doing time diffs and adds is not as simple as it sounds; its a bit contrived to get it right. What you end up with however is as near second accruacy universal server time across all clients. This depends on how accurate minute rollovers form server time are and using the cients seconds counter should not drift any perceptable amount inside a mintute. I'm guessing the wow client itself is basing the server time minute rollovers on local client time as well, just not shared with us through this function, and i dont know how often or what triggers actual server time updates to the client. But in practice ive observed this working very very well. However... with the newer problem (the original reason for the note) you will need to basically shut off the base correction when a player enters an instance and save the difference value to your saved vars, in case the player restarts or logs into an instance instead of the realm world server. This leaves the problem of a user installing the addon and loging on to an instance server first rather than the realm world server (and people who raid know that can really happen a lot, ala "oh let me go enable or install that addon i need, brb"). In this case you will need to seed the base with the difference of the instance server just once and then follow the rule of shutting it off in an instance, where it will natuarally be corrected within a minute or so of entering realm world server. | A third choice for consistant times is to mix the two and run a timer correction update event in the background, where you get a base time difference between local and server time as to correct local time to server time, and base seconds (plus diff) purely off of local time. So: seed base -> use local time + base as time value in addon (server time with second precision) -> continue every fraction of second or so to see if server time has rolled over to next minute -> reconcile and update base -> and on and on... The update event basically corrects the base difference over time to keep it acruate with server time. The base correction update is necessary because users computers can drift dramatically depending on the computer, and because users can choose to change their timezone or clock at any time. Also doing time diffs and adds is not as simple as it sounds; its a bit contrived to get it right. What you end up with however is as near second accruacy universal server time across all clients. This depends on how accurate minute rollovers form server time are and using the cients seconds counter should not drift any perceptable amount inside a mintute. I'm guessing the wow client itself is basing the server time minute rollovers on local client time as well, just not shared with us through this function, and i dont know how often or what triggers actual server time updates to the client. But in practice ive observed this working very very well. However... with the newer problem (the original reason for the note) you will need to basically shut off the base correction when a player enters an instance and save the difference value to your saved vars, in case the player restarts or logs into an instance instead of the realm world server. This leaves the problem of a user installing the addon and loging on to an instance server first rather than the realm world server (and people who raid know that can really happen a lot, ala "oh let me go enable or install that addon i need, brb"). In this case you will need to seed the base with the difference of the instance server just once and then follow the rule of shutting it off in an instance, where it will natuarally be corrected within a minute or so of entering realm world server. | ||