All files timeFormatters.js

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14      3x 6x 6x 6x 6x     3x 65x    
// a time formatter is a function that takes a single argument, being the number
// of milliseconds left, and returns the number to show on the countdown
 
export const timeFormatterDigitalClock = timeLeft => {
  timeLeft = Math.round(timeLeft / 1000)
  const seconds = timeLeft % 60
  const minutes = (timeLeft - seconds) / 60
  return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`
}
 
export const timeFormatterSeconds = timeLeft => {
  return Math.round(timeLeft / 1000)
}