Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopwatch, Timer time more accurately #40

Open
kitsuyui opened this issue May 15, 2023 · 0 comments
Open

Stopwatch, Timer time more accurately #40

kitsuyui opened this issue May 15, 2023 · 0 comments

Comments

@kitsuyui
Copy link
Owner

In the current implementation of this repository, useInterval of react-use is used, and the time is managed by adding or subtracting the number of seconds at regular intervals. There is a problem with this method.
There is a time difference between the actual time and the time managed by adding or subtracting the number of seconds. Depending on the processing system, there may be a time difference of several seconds per minute.

Solution

Get the current time with Date and calculate the difference to more accurately manage the time.

Another problem

Date is affected by the time managed by the browser or OS. The following problems may occur

  1. The user changed the time of the OS
  2. A leap second is inserted

More solution

Both 1 and 2 can be solved by measuring International Atomic Time (TAI), but there is no way to get this value in JavaScript on the browser.
As a method to get a value close to this, there is GeolocationPosition.timestamp. On the other hand, it requires the user's location information. There is no need to do this much at this point.

kitsuyui added a commit that referenced this issue May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant