delsols
04-08-2005, 08:14 AM
I've been using the script found here:
http://javascript.internet.com/page-details/page-up-for.html
But, since the Daylight Saving Time changeover, This:
The JavaScript Source has been up for 7 years, 9 months, and 22 days.
Has changed to this:
The JavaScript Source has been up for 7 years, 9 months, and 22.958333333333332 days.
Any Advice on a fix?
scragar
04-08-2005, 09:19 AM
always Math.round(date) it of.
function HowLongSince(startmonth, startdate, startyear) {
sdate=startdate;
smonth=startmonth-1;
syear=startyear;
var DaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
today = new Date()
var thisyear = today.getFullYear();
var thismonth = today.getMonth();
var thisdate = today.getDate();
mstart = new Date(syear,(smonth==12?1:smonth+1),1);
days1 = (mstart - new Date(syear,smonth,sdate))/(24*60*60*1000)-1;
mend = new Date(thisyear,thismonth,1);
days2 = (new Date(thisyear,thismonth,thisdate) - mend)/(24*60*60*1000)+1;
dayst = days1 + days2;
if (dayst >= DaysInMonth[smonth]) {
AddOneMonth = 1;
dayst -= DaysInMonth[smonth];
}
else AddOneMonth = 0;
ydiff1 = thisyear-mstart.getFullYear();
mdiff1 = thismonth-mstart.getMonth()+AddOneMonth;
if (mdiff1 >11) { mdiff1=0; ydiff1++; }
if (mdiff1 < 0) { mdiff1 = mdiff1 + 12; ydiff1--; }
temp = (ydiff1==0?"":(ydiff1==1?ydiff1+" year and ":ydiff1 + " years, "));
temp += (mdiff1==0?"0 months, and ":(mdiff1==1?mdiff1+" month, and ":mdiff1+" months, and "));
temp += (dayst==0?"no days":(dayst==1 ? " 1 day." : Math.round(dayst) + " days." ));
return temp;
}
delsols
04-08-2005, 10:26 AM
Much Ablige, Mr. Scragar
Following your suggestion, in the last line of script i replaced:
(dayst==1 ? " 1 day." : dayst + " days" )
with:
Math.round(dayst)
Works fine now :)