Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created April 11, 2016 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gibatronic/9ac111862631fe3fb42b968a73ae5226 to your computer and use it in GitHub Desktop.
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.
#!/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