Skip to content

Instantly share code, notes, and snippets.

@yurynix
Last active January 31, 2016 10:28
Show Gist options
  • Save yurynix/d94556c2acbb24051bb5 to your computer and use it in GitHub Desktop.
Save yurynix/d94556c2acbb24051bb5 to your computer and use it in GitHub Desktop.
tlushim.co.il hours summary
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