日期:2009-09-06  浏览次数:21078 次

<HTML>
<HEAD>
</HEAD>
<BODY bgColor=#000000 onload=fly()>



<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function run() {
with (document.agecalc) {
dd = parseInt(day.selectedIndex) + 1;
mm = parseInt(month.selectedIndex) + 1;
yy = year.value;
if (yy.length != 4 || isNaN(yy)) {
document.agecalc.timealive.value = "年份数请输入四位.";
document.agecalc.year.select();
document.agecalc.year.focus();
return;
   }
}
days = new Date();
gdate = days.getDate();
gmonth = days.getMonth();
gyear = days.getYear();
if (gyear < 2000) gyear += 1900;
age = gyear - yy;
if ((mm == (gmonth + 1)) && (dd <= parseInt(gdate))) {
age = age;
} else {
if (mm <= (gmonth)) {
age = age;
} else {
age = age - 1;
   }
}
if (age == 0)
age = age;
document.agecalc.timealive.value = "你已经" + age+ " 了 . . .\n\n";
if (mm <= (gmonth + 1))
age = age - 1;
if ((mm == (gmonth + 1)) && (dd > parseInt(gdate)))
age = age + 1;
var m;
var n;
if (mm == 12) n = 31 - dd;
if (mm == 11) n = 61 - dd;
if (mm == 10) n = 92 - dd;
if (mm == 9) n = 122 - dd;
if (mm == 8) n = 153 - dd;
if (mm == 7) n = 184 - dd;
if (mm == 6) n = 214 - dd;
if (mm == 5) n = 245 - dd;
if (mm == 4) n = 275 - dd;
if (mm == 3) n = 306 - dd;
if (mm == 2) { n = 334 - dd; if (leapyear(yy)) n++; }
if (mm == 1) { n = 365 - dd; if (leapyear(yy)) n++; }
if (gmonth == 1) m = 31;
if (gmonth == 2) {
m = 59;
if (leapyear(gyear)) m++;
}
if (gmonth == 3)  { m = 90;  if (leapyear(gyear)) m++; }
if (gmonth == 4)  { m = 120; if (leapyear(gyear)) m++; }
if (gmonth == 5)  { m = 151; if (leapyear(gyear)) m++; }
if (gmonth == 6)  { m = 181; if (leapyear(gyear)) m++; }
if (gmonth == 7)  { m = 212; if (leapyear(gyear)) m++; }
if (gmonth == 8)  { m = 243; if (leapyear(gyear)) m++; }
if (gmonth == 9)  { m = 273; if (leapyear(gyear)) m++; }
if (gmonth == 10) { m = 304; if (leapyear(gyear)) m++; }
if (gmonth == 11) { m = 334; if (leapyear(gyear)) m++; }
if (gmonth == 12) { m = 365; if (leapyear(gyear)) m++; }
months = age * 12;
months += 12 - parseInt(mm);
months += gmonth;
totdays = (parseInt(age) * 365);
totdays += age / 4;
totdays = parseInt(totdays) + gdate + m + n;
if (gmonth == 1) p = 31 + gdate;
if (gmonth == 2) {
p = 59 + gdate;
if (leapyear(gyear)) m = m+1;
}
if (gmonth == 3)  { p = 90 + gdate;  if (leapyear(gyear)) p++; }
if (gmonth == 4)  { p = 120 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 5)  { p = 151 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 6)  { p = 181 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 7)  { p = 212 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 8)  { p = 243 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 9)  { p = 273 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 10) { p = 304 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 11) { p = 334 + gdate; if (leapyear(gyear)) p++; }
if (gmonth == 12) { p = 365 + gdate; if (leapyear(gyear)) p++; }
weeks = (age * 365) + n + p;
weeks = weeks / 7;
etcdays = parseFloat(weeks) - parseInt(weeks);
etcdays = Math.round(etcdays * 7);
weeks = parseInt(weeks);
etcdays += parseInt(age / 4);
if (etcdays > 7)
weeks += parseInt(etcdays / 7);
document.agecalc.timealive.value += "     或者 " + weeks + " 个星期\n";
document.agecalc.timealive.value += "     或者 " + months + " 个月\n";
document.agecalc.timealive.value += "