Created
January 6, 2016 13:26
-
-
Save brunoksato/0f74ebda5cb83677a645 to your computer and use it in GitHub Desktop.
HORAS LOLZINHO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
let minutosTotais = 0; | |
let segundosTotais = 0; | |
let horasTotais = 0; | |
let quantidePartidas = 0; | |
$('.date-duration-duration > div').each(function(index, item){ | |
quantidePartidas += 1; | |
let data = item.textContent.split(':'), | |
segundo = 0, | |
minuto = 0, | |
hora = 0; | |
if (data.length === 2) { | |
//minutos | |
minuto = data[0]; | |
segundo = data[1]; | |
} else { | |
//horas | |
hora = data[0]; | |
minuto = data[1]; | |
segundo = data[2]; | |
} | |
horasTotais += parseInt(hora); | |
minutosTotais += parseInt(minuto); | |
segundosTotais += parseInt(segundo); | |
}); | |
//minutos para hora | |
horasTotais += parseInt(Math.floor(minutosTotais / 60)); | |
//segundos para minutos | |
minutosTotais += parseInt(Math.floor(segundosTotais / 60)); | |
//minutos para hora | |
horasTotais += parseInt(Math.floor(minutosTotais / 60)); | |
alert('Horas jogadas:' + horasTotais + ', quantidade de partidas: ' + quantidePartidas); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment