JavaScript时间脚本大全this.year = i this.yearCyl = i-1864 leap = leapMonth(i) //闰哪个月 this.isLeap = false for(i=1; i<13 && offset>0; i++) { //闰月 if(leap>0 && i==(leap+1) && this.isLeap==false) { --i; this.isLeap = true; temp = leapDays(this.year); } else { temp = monthDays(this.year, i); } //解除闰月 if(this.isLeap==true && i==(leap+1)) this.isLeap = false offset -= temp if(this.isLeap == false) this.monCyl ++ } if(offset==0 && leap>0 && i==leap+1) if(this.isLeap) { 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;
伊图教程网[www.etoow.com] http://www.etoow.com/html/2007-10/1193133891-11.html
this.sMonth = sMonth;
JavaScript时间脚本大全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;i<this.length;i++) { if(lD>lX) { 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) //农历当月最後一天
|