Time Estimation Calculation

2

I'm making a calculator for calculating time for any distance on my site, but my question is in the execution algorithm.

The formula is as follows:

tempo previsto = tempo real x distância prevista / distância do tempo real elevada a 1.07 .

Only when I do this calculation on the calculator comes a broken result that I do not know how I turn into an algorithm that returns hours, minutes, and seconds. The source is the following link: link

  • Weather forecast for any distance:
  • asked by anonymous 02.06.2016 / 01:46

    1 answer

    1

    link

    function calcularTempoTotalPrevisto( horas, minutos, segundos, distanciaPrevista, distanciaPercorrida ) {
      var horasTotalOcorrido = horas + ( (minutos * 60 + segundos) / 3600 );
    
      var horasTotalPrevisto = Math.pow( ( distanciaPrevista / distanciaPercorrida ), 1.07 ) * horasTotalOcorrido;
    
      var horasPrevisto = Math.floor( horasTotalPrevisto );
      var segundosPrevisto = ( horasTotalPrevisto - horasPrevisto ) * 3600;
      var minutosPrevisto = Math.floor( segundosPrevisto / 60 );
      segundosPrevisto = Math.round( segundosPrevisto - minutosPrevisto * 60 );
    
      return { "h": horasPrevisto, "m": minutosPrevisto, "s": segundosPrevisto }
    }
    
        
    02.06.2016 / 04:39