function lunDate(y,m,d){ //求日数
var t=(y-1899.5)/100;
var ms=floor((y-1900)*12.3685);
var rpi=180/PI();
var zone=8; //时区
var f0=ang(ms,t,0,0.75933,2.172e-4,1.55e-7)+0.53058868*ms-8.37e-4*t+zone/24+0.5;
var fc=0.1734-3.93e-4*t;
var j0=693595+29*ms;
var aa0=ang(ms,t,0.08084821133,359.2242/rpi,0.0000333/rpi,0.00000347/rpi);
var ab0=ang(ms,t,7.171366127999999e-2,306.0253/rpi,-0.0107306/rpi,-0.00001236/rpi);
var ac0=ang(ms,t,0.08519585128,21.2964/rpi,0.0016528/rpi,0.00000239/rpi);
var ecli=0;
var lunD=-1; //农历日数
var jerD=erD(y,m,d);////等效标準天数
var jeJD=round(JD(y,m,d,20,0,0,8)*1000)/1000;////儒略日
/////
if(jeJD>=1410952&&jeJD<1947169){ /////-850年到619平朔;
if(jeJD>=1410952&&jeJD<1565456){
var jsf=0.00269249*(y-(-721))
var zk1=floor((jeJD-1457727.915958)/29.5306); /////-722-1-16到428;数据来自
《春秋战国秦汉朔闰表》 var sou0=floor(1457727.915958-jsf+29.530805106*(zk1-1)+0.5);
var sou1=floor(1457727.915958-jsf+29.530805106*zk1+0.5);
var sou2=floor(1457727.915958-jsf+29.530805106*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1565456&&jeJD<1683518){
var zk1=floor((jeJD-1565455.530851)/29.5306); /////前428年-12-26;数据来自
《春秋战国秦汉朔闰表》 var sou0=floor(1565455.530851+29.530805*(zk1-1)+0.5);
var sou1=floor(1565455.530851+29.530805*zk1+0.5);
var sou2=floor(1565455.530851+29.530805*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1683518&&jeJD<1752148){
var zk1=floor((jeJD-1683489.570610)/29.5306); /////前104年-02-22起h=0.00324;数据来自
《寿星万年历》 var sou0=floor(1683489.570910+29.53086158*(zk1-1)+0.5);
var sou1=floor(1683489.570910+29.53086158*zk1+0.5);
var sou2=floor(1683489.570910+29.53086158*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1752148&&jeJD<1807784){
var zk1=floor((jeJD-1752148.041079)/29.5305); /////85年-02-13起h=0.00049数据来自
《寿星万年历》 var sou0=floor(1752148.041079+29.53085097*(zk1-1)+0.5);
var sou1=floor(1752148.041079+29.53085097*zk1+0.5);
var sou2=floor(1752148.041079+29.53085097*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1807784&&jeJD<1883619){
var zk1=floor((jeJD-1807665.420323)/29.5303); /////237年-02-12起h=0.00033数据来自
《寿星万年历》 var sou0=floor(1807665.420323+29.53059851*(zk1-1)+0.5);
var sou1=floor(1807665.420323+29.53059851*zk1+0.5);
var sou2=floor(1807665.420323+29.53059851*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1883619&&jeJD<1907361){
var zk1=floor((jeJD-1883618.114100)/29.5303); /////445年-01-24起h=0.00030数据来自
《寿星万年历》 var sou0=floor(1883618.114100+29.53060000*(zk1-1)+0.5);
var sou1=floor(1883618.114100+29.53060000*zk1+0.5);
var sou2=floor(1883618.114100+29.53060000*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1907361&&jeJD<1936597){
var zk1=floor((jeJD-1907360.704700)/29.5303); /////510年-01-26起h=0.00030;数据来自
《寿星万年历》 var sou0=floor(1907360.704700+29.53060000*(zk1-1)+0.5);
var sou1=floor(1907360.704700+29.53060000*zk1+0.5);
var sou2=floor(1907360.704700+29.53060000*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1936597&&jeJD<1939136){
var zk1=floor((jeJD-1936596.224900)/29.5303); /////590年-02-10起h=0.01010;数据来自
《寿星万年历》 var sou0=floor(1936596.224900+29.53060000*(zk1-1)+0.5);
var sou1=floor(1936596.224900+29.53060000*zk1+0.5);
var sou2=floor(1936596.224900+29.53060000*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
if(jeJD>=1939136&&jeJD<1947169){
var zk1=floor((jeJD-1939135.675300)/29.5303); /////597年-02-10起h=0.00890;数据来自
《寿星万年历》 var sou0=floor(1939135.675300+29.53060000*(zk1-1)+0.5);
var sou1=floor(1939135.675300+29.53060000*zk1+0.5);
var sou2=floor(1939135.675300+29.53060000*(zk1+1)+0.5);
var mlunD=sou2 - sou1;var mlunD0=sou1 - sou0;
var lunD1=jeJD-sou1+1;
}else{
lunD1='';};};};};};};};};};
if(lunD1>mlunD){
lunD1 = 1;
}
if(mlunD0==29&&lunD1<1){
lunD1 = 29;
}
if(mlunD0==30&&lunD1<1){
lunD1 = lunD1+=30;
}
}else{
lunD1='';
for(var k=-1;k<=13;k+=1){ //朔
var aa=aa0+0.507984293*k;
var ab=ab0+6.73377553*k;
var ac=ac0+6.818486628*k;
var f1=f0+1.53058868*k+fc*sin(aa)-0.4068*sin(ab)+0.0021*sin(2*aa)+0.0161*sin(2*ab)+0.0104*sin(2*ac)-0.0074*sin(aa-ab)-0.0051*sin(aa+ab);
var j=j0+28*k+f1; //朔或望的等效标準天数及时刻
var kk=souj(ms+floor(k)+15819); // 从校正数据表取出619年到1900年校正数据。
var lunD0=jerD-(floor(j)+kk); //当前日距朔日的差值,同时对619年到1900年校正。
if(k==floor(k)&&lunD0>=0&&lunD0<=29){
lunD=lunD0+1;
var syd0=floor(j0+28*k+f1);
}
} }
///对现行农历的校正(1901-2050)
///////1924.3.5-4.3 少一天
if(y==1924&&((m==3&&d>=5)||(m==4&&d<=3))){
var v= lunD++;
if(lunD>30){
var v= lunD-=30;
}
}
//2018.11.7-12.6 -- 2057.9.28-10.27 - 2097.8.7-9.5 多一天
if(y==2018&&((m==11&&d>=7)||(m==12&&d<=6))||y==2057&&((m==9&&d>=28)||(m==10&&d<=27))||y==2097&&((m==8&&d>=7)||(m==9&&d<=5))){
var v= lunD--;
if(lunD<1){
var v= lunD+=30;
}
}
var v=lunD; //返回值
if(jeJD>=1410952&&jeJD<1947169){
v=lunD1;
}
return(v)
}
[此贴子已经被作者于2008-12-16 14:36:37编辑过]