Re: Timer on webpages



RobG said the following on 4/29/2006 10:54 PM:
Randy Webb wrote:
Dr John Stockton said the following on 4/29/2006 5:25 PM:
JRS: In article <mM2dnd6tB8szLM7ZnZ2dnUVZ_vidnZ2d@xxxxxxxxxxx>, dated
Sat, 29 Apr 2006 14:34:28 remote, seen in news:comp.lang.javascript,
Randy Webb <HikksNotAtHome@xxxxxxx> posted :
In the callback you update the counter, animation, etc., and increment a variable that counts how many seconds have elapsed.
I don't agree with that one. Incrementing a variable would lead to inaccuracies in the total. Just start with a Date object and compare the current time, get the difference, and display it.

Using a Date Object to indicate duration will be unreliable in systems
where the clock is being automatically synchronised from time to time.

If your app is that time critical, then you would know whether that was happening or not and if you didn't allow for it then you get what you deserve.

Absolutely, so worth mentioning.


Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.

And naively assuming that most business applications are being used on a Saturday night at 2AM is indeed naive.

That is not naive at all - many businesses that have a production process have shift work. I've frequently been involved in projects with 24hr shifts, 7 days per week over many months. That is common on projects such as those that use very expensive CAD equipment, say a major construction project.

True, but that falls into the first category. That is a time critical application and if you don't take care to account for it then you, well, deserve what you get :)

But, your point is valid.

But, most sites that have a count-down/up timer are not business apps. Some are, but most aren't. Probably a quiz type site that the OP has.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
.