Skip to content

Instantly share code, notes, and snippets.

@charlesmims
Last active April 21, 2017 16:47
Show Gist options
  • Save charlesmims/c791fa6c7c2fddf81298d8657ee5a6bd to your computer and use it in GitHub Desktop.
Save charlesmims/c791fa6c7c2fddf81298d8657ee5a6bd to your computer and use it in GitHub Desktop.
function daysInMonth(month, year){
return new Date(year, month, 0).getDate();
}
function estimate(current){
d = new Date();
n = d.getDate();
h = d.getHours();
y = d.getFullYear();
m = d.getMonth() + 1;
dim = daysInMonth(m,y);
return current * (dim*24) / ((n * 24) + h);
}
process.argv.forEach(function(val, index, array){
if (index > 1) {
console.log("current: "+ val + "\testimate: " + estimate(val).toFixed(2))
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment