中國老黃歷在線查詢
";
m=form.m.value;
d=form.d.value;
h=form.h.value;
if (m==""||d==""){
document.write(s1,s2,"
","進一步查詢,請輸入月和日。
",s3,s4);
document.close();
}
else if (m>12||m<1)
alert("月應在1與12之間。"+re);
else if (d>31||d<1)
alert("日應在1與31之間。"+re);
else if ((m==4||m==6||m==9||m==11)&&d>30)
alert(m+"月只有30天。"+re);
else if (y%4!=0&&m==2&&d>28)
alert(y+"年是平年,2月只有28天。"+re);
else if (m==2&&d>29)
alert(y+"年是閏年,2月只有29天。"+re);
else if (h>23||h<0)
alert("時應在0與23之間。"+re);
else{
if (form.h.value=="") h=0;
sum=(Date.UTC(y,m-1,d,h)-Date.UTC(1901,1,18,23))/1000;
sumd=Math.floor(sum/86400);
day=(Math.floor((sum-1800)/86400)+51)%7;
xq=(day==0)?"日":sz[day-1];
tgr=(sumd+54)%10;
dzr=(sumd+52)%12;
gzr=tg[tgr]+dz[dzr];
dzs=Math.floor((h*1+1)/2)%12;
tgs=((tgr%5)*2+dzs)%10;
gzs=tg[tgs]+dz[dzs];
for (i=0;ms[i][120]<=sumd;i++);
k=(i==0)?0:ms[i-1][120];
p=i*120;
for (j=0;j<120;j++){
k+=ly[ms[i][j]];
p++;
if (k>sumd) break;
}
if (sumd+30<0){
ri=59+sumd;
p=-1;
}
else if (sumd<0){
ri=30+sumd;
p=0;
}
else
ri=sumd+ly[ms[i][j]]-k;
yue=((p+11)%12==0)?"正":sz[(p+11)%12];
mij=ms[i][j];
if ((mij==2||mij==3)&&ri>28){
ri-=29;
yue="閏"+yue;
}
else if ((mij==4||mij==5)&&ri>29){
ri-=30;
yue="閏"+yue;
}
ri=((ri<10)?"初":"")+sz[ri];
tgn=Math.floor((p-1)/12+7)%10;
dzn=Math.floor((p-1)/12+1)%12;
gzn=tg[tgn]+dz[dzn];
tgy=(p+5)%10;
dzy=(p+1)%12;
gzy=tg[tgy]+dz[dzy];
tn=tw[tgn];
dn=dw[dzn];
ty=tw[tgy];
dy=dw[dzy];
tr=tw[tgr];
dr=dw[dzr];
ts=tw[tgs];
ds=dw[dzs];
s5=m+"月"+d+"日(星期"+xq+")";
s6="
農歷:"+gzn+"年"+yue+"月"+ri+"日";
s7="生肖:"+sx[dzn]+"
"
if (form.h.value=="")
document.write(s1,s5,s6,s2,"干支:",gzn,"年",gzy,"月",gzr,"日
",s7,s3,s4);
else
document.write(s1,s5,h,"點",s6,dz[dzs],"時",s2,
"八字:",gzn," ",gzy," ",gzr," ",gzs,"
",
"五行:",w[tn],w[dn]," ",w[ty],w[dy]," ",w[tr],w[dr]," ",w[ts],w[ds],"
",
"方位:",f[tn],f[dn]," ",f[ty],f[dy]," ",f[tr],f[dr]," ",f[ts],f[ds],"
",s7,s4);
document.close();
}
}
}
function setfocus(){
document.cal.y.focus();
return;
}
//-->
年必須輸入,限于1901年和2050年之間。只輸入年,輸出結果有該年春節日期及春節前后的年干支;輸入年、月、日,則輸出結果還有該日星期、農歷年月日、年月日的干支、生肖;輸入年、月、日、時,則輸出結果還有生辰八字及八字所對應的五行、方位。
年、月、日需準確輸入,而時只要在同一個時辰范圍里則不影響查詢結果。23點至1點前是子時,1點
至3點前是丑時,……21點至23點前是亥時。
最后說明一點,計算時辰以23點為一天的開端,這樣干支系統才能自洽,因此本皇歷查詢生辰八字按此規則。除了計算時辰,還是應把
0點作為一天的開端。也就是說,23點以后出生的人,生日算當日,時辰算下一日子時,八字按下一日算。
|
|