I've built a clock app that:
1. Get the user's local time. aka "Your Time"
2. Pings a server hosting a cgi script that returns a GMT date string. aka "GMT"
3. Calculates the difference between Your Time and GMT in milliseconds.
4. Uses that calculated difference to dynamically generate dspGMT which is then used to keep the display updated.
I've got a few people on our company intranet, around the world, testing it out. For 90% everything is great. But, for a few of them, "Your Time" and "dspGMT" fall out of sync.
Is this possibly a CPU speed issue? What else cold be causing this?
Here's a sample of the code that generates the display...
1. Get the user's local time. aka "Your Time"
2. Pings a server hosting a cgi script that returns a GMT date string. aka "GMT"
3. Calculates the difference between Your Time and GMT in milliseconds.
4. Uses that calculated difference to dynamically generate dspGMT which is then used to keep the display updated.
I've got a few people on our company intranet, around the world, testing it out. For 90% everything is great. But, for a few of them, "Your Time" and "dspGMT" fall out of sync.
Is this possibly a CPU speed issue? What else cold be causing this?
Here's a sample of the code that generates the display...
Code:
this.onEnterFrame = function():Void {
yourDate = new Date();
// pull out the various date parts
// :
yourMilliSecs = Number(yourDate.getMilliseconds()) ;
// _global.diffTimeCalc calculated in another function.
// Now calc calcGmtMilliSecs
calcGmtMilliSecs = Math.floor(yourMilliSecs + diffTimeCalc);
// Now calculate GMT using calcGmtMilliSecs.
gmDateCalc = new Date(yourYear, yourMonth, yourDayNum, yourHours, yourMins, yourSecs, calcGmtMilliSecs);
// Extract the parts you need for the clock display
dspGmtTimeHour = Number(String(gmDateCalc).substring(11,13));
dspGmtTimeMin = Number(String(gmDateCalc).substring(14,16));
dspGmtTimeMonth =String(gmDateCalc).substring(4,7) ;
dspGmtTimeDayName = String(gmDateCalc).substring(0,3);
dspGmtTimeDay = Number(String(gmDateCalc).substring(8,10));
dspGmtTimeYear = Number(String(gmDateCalc).substring(29,33));
// Populate the appropriate display boxes
localTimeBox.htmltext = yourHours + ":" + yourMins + ":" + yourSecs ;
gmtTimeBox.htmltext = dspGmtTimeHour+ ":" + dspGmtTimeMin + ":" +yourSecs ;
/* There's a LOT more to it than just this, like calculating daylight savings time, start, end, if at all, etc. But you get the idea. */
}