|
// Redondear los valores intermedios al entero más cercano (arriba o abajo con Math.round) para ir obteniendo |
|
|
|
function convertSecondsToTimeFormat(seconds, onlyMinSeconds = false) { |
|
// Definir el número de segundos a convertir |
|
const segundos = seconds; |
|
|
|
// Calcular las horas, minutos y segundos |
|
const horas = Math.floor(segundos / 3600); |
|
const minutos = Math.floor((segundos - horas * 3600) / 60); |
|
const segundosRestantes = segundos % 60; |
|
|
|
// Crear la cadena de caracteres con formato "hh:mm:ss" y mostrar el resultado |
|
return onlyMinSeconds |
|
? `${minutos.toString().padStart(2, '0')}:${segundosRestantes |
|
.toString() |
|
.padStart(2, '0')}` |
|
: `${horas.toString().padStart(2, '0')}:${minutos |
|
.toString() |
|
.padStart(2, '0')}:${segundosRestantes.toString().padStart(2, '0')}`; // 09:36:07 |
|
} |
|
|
|
function convertoSecondsFromTime({ hours = 0, min = 0, seconds = 0 }) { |
|
return hours * 3600 + min * 60 + seconds; |
|
} |
|
|
|
console.log('PRIMERA PARTE:'); |
|
const firstPartSplits = [ |
|
221.9545, 221.624, 221.2935, 220.963, 220.6325, 220.302, 219.9715, 219.641, |
|
219.3105, 218.98, |
|
]; |
|
|
|
for (let i = 0; i < firstPartSplits.length; i++) { |
|
console.log(`${i + 1}: ${Math.round(firstPartSplits[i])}`); |
|
console.log( |
|
`${convertSecondsToTimeFormat(Math.round(firstPartSplits[i]), true)} min/km` |
|
); |
|
} |
|
|
|
const secondsFirstTenKms = Math.round( |
|
firstPartSplits.reduce((prev, accc) => prev + accc) |
|
); |
|
console.log( |
|
secondsFirstTenKms, |
|
` segundos primeros ${firstPartSplits.length} kms` |
|
); |
|
|
|
console.log(convertSecondsToTimeFormat(secondsFirstTenKms)); |
|
|
|
console.log('SEGUNDA PARTE:'); |
|
const secondPartSplits = [ |
|
218.6705, 218.361, 218.0515, 217.742, 217.4325, 217.123, 216.8135, 216.504, |
|
216.1945, 215.885, 215.575, |
|
]; |
|
|
|
for (let i = 0; i < secondPartSplits.length; i++) { |
|
console.log(`${i + 11}: ${Math.round(secondPartSplits[i])}`); |
|
console.log( |
|
`${convertSecondsToTimeFormat( |
|
Math.round(secondPartSplits[i]), |
|
true |
|
)} min/km` |
|
); |
|
} |
|
|
|
const secondsSecondPartKms = Math.round( |
|
secondPartSplits.reduce((prev, accc) => prev + accc) |
|
); |
|
console.log( |
|
secondsSecondPartKms, |
|
` segundos siguientes ${secondPartSplits.length} kms` |
|
); |
|
|
|
console.log(convertSecondsToTimeFormat(secondsSecondPartKms)); |
|
|
|
console.log( |
|
'Parcial en el km 21', |
|
convertSecondsToTimeFormat(secondsFirstTenKms + secondsSecondPartKms) |
|
); |
|
|
|
/*const lastStepsTimeSeconds = (4620 - (secondsFirstTenKms + secondsSecondPartKms)); |
|
|
|
console.log(lastStepsTimeSeconds)*/ |
|
|
|
const lastStepsTimeSeconds = 218.98 * 0.0975; |
|
|
|
console.log(`Tiempo final de los 0.0975m restantes: ${lastStepsTimeSeconds}`); |
|
|
|
console.log( |
|
`Tiempo final: `, |
|
convertSecondsToTimeFormat( |
|
Math.round(secondsFirstTenKms + secondsSecondPartKms + lastStepsTimeSeconds) |
|
) |
|
); |