How Alarm Countdown Timing Works (Calculation Method)
Target-timestamp anchoring prevents background tab throttling from slowing down the timer.
Remaining Time Ms = Target End Time Ms - Current Time Ms (Date.now())
Target Time Setup
Convert requested timer minutes to milliseconds and calculate Target End Time = Date.now() + Target Ms.
Interval Countdown Calculation
Every second, compute Remaining Ms = Target End Time - Date.now().
Pause State Handling
If paused, freeze Remaining Ms. When resumed, recalculate Target End Time = Date.now() + Remaining Ms.
Zero Completion Alert
When Remaining Ms ≤ 0, halt timer and trigger completion alerts.