Last active
January 31, 2016 10:28
-
-
Save yurynix/d94556c2acbb24051bb5 to your computer and use it in GitHub Desktop.
tlushim.co.il hours summary
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
var hours = []; | |
totalMinutes = 0, | |
maxMinutes = 0; | |
minMinutes = Number.MAX_VALUE; | |
Array.prototype.forEach.call(document.querySelectorAll('table.atnd > tbody > tr'), function (tr) { | |
// if there is an error td, then don't count that row | |
var errorTd = tr.querySelectorAll('td.atnd_error'); | |
if (errorTd && errorTd.length > 0) { | |
return; | |
} | |
var td = tr.querySelectorAll('td')[4]; | |
var time = td ? td.innerText : null; | |
var minutesInADay = 0; | |
if (time && time.match(/\d+:\d+/)) { | |
hours.push(time); | |
var timeParts = time.split(':'); | |
minutesInADay += parseInt(timeParts[0]) * 60; | |
minutesInADay += parseInt(timeParts[1]); | |
totalMinutes += minutesInADay; | |
maxMinutes = Math.max(maxMinutes, minutesInADay); | |
minMinutes = Math.min(minMinutes, minutesInADay); | |
} | |
}); | |
console.log('Total worked:', totalMinutes / 60, 'Shouldve been working:', hours.length * 9, 'Days:', hours.length, 'Max:', maxMinutes/60, 'Min:', minMinutes/60); | |
console.log('Hours:', hours); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment