中华农历论坛知识讨论区历法知识 → [原创]电脑医生万年历和福星万年历最新历算源码


  共有47818人关注过本帖树形打印

主题:[原创]电脑医生万年历和福星万年历最新历算源码

帅哥哟,离线,有人找我吗?
chwc
  31楼 个性首页 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:603 积分:5315 威望:0 精华:4 注册:2008/4/21 19:06:00
  发帖心情 Post By:2011/2/28 19:48:00

function leapNum(y){  ///總閏月數
    return leapNumber[y+1187];
}
var starY=-1187;  //記錄從-1187前850(-849)到公元2302年開始050000c00900909(050700600000909)040700600400909--------------------------                                                                                                                                                                                                                  
var leapM='7004007090050020b007004002090060030b00800400b090060020a008005007090060030b007004007090050020b007004002090060030b00800400b090060020a008005007090070030c0080050010a0070030c0080050020a0070030c0080050040a0070030c0080050020a0070030c0080050010a0070030c0080050020a0070030c0080050040a0070030c0080050020a0070030c0080050010a0070030c0080050020a0070030c0080050010a0070030c0080050010a0070030c0080050020a0070030c0080050020a0070030c0090050020a0070030c0090050020a0060030c0060030c00900600c0c0060c00c00c00c0c000600c0c0006090303030006000c00c060c0006c00000c0c0c0060003030006c00009009c0090c00c009000300030906030030c0c00060c00090c0060600c0030060c00c003006009060030c0060060c0090900c00090c0090c00c006030006060003030c0c00030c0060030c0090060030c0090300c0080050020a0060030c0080050020b0070030c0090050010a0070030b0090060020a0070040c0080050020a0060030c0080050020b0070030c0090050010a0070030b0090060020a0070040c0080050020a0060030c0080050020b0070030c0090050000c00c0c00c00c00c0c00c00c00c0c00c00c0c00c00c00c0c00c00c0c00c00c00c0c00c00c0c00c00c00c0c00c00c0c00c00c0c00c00c00c0c00c00c0c00c00c00c0c00c00c0c00c00c00c0c00c00c0c0060030c0090050010a0070030b008005001090070040c0080050020a0060030c0080040010a0060030c0090050010a0070030b0080050010a008005001090050020a0060030c0080040010a0060030c0090050010a0070030b0080050010a0070030b008005001090070040c0080050020a0060030c0080040010a0060030c0090050010a0070030b008005001090070040c0080050020a0060030c0080040010a0060030c0090050010b0060030c0090050010a0070030b008005001090070040c0080050020a0060030c0080040010a0070030b0080050010a0070040c0080050020a0060030c0080040010a0070030c0090050010a0070030b0080050020a0060030c0080040010a0060030c0090050050020a0060030c0090050010b0070030c0090050010a0070040c0080040020a0060030c0080050020a0060030c0090050010a0070030b0080040020a0060040c0090050020b0070030c00a0050010a0070030b0090050020a0070030c0080040020a0060030c0090050010a0070030c0090050030b007005001090070040c009004001090060020c0070050c0090060030b0080040020a0060030b0080040010a0060030b0080050010a0050040c0080050010a0060030c0080050010a0070030c007005001090070030b0070040020a0060030c0080040020a0070030b0090050010a0060040c0080050020a0060040c0080050010b0070030c007005001090070030c0080050020a0070030c0090050020a0070030c0090050020a0060040c0090050020a0060040c0090050010b0070030c0080050030b007004001090060020c008004002090060020a008004001090050030b0080040020a0060040b0080040c00a0060020b007005001090060030b0070050020a0060020c008004002090070030c008005002090070040c0080040020a0060040b0090050010a0060030b0080050020a0060040c0080050010b00700300108005001090070030c0080050020a007003001090050030a0070030b0090050020a0060040c0090050030b0070040c0090050010c0070040c0080060020b007004001090060020b007003002090060020a008004001090050030b007004001090050040c0080040c00a0060020c007005001090060030b0070050020a0060020c008004002090060030b008004002090060030b0080040020a0060040b0080040010b006004002060050030700600400207005003080060040030700500307006004003070050030800600400307005004090060040030700500409006005002070050030a0060050030700500400206004002060050030020600400307005004090060040030700500408007005003080050040a00600500307005004002060050030800500400206005002070050040020600500307006004002070050030800600400307005004080060040a006005003080050040020700500409006004002060050030b0060050020700500308006004003070050040800600400307005004080060040020700500409006004003070050040b006005002070050040b006005003070060040a006005003070060040020600500307006004090060040030700500409007005003080050040b006005003070060050010700500308006004002060050030700600400200000000000';//-1187-2230(2)//
//[注:2186閏2有的是2185閏8,2242閏11有的閏9]
function leapMon(y){
  var v=leapM.charAt(y-starY);
  if(v=='a')
    v=10;
  if(v=='b')
    v=11;
  if(v=='c')
    v=12;
  if(v=='')
    v=0;
  return parseInt(v);
 }

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
chwc
  32楼 个性首页 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:603 积分:5315 威望:0 精华:4 注册:2008/4/21 19:06:00
  发帖心情 Post By:2011/2/28 19:49:00

 var starYd=2302;///從2302年到7800年的閏月
  var leapNNm0='6005003070060040a0070050030800600400307005004080060050010700500408006005002070050040a0060040020600500308006005002070050030800600400307005004080070050030800500408006005003070050040a006005003070050040a0060050020700500400106005003070060040010700500307006004080070050040700600409006004003070050040a007005003080060040b006005003080060050010700500308006004002070050030700600400307005003070060040030700500308';
  var leapNNm1='00600400307005004090060050b00700500409006005002070060040800600500307006003080060050030700600308006004003070060040900700500308005004090060050030800600509007005003070060040a006005003070060040a006005003070060040b00700500308006004090070050040800600408007005004080060040a007005003080060040a006005003080060050020700500308006004002070060040800700500307005004080060040b007005004080060040a00700500409006005002';
  var leapNNm2='0700600409006005002070060040800700500307006004080070050030700600408006004003070060040900700500308006004090060050040800600509007005003080060040b006005003070060040a006005003070060040020700500308006004090070050040800600509007005004080060050b0070050030800600500c0700500409006005002070060030800600400207006004080070050a0080050040800600500308005004080070050a0070050040900600500c070060040a006005002070060040';
  var leapNNm3='8007005003080060040900700500308006004080070050040800600409007005003080060040a006005004080060050a007006003080060040b007006003080060050a0070050030800600409007005003080060040a0070050040800600509008006004090060050b007006004080060050b0070060040900600500307006003080070040030700600408007005003080060040900700500c08006005090070050b00800600409006005003080060040a0070050020700600409007006003080060040900700500';
  var leapNNm4='308006005080070050040800600509007005003080060040a007005004080060050a0070060030800600500c07006004080070050b0070060040800700409007006004080070050a007005004090060050a008006004090060050a007006004080070050010700600409007005003070060040800700500307006004090070050b008006004090070050a008006005090070060b00800600509007006003080060050a00700500308006004090070060030800700409007005004080060050900800600408006005';
  var leapNNm5='09007005004080060050b007006004090060050b007006003080070050a007006004080070050b0080060040800700509008006004080070050b008006004090060050a008006004090070050a007006004090070060020800600409007005003080060040800700500408006004090070050b008006004090070050a0080060050a0070060020800600509007006003080070050b0070060030800600409007006003080070050a00800500408006005090080060040900700509007006004090060050b0070060';
  var leapNNm6='04090060050b007006003080070050a0080060040900700500c080060040900700509008006005090070050b008006005090070050b0080060050a0070060010800600409007006002080070040900700500208006005090070050040800700509007005004080060050a008006001090060050a00700600c080070050a007006002080070050b0070060040800700509007006004080070050a008006004090070050a008006004090070050a0080060040900700600c08006004090070050b0070060040800700';
  var leapNNm7='50b0080060040900700500c08006004090080060a008006005090070060b008006005090070060b0080060050a0070060b0080070040900700600308007004090080060030800700509008006004080070050900800500c080060050a0080060b0090070050b007006003080070060a0080060030900700500c080060040800700509008006004080070050a008006004090070050a008006005090070060a0080060050900700600c080070040900700500c08006004090070060b0080070040900700500c08006';
  var leapNNm8='005090080060a0090070050a00700600c080060050900700600c090060050a007006003080070050a008006003080070050a00800600309007005090080060040900700509008006004090070050a008006004090070050b008006004080070060b0080070030900700500c08006004090080050a008006005090070050a008006005090070050b0080060050a0070060b0080070050a00700600c080070040900800600c08007005090080060b00800700409008006001090060050a0080060b0090070050a0080';
  var leapNNm9='0600c090070060a00800600c090070050a007006002080070050a008006004090070050a008006004090070050a008006004090070060a008006005090070060a008006002090070060b008007004090070060b0080070030900800500108006004090080060a009007005090080060a008006005090070060b0090070050a0070060b0080070050a008006001090070050a00800600308007005090080060040800700509008006001090070050a0080060b0090070050a008006001090070060a0080070020900';
  var leapNNm10='70050a008006002080070050a008007004090070050a008006004090080060a0090070050a0070060a008007005090070060b0090070040a00700600c08007004090080060b0080070040900800600109007005090080060a009007005090080060b0090060050a0080060b0090070050a00800600c080070050a008007001090070050a008006003090070050a008006004090070050a008006001090070050a0080060b0090070060b008007001090080060b008007003090080050b008007004090080060a008';
  var leapNNm11='007004090080050a0090060040a0080060b0090070050a0080060a0080070050a0080060b0090070040a00700600c080070050900800600c090070040a008006001090070050a0080060b0090070060a0080060b0090070060a00800600c090070050b00800700c090070060b008007002090080050a009006003090080060a009007004090080060a008006001090070060b00900700c0a0070060b008007001090080060b0090070010a0080060b008007005090080060b008007005090080060b0090070050a0';
  var leapNNm12='080060b0090070050a0080060b0090070060a0080070b0090070050a008006001090070050900800700c090080050a008006002090070050a0090070b00a0070060a008007001090070060a00800700c090070060b00800700c090080060b008007002090080050b009007004090080060a009007005090080060a0090060050a0070060b00900700c0a0080060b0090070020a0080070b0090080040a00800600109007005090080060b0090070050a0080060b0090070050a0080060b0090070050b0080070b00';
  var leapNNm13='90080060a008007001090080050a008007001090080050a00800700c090080050a0090060020a0070060a0090070b00a0080060a0090070010a0070060b0090070010a0080060b008007002090080060b0090070020a0080060b0090070040a0080060a0090070050a0080060b0090070050a0080060b00900700c0a00800600c090070020a00800700c090080040a0090060010900';//7800年
  var leapNNm=leapNNm0+leapNNm1+leapNNm2+leapNNm3+leapNNm4+leapNNm5+leapNNm6+leapNNm7+leapNNm8+leapNNm9+leapNNm10+leapNNm11+leapNNm12+leapNNm13;/////
  function leapM6(y){ ////計算2302年后閏月
   var v=leapNNm.charAt(y-starYd);
  if(v=='a')
    v=10;
  if(v=='b')
    v=11;
  if(v=='c')
    v=12;
  if(v=='')
    v=0;
  return parseInt(v);
 }

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
chwc
  33楼 个性首页 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:603 积分:5315 威望:0 精华:4 注册:2008/4/21 19:06:00
  发帖心情 Post By:2011/2/28 19:49:00

 function leapN(y){ ///求閏月數
  var leapN=0;var lea=0; var lea2=''; //
  var lea3=leapM6(y);
  return lea3;
  }
function zqmo(y,n){//y年每個節氣日所在月到1900年,1,1總月數(閏月未扣除)冬至n=24
  var dtt=S(y,n,1);var dt=antiD0(y,floor(dtt));
  var m=floor(dt/100);var m0=m;if(m<1)m0=m+12;if(m>12)m0=m-12;
  var d=dt%100;var d1=d;if(m<0)d1=(100*abs(m))+dt;
  var lumt2=lunData(y,m0,d1,5);if(m>12)lumt2=lunData(y+1,m0,d1,5);if(m<1)lumt2=lunData(y-1,m0,d1,5);
  var dzrs=lumt2;
  return dzrs; 
   }
function lunMoa(y,m,d,a){//年、月數
  var lumt=lunData(y,m,d,5);var nlnuy0=leapM6(y-1);var nlnuy=leapM6(y);
  var lmn5=leapM5(y);var lmn6=0;if(lmn5==12)lmn6=12;
  var leapNm2=nlnuy;if(y<-1187)leapNm2=lmn6;
  var leapN=0;//從當年到-2699年的總閏月數
  var leapN2=0;if(leapNm2>0)leapN2=1;
  if(y>=2302||y<-1187){
  var lumt2=zqmo(y-1,24);//上年冬至日所在月到1900年,1,1總月數(閏月未扣除)
  var dzrs=lumt2;}else{var dzrs=0;
   }//
  if(y>=-1187&&y<2302){
  leapN=leapNum(y);var lumq=-38180;
  var MonN=(lumt-lumq)-leapN;//當日到-1187年,2,7的總月數(扣除閏月)
  //電腦醫萬年暦及福星萬年暦史上修改月建開紿
  if(lumt>=-14076&&lumt<-14071)MonN=MonN+2;//761,12,2--762,4,29
  if(lumt<-14830) MonN=MonN+2;//700,12,15
  if(lumt<-14966) MonN=MonN-2;//689,12,18
  if(lumt<-20531) MonN++;//240,1,12
  if(lumt<-20565) MonN--;//237,4,13
  if(lumt<-23205) MonN++;//23,11,2
  if(lumt<-23388) MonN--;//9,1,15
  if(lumt<-24771) MonN+=3;//-103,3,23
  if(lumt<-32417) MonN++;//-721,1,16
  if(lumt<-36425) MonN--;//-1046,12,30
  if(lumt<-43276) MonN--;//-1599,2,1//史上修改月建完
  var leapNk=0;if(leapMon(y)>0)leapNk=1;
  var lunM8aa=ifGr5(y,m,d);
  var luny=floor((MonN+9+leapNk)/12)-1188;if(lunM8aa<7&&m>2)luny=floor((MonN+9)/12)-1188;
  var lunM=round(rem(MonN-3,12)+1);
  var lunM5a=round(rem(MonN-3,12)+1);
   if(lunM8aa<7&&leapMon(luny)>0&&lunM==(leapMon(luny)+1)&&m>9&&lunM<5)
   lunM=(lunM-1)*(-1);
    else{
  if(lunM8aa<7&&leapMon(luny)>0&&lunM<leapMon(luny)&&m>=9&&lunM<5)
    lunM=lunM;
      else{
  if(lunM8aa<7&&leapMon(luny)>0&&lunM>leapMon(luny)&&m>=9&&lunM<5)
    lunM--;
      else{
    if(leapMon(luny)>0&&lunM==leapMon(luny)&&(m-lunM)<5&&(m-lunM)>-2||y>-150&&lunM8aa==7&&leapMon(y-1)>10&&lunM==leapMon(y-1)&&m<5||lunM8aa<7&&leapMon(luny)==12&&lunM==leapMon(luny)&&m>8)
      lunM*=-1;
      else{
      if(m<5&&lunM>9&&leapMon(y)||lunM<leapMon(luny))
        lunM++;//y年是閏月但當月未過閏月則前面多扣除了本年的閏月,這裏應當補償 
        if(lunM>=0)lunM=round(rem(lunM-1,12)+1);
       }}}}
     }else{//2302年後的
   if(y<-1187&&lmn5>=12)leapN2=1;
  var lmn8=0;if(y<-1187&&lmn5>=12)lmn8=12;
  var MonN=(lumt-(dzrs))+37-leapN2;//當日到上年冬至所在月的總月數(扣除閏月)
  if(y>=-1598&&y<-1187||y==-1599&&m>=2) MonN++;
  var lunM=round(rem(MonN-3,12)+1);
  var lunMk=round(rem(lunM-1+leapN2,12)+1);if(nlnuy0==11&&m<=3)lunMk=round(rem(lunM-2,12)+1);
  if(nlnuy==12||y<-1187&&lmn8==12)lunMk=round(rem(lunM-1,12)+1);
  var luny=y;if(m<=3&&lunMk>=10)luny=y-1;
 if(m<=3&&lunM==12&&nlnuy0==11)
  lunM=-11;
 else{
    if(lunM==nlnuy&&nlnuy>0&&nlnuy<11||m<=3&&lunM>=10&&m<lunM&&lunM==nlnuy&&nlnuy>0&&nlnuy<11||nlnuy==11&&m>=11&&lunM==11)
    lunM*=-1;
 else{
    if(lunM<nlnuy&&nlnuy>0&&nlnuy<12||m<=3&&lunM>=10&&m<lunM&&nlnuy&&nlnuy>0&&nlnuy<12)
    lunM++;
 else{
 if(nlnuy==12&&m<=2&&lunM==nlnuy&&lunM>2||y<-1187&&lmn8==12&&m<=4&&lunM==lmn8&&lunM>3)
 lunM*=-1;
 else{
 if(nlnuy==12&&m<=2&&lunM<nlnuy&&lunM>2||y<-1187&&lmn8==12&&m<=4&&lunM<lmn8&&lunM>3)
 lunM++;
 else{
 if(nlnuy0==11&&lunM>=0)
 lunM--;
 }}}}}
 if(lunM>=0)lunM=round(rem(lunM-1,12)+1);
   }
  if(y<-1187&&lunM==-12)
  lunM=13;
  if(a==1){
  return luny;
  }else{
  return lunM;
  }}

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
chwc
  34楼 个性首页 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:603 积分:5315 威望:0 精华:4 注册:2008/4/21 19:06:00
  发帖心情 Post By:2011/2/28 19:49:00

function luny(y,m,d){//取出農曆公元紀年數(公元前1年顯0);正月一日為界
 return lunMoa(y,m,d,1);
}
function lunMon(y,m,d){//取出月數
 return lunMoa(y,m,d);
}
function gaiyej(y1,m1,d1,lunM1,lunD1){//取出史上修改月建
  var v='';
  if(y1==240 && m1==1 && lunM1==12 && d1>lunD1 || y1==240 && m1==2 && lunM1==12 && d1<lunD1 ){v='改'}else{}
  if(y1==23 && m1==11 && lunM1==10 && d1>=lunD1 || y1==23 && m1==12 && lunM1==10 && d1<=lunD1 ){v='改'}else{}
  if(y1==9&&m1==1&&d1>14||y1==9&&m1==2&&d1<14){v='改'}else{}
  if(y1==-103 && m1>3 && lunM1<=4||y1==-103 && m1==3 && d1>=lunD1){v='改'}else{}
  if(y1==-721 && m1==1 && d1>lunD1||y1==-721 && m1==2 && d1<=lunD1){v='改'}else{}
  if(y1==-1599 && m1==2||y1==-1599 && m1==3&& d1<3||y1==-1046 && m1==12 && d1>lunD1||y1==-1045 && m1==1 && d1<=lunD1){v='改'}else{}
  return v;
}
function lunDate(y,m,d){//取出每月天數和日數,如2901;29代表這個月有29天01代表是初一。
return lunData(y,m,d);
}
//取出月相,日月食
function shwStr(y,m,d){//電腦醫萬年暦含發生時間月相
  return rsys(y,m,d,1);
}
function shwStr1(y,m,d){//電腦醫萬年暦不含發生時間月相
  return rsys(y,m,d,2);
}
  function zim(y,m,d,ak){//電腦醫萬年暦及福星萬年暦曆家地支紀月(初一為界的);1=寅
  var lunM8aa=ifGr5(y,m,d);var mk=0;var mk3=0;
  if(lunM8aa==1||lunM8aa==0||lunM8aa==6)mk=2;
  if(lunM8aa==3||lunM8aa==4||lunM8aa==5)mk=1;
  if(lunM8aa==2)mk=3;
  var mk2=abs(lunMoa(y,m,d));var ii=mk2-mk;
  if(y<-1187&&ii==13)ii=12;ii=round(rem(ii-1,12)+1);
  var ii2=ii;if(lunMoa(y,m,d)<0&&ak==1)ii2=ii*(-1);
  return ii2;
}
  function lundsMon(y,m,d){//農曆月大小。
  var a96t=lunData(y,m,d);
  var a96=floor(a96t/100);
  var dszm=(a96==30)?'大':'小';
  return dszm;
  }

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
CPU
  35楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:25 积分:407 威望:0 精华:0 注册:2005/11/26 4:45:00
  发帖心情 Post By:2011/3/10 3:07:00

谢谢分享!俺要认真学习

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
nikexie
  36楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:10 积分:263 威望:0 精华:0 注册:2011/2/27 15:18:00
  发帖心情 Post By:2011/3/14 13:08:00

很有用的资料,楼主很热心!

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
水生活
  37楼 个性首页 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:16 积分:258 威望:0 精华:0 注册:2011/3/9 16:42:00
  发帖心情 Post By:2011/3/26 22:57:00

来学习的呵,不过源码我确实不懂

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
nikexie
  38楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:10 积分:263 威望:0 精华:0 注册:2011/2/27 15:18:00
  发帖心情 Post By:2011/3/29 12:16:00

这些是干什么的?

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
帅哥哟,离线,有人找我吗?
ch20111111
  39楼 个性首页 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:1 积分:201 威望:0 精华:0 注册:2011/12/30 17:38:00
  发帖心情 Post By:2011/12/30 17:52:00

很给力啊啊

支持(0中立(0反对(0单帖管理 | 引用 | 回复 回到顶部
总数 39 上一页 1 2 3 4

返回版面帖子列表

[原创]电脑医生万年历和福星万年历最新历算源码








签名