const prependZero = (value: number | string) => (
  `0${value}`.slice(-2)
)

/**
 * Форматирует секунды в hh:mm:ss
 */
export const secondsToHms = (seconds: number) => {
  const hours = prependZero(Math.floor(seconds / 3600))
  const minutes = prependZero(Math.floor(seconds % 3600 / 60))
  const secondsStr = prependZero(Math.floor(seconds % 3600 % 60))

  if (Number(hours) > 0) return `${hours}:${minutes}:${secondsStr}`

  return `${minutes}:${secondsStr}`
}
