Created
April 11, 2016 16:47
-
-
Save gibatronic/9ac111862631fe3fb42b968a73ae5226 to your computer and use it in GitHub Desktop.
Stupid tool to calculate what time I should leave given the time I arrived at work to complete 8.5h with 1h of lunch.
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
#!/usr/bin/env node --harmony | |
const output = function(...data) { | |
process.stdout.write(data.join('')); | |
}; | |
const main = function(hour, minute) { | |
hour = +hour; | |
minute = (minute / 60) || 0; | |
if (!hour) { | |
throw new Error('No time was given.'); | |
} | |
hours = hour + minute + 9.5; | |
hour = hours >> 0; | |
minute = hours * 60 % 60; | |
if (hour < 10) { | |
output(0); | |
} | |
output(hour, ' '); | |
if (minute < 10) { | |
output(0); | |
} | |
output(minute, '\n'); | |
}; | |
main.apply(undefined, process.argv.slice(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment