nhsx / antibody-web

Web application for finger prick covid19 antibody Lateral Flow Tests (LFT) and interpreting results
MIT License
28 stars 10 forks source link

Fix timer so it doesn't start with "9:60" #46

Closed mathewsb closed 4 years ago

mathewsb commented 4 years ago

This pulls over the timer fix from AudereNow/audere#666.

Around each minute boundary, the timer has a wonky behavior where it temporarily shows a time like "3:60".

This happens because the current minute is calculated using Math.floor(), while the current second is calculated using Math.round().

I fixed this by first converting to an integer number of seconds. Then the remaining calculations are more straightforward.

I decided to use Math.ceil() here so that the timer has this sequence:

10:00 -> 9:59 -> ... -> 0:02 -> 0:01 -> DONE!

rather than:

9:59 -> 9:58 -> ... -> 0:01 -> 0:00 -> DONE!