农历与阳历的对照[3]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 meizz 的 blog

{ this.isleap = false; } else { this.isleap = true; --i; --this.moncyl;} if(offset<0){ offset += temp; --i; --this.moncyl; } this.month = i this.day = offset + 1 } //==============================传回国历 y年某m+1月的天数 function solardays(y,m) { if(m==1) return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28) else return(solarmonth[m]) } //============================== 传入 offset 传回干支, 0=甲子 function cyclical(num) { return(gan[num%10]+zhi[num%12]) } //============================== 月历属性 function calelement(syear,smonth,sday,week,lyear,lmonth,lday,isleap,cyear,cmonth,cday) { this.istoday = false; //国历 this.syear = syear; this.smonth = smonth; this.sday = sday; this.week = week; //农历 this.lyear = lyear; this.lmonth = lmonth; this.lday = lday; this.isleap = isleap; //干支 this.cyear = cyear; this.cmonth = cmonth; this.cday = cday; this.color = ''; this.lunarfestival = ''; //农历节日 this.solarfestival = ''; //国历节日 this.solarterms = ''; //节气 } //===== 某年的第n个节气为几日(从0小寒起算) function sterm(y,n) { var offdate = new date( ( 31556925974.7*(y-1900) + sterminfo[n]*60000 ) + date.utc(1900,0,6,2,5) ) return(offdate.getutcdate()) } //============================== 传回月历物件 (y年,m+1月) function calendar(y,m) { var sdobj, ldobj, ly, lm, ld=1, ll, lx=0, tmp1, tmp2 var ldpos = new array(3) var n = 0 var firstlm = 0 sdobj = new date(y,m,1) //当月一日日期 this.length = solardays(y,m) //国历当月天数 this.firstweek = sdobj.getday() //国历当月1日星期几 for(var i=0;ilx) { sdobj = new date(y,m,i+1) //当月一日日期 ldobj = new lunar(sdobj) //农历 ly = ldobj.year //农历年 lm = ldobj.month //农历月 ld = ldobj.day //农历日 ll = ldobj.isleap //农历是否闰月 lx = ll? leapdays(ly): monthdays(ly,lm) //农历当月最後一天 if(n==0) firstlm = lm ldpos[n++] = i-ld+1 } //syear,smonth,sday,week, //lyear,lmonth,lday,isleap, //cyear,cmonth,cday this[i] = new calelement(y, m+1, i+1, nstr1[(i+this.firstweek)%7], ly, lm, ld++, ll, cyclical(ldobj.yearcyl) ,cyclical(ldobj.moncyl), cyclical(ldobj.daycyl++) ) if((i+this.firstweek)%7==0) this[i].color = 'red' //周日颜色 if((i+this.firstweek)%7==6) this[i].color = 'red' //周休二日颜色 } //节气 tmp1=sterm(y,m*2 )-1 tmp2=sterm(y,m*2+1)-1 this[tmp1].solarterms = solarterm[m*2] this[tmp2].solarterms = solarterm[m*2+1] if(m==3) this[tmp1].color = 'red' //清明颜色 //国历节日 for(i in sftv) if(sftv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/)) if(number(regexp.$1)==(m+1)) { this[number(regexp.$2)-1].solarfestival += regexp.$4 + ' ' if(regexp.$3=='*') this[number(regexp.$2)-1].color = 'red' } //月周节日 for(i in wftv) if(wftv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/)) if(number(regexp.$1)==(m+1)) { tmp1=number(regexp.$2) tmp2=number(regexp.$3) this[((this.firstweek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstweek].solarfestival += regexp.$5 + ' ' } //农历节日 for(i in lftv) if(lftv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) { tmp1=number(regexp.$1)-firstlm if(tmp1==-11) tmp1=1 if(tmp1 >=0 && tmp1= 0 && tmp21874 && sy<1909) ydisplay = '光绪' + (((sy-1874)==1)?'元':sy-1874) if(sy>1908 && sy<1912) ydisplay = '宣统' + (((sy-1908)==1)?'元':sy-1908) if(sy>1911 && sy<1950) ydisplay = '民国' + (((sy-1911)==1)?'元':sy-1911) if(sy>1949) ydisplay = '共和国' + (((sy-1949)==1)?'元':sy-1949) ymqg.innerhtml = ydisplay +'年 农历' + cyclical(sy-1900+36) + '年   【'+animals[(sy-4)%12]+'

本文关键:时钟 日历 农历
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top