NodeGuy / server-date

Make the server's clock available in the browser.
http://www.nodeguy.com/serverdate/
Mozilla Public License 2.0
193 stars 53 forks source link

Expose decisecond or better precision #17

Closed curby closed 9 years ago

curby commented 9 years ago

Update interval and display precision should be selectable. E.g. update every decisecond, with decisecond or centisecond precision. Update every centisecond, with centisecond or millisecond precision. I understand that the accuracy may not be sufficient in all cases, and that higher update frequency will tax client resources, but this should at least be an option since ServerDate can generally produce better-than-second accuracy.

This may already be possible with the current code, but it is not exposed in example.html.

curby commented 9 years ago

This modification of example.html displays centiseconds with default ServerDate javascript/php. CPU activity does jump up, but it seems to keep up pretty well.

http://ntp2.curby.net/example-centiseconds.html

Gist in case the above link stops working:

https://gist.github.com/curby/c26452d82aeef7dac36d

By the way, my intention is not that this should replace the default example.html. It's merely another example that can be used as a starting point for others with interest in higher precision.

(Also, I understand that a 100Hz refresh rate is partially wasted when so many monitors use 60Hz refresh.)

NodeGuy commented 9 years ago

Synchronization frequency is already selectable via ServerDate.synchronizationIntervalDelay.

The example is designed to be simple and modifiable as desired by the end user, not to satisfy all use cases.