mrchimp / tock

Timer Object/Class. Kickass!
MIT License
237 stars 33 forks source link

Time in seconds is off #43

Open tforward opened 6 years ago

tforward commented 6 years ago

Starting a timer and noticing the time in seconds skips sometimes. Like in a 25 min timer [25:58, 25:57] and 25:59 is missing. Also have had 25:58 missing and 25:59 showing.

Sometime will repeat the same number in general overtime

`function displayTime(timer) { const currentTime = timer.msToTimecode(timer.lap()); // console.log(timer.msToTimecode(timer.lap())); const timeMMSS = currentTime.substring(3, 8); console.log(currentTime); }

function getTimer() { const timer = new Tock({ countdown: true, interval: 1000, callback: displayTime // complete: someCompleteFunction }); return timer; }`

tforward commented 6 years ago

I played around with the example file in Tock and it looks like it does not support 1 second (1000ms) ticks, because of rounding it won't be accurate, and you have to use a smaller tick like 250ms for it to work correctly.

mrchimp commented 6 years ago

Thanks for raising the issue. I'll try to find some time to look into it. It seems strange that it would have problems with 1s ticks as it's all measured in ms... Is it only 1000ms exactly that causes the issue, or times over a certain amount?

tforward commented 6 years ago

I only tested 1000ms as that is what I needed. You can see it happening in the example provided with tock, just change the interval to 1000 and watch the console log you can see it skips 59 for me usually or 58. It looks like a rounding issue as the output number is generally really close to 1000

On Tue, Jun 5, 2018, 05:06 Jake, notifications@github.com wrote:

Thanks for raising the issue. I'll try to find some time to look into it. It seems strange that it would have problems with 1s ticks as it's all measured in ms... Is it only 1000ms exactly that causes the issue, or times over a certain amount?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mrchimp/tock/issues/43#issuecomment-394637119, or mute the thread https://github.com/notifications/unsubscribe-auth/AJc6ECX3U1e75KmR04jPyWnVdvAwj2Jfks5t5kn5gaJpZM4UYUn- .

robatwilliams commented 5 years ago

Looking at the count up example, it skipped 2:08.

Log:

Tick 126987ms
Tick 127988ms
Tick 129003ms
Tick 130006ms