Last active
April 21, 2017 16:47
-
-
Save charlesmims/c791fa6c7c2fddf81298d8657ee5a6bd to your computer and use it in GitHub Desktop.
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
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