DIR Return Create A Forum - Home
---------------------------------------------------------
The world in your hands
HTML https://twiyh.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: General Discussion
*****************************************************
#Post#: 102--------------------------------------------------
PP Time calculator.
DIR By: MysticPing
Date: February 21, 2016, 5:02 am
---------------------------------------------------------
I created a script in javascript where you input PP and it
outputs a date it will be finished. I need people to test if its
accurate.
Instructions:
Create a bookmark with this as the url:
--- Code ---
javascript:(function(){
var pp = parseFloat(prompt("Enter PP", "0"));
var d = new Date();
var month = d.getMonth()+1;
var day = d.getDate();
var mins = d.getMinutes();
var hours = d.getHours();
function numberOfDays(year, month) {
var d = new Date(year, month, 0);
return d.getDate();
}
while (pp >= 24) {
pp -= 24;
day += 1;
}
var decimal = pp % 1;
mins += 60*decimal;
hours += Math.floor(pp);
while (mins >= 60) {
mins-= 60;
hours += 1;
}
while (hours >= 24) {
hours -= 24;
day += 1;
}
while (day > numberOfDays(d.getFullYear(), month)) {
day -= numberOfDays(d.getFullYear(), month);
month += 1;
}
alert(""+hours+":"+mins+"
"+day+"/"+month+"/"+d.getFullYear());
})();
--- End Code ---
Then just click on the bookmark.
Output is your local timezone and 24 hour clock
Hour/Min Day/Month/Year
If you find it returns the wrong value please tell me!
#Post#: 105--------------------------------------------------
Re: PP Time calculator.
DIR By: MysticPing
Date: February 21, 2016, 5:50 am
---------------------------------------------------------
Fixed an issue with string parsing. (TL;DR Now works if PP < 24)
#Post#: 107--------------------------------------------------
Re: PP Time calculator.
DIR By: MysticPing
Date: February 21, 2016, 6:45 am
---------------------------------------------------------
Added the ability to input decimal pp values as well as some
general improvements to the code
*****************************************************
Page 1 of 1