Created
November 2, 2017 11:17
-
-
Save screeny05/1d4308892df09a8362f435a77ecf74e1 to your computer and use it in GitHub Desktop.
Papershift overtime calculator (paste in console)
This file contains hidden or 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 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