javaScript формат час

function timeConversion(s) {
  const formatter = s.replace(/[a-z]/gi, '').split(':')
  let firstIndex = +formatter[0]
  let time = 12
  let time1 = ""
  let time2 = ""
 
  for(let i = 0; i < formatter.length; i++) {
      
       if(i == 0 && firstIndex < 12) {
         time += +formatter[0]
         time1 += String(time)
       }
    
       if(i == 0 && firstIndex > 11) {
         time -= +formatter[0]
         time1 += String(Math.abs(time)).repeat(2)
       }
      
       if(i !== 0) {
         time2 += " " + formatter[i]
       }
  }

 return time1.concat(time2).replace(/[\s]/g, ':')
}
Restu Wahyu Saputra