Skip to content

Instantly share code, notes, and snippets.

@screeny05
Created November 2, 2017 11:17
Show Gist options
  • Save screeny05/1d4308892df09a8362f435a77ecf74e1 to your computer and use it in GitHub Desktop.
Save screeny05/1d4308892df09a8362f435a77ecf74e1 to your computer and use it in GitHub Desktop.
Papershift overtime calculator (paste in console)
(function getOvertime(){
const padLeftTwo = str => ('' + str).length === 1 ? '0' + str : str;
const now = new Date();
const today = now.getFullYear() + '' + padLeftTwo(now.getMonth() + 1) + '' + padLeftTwo(now.getDate());
const days = {};
$('#time_trackings_list .entry').each((i, el) => {
const dayKey = $(el).find('.day span').text().slice(0,8);
const dayHours = parseFloat($(el).find('.netto_time').text().replace(' h', ''));
// don't count today
if(dayKey === today){ return; }
if(!days[dayKey]){
days[dayKey] = 0;
}
days[dayKey] += dayHours;
});
const hoursShould = Object.keys(days).length * 8;
const hoursAre = Object.values(days).reduce((mem, val) => mem + val);
return hoursAre - hoursShould;
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment