var lunarInfo=new Array(//阴历数据 0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2, 0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977, 0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970, 0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950, 0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557, 0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0, 0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0, 0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6, 0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570, 0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0, 0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5, 0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930, 0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530, 0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45, 0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0) var solar_month=new Array(31,28,31,30,31,30,31,31,30,31,30,31); var day_gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸"); var day_zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"); var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"); var solar_term = new Array("","","","","","","","","","","","","","","","","","","","","","","","") //计算某年的第n个节气公历日期所需要的基础数据(类似于每月的多少天) var sterm_info = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758) var n_str1= new Array('','','','','','','','','','','') var n_str2 = new Array('','','','','') //国历节日 *表示放假日 var solar_fes = new Array( "20240327*事件", "20231220*事件", "20231025*事件", "20230823*事件", "20230628*事件", "20230524*事件", "20230426*事件", "20230322*事件", "20230222*事件", "20221221*事件", "20220719*事件", "20220622*事件", "20220223*事件", "20220126*事件", "20220113*事件", "20220123*事件", "19700101*事件", "19700101*事件", "19700101*事件", "19700101*事件", "19700101*事件", "19700101*事件", "19700101*事件", "19700101*事件", "20211118*事件", "20211127*事件", "20211023*事件", "20210925*事件", "20210828*事件", "20210724*事件", "20210522*事件", "20210424*事件", "20210327*事件", "20210227*事件", "20210123*事件", "20201226*事件", "20201128*事件", "20201024*事件", "20200927*事件", "20200822*事件", "20200725*事件", "20200621*事件", "20200523*事件", "20200425*事件", "20200328*事件", "20200222*事件", "20200112*事件", "20210806*事件", "20201001*事件", "20210305*事件", "20200901*事件", "20200724*事件", "20191128*事件", "20190905*事件", "20180426*事件", "20170713*事件", "19700101*事件", "20211201*事件", "20210505*事件", "20210303*事件", "20201105*事件", "20200805*事件", "20200603*事件", "20200212*事件", "20211215*事件", "20211004*事件", "19700101*事件", "20211015*事件", "20211124*事件", "20201223*事件", "19700101*事件", "20210917*事件", "20211012*事件", "20210825*事件", "20191225*事件", "20210819*事件", "19700101*事件", "20210820*事件", "20210908*事件", "20181228*事件", "20210817*事件", "19700101*事件", "20210716*事件", "20210715*事件", "20181226*事件", "20200917*事件", "19700101*事件", "20210521*事件", "20210609*事件", "20171220*事件", "20210422*事件", "19700101*事件", "20200826*事件", "20210514*事件", "19700101*事件", "20210319*事件", "20210409*事件", "20191023*事件", "19700101*事件", "20210219*事件", "20210311*事件", "20181003*事件", "19700101*事件", "20210115*事件", "20210224*事件", "20210928*事件", "20181003*事件", "19700101*事件", "20201218*事件", "20181003*事件", "19700101*事件", "20201016*事件", "20210107*事件", "20181003*事件", "19700101*事件", "20200918*事件", "20201222*事件", "20200821*事件", "19700101*事件", "20180829*事件", "20201106*事件", "20200717*事件", "20200924*事件", "20170810*事件", "20200619*事件", "20200903*事件", "20200515*事件", "20200706*事件", "20200423*事件", "20200611*事件", "20200320*事件", "20200511*事件", "20200221*事件", "20200422*事件", "20200117*事件", "20200325*事件", "20200226*事件", "20200114*事件", ) //农历节日 *表示放假日 var lunar_fes = new Array(); var w_fes = new Array(); var today = new Date(); var tY = today.getFullYear(); var tM = today.getMonth(); var tD = today.getDate(); var width = "130"; var offsetx = 2; var offsety = 16; var x = 0; var y = 0; var snow = 0; var sw = 0; var cnt = 0; var dStyle; // 时钟clock setInterval("oTime()",1000); function oTime() { today = new Date(); var hou = today.getHours(); var min=today.getMinutes(); //分 var sec =today.getSeconds(); //秒 if(sec<10) var sec ="0"+sec; if(min<10) var min= "0"+min; if(hou<10) var hou = "0"+hou; clock.innerHTML = ''+hou+':'+min+':'+sec+''; } //返回农历第y年的总天数 function lunar_day(y) { var i, sum = 348 for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0 return(sum+lunar_leap(y)) } //返回农历第y年闰月的天数 function lunar_leap(y) { if(lunar_leap_m(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29) else return(0) } //返回农历第y年闰几月(1-12月),没闰返回0 function lunar_leap_m(y) { return(lunarInfo[y-1900] & 0xf) } //返回农历第y年第m月的总天数 function lunar_leap_d(y,m) { return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 ) } //算出农历,把值传入到日期控件,返回农历日期控件 //该农历日期对象的属性:.year,.month,.day,.isLeap, //.yearCyl,.monthCyl,.dayCyl function Lunar(objDate) { var i, leap=0, temp=0 var baseDate = new Date(1900,0,31); var offset = (objDate - baseDate)/86400000 this.dayCyl = offset + 40 this.monCyl = 14 for(i=1900; i<2050 && offset>0; i++) { temp = lunar_day(i) offset -= temp this.monCyl += 12 } if(offset<0) { offset += temp; i--; this.monCyl -= 12 } this.year = i this.yearCyl = i-1864 leap = lunar_leap_m(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 = lunar_leap(this.year); } else { temp = lunar_leap_d(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 } function solar_day(y,m) { if(m==1) return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28) else return(solar_month[m]) } //传入offset 传回干支,0=甲子 function cyclical(num) { return(day_gan[num%10]+day_zhi[num%12]) } function cal_ele(sy,s_m,s_d,week,lYear,l_m,l_d,isLeap,c_y,c_m,cal_d) { this.color = ''; this.lunar_festival = ''; this.solar_festival = ''; this.solarTerms = ''; this.istoday = false; this.sy = sy; this.s_m = s_m; this.s_d = s_d; this.week = week; this.lYear = lYear; this.l_m = l_m; this.l_d = l_d; this.isLeap = isLeap; this.c_y = c_y; this.c_m = c_m; this.cal_d = cal_d; } //某年的第n个节气的公历日期(从0小寒算起);节气的公历日期的计算参考网上算法 function sTerm(y,n) { var off_date = new Date( ( 31556925974.7*(y-1900) +sterm_info[n]*60000 ) + Date.UTC(1900,0,6,2,5) ) return(off_date.getUTCDate()) } function calendar(y,m) { var lunar_dpos = new Array(3) var solor_dobj, lunar_dobj, lY, lM, lD=1, lL, lX=0, t_1, t_2 var n = 0,first_lunarm = 0 solor_dobj = new Date(y,m,1) this.length = solar_day(y,m) this.firstWeek = solor_dobj.getDay() for(var i=0;ilX) { solor_dobj = new Date(y,m,i+1) lunar_dobj = new Lunar(solor_dobj) lY = lunar_dobj.year lM = lunar_dobj.month lD = lunar_dobj.day lL = lunar_dobj.isLeap lX = lL? lunar_leap(lY): lunar_leap_d(lY,lM) if(n==0) first_lunarm = lM lunar_dpos[n++] = i-lD+1 } this[i] = new cal_ele(y, m+1, i+1, n_str1[(i+this.firstWeek)%7], lY, lM, lD++, lL, cyclical(lunar_dobj.yearCyl) ,cyclical(lunar_dobj.monCyl), cyclical(lunar_dobj.dayCyl++) ) if((i+this.firstWeek)%7==0) this[i].color = '#FF5F07' if((i+this.firstWeek)%14==13) this[i].color = '#FF5F07' } t_1=sTerm(y,m*2 )-1 t_2=sTerm(y,m*2+1)-1 this[t_1].solarTerms = solar_term[m*2] this[t_2].solarTerms = solar_term[m*2+1] if(m==3) this[t_1].color = '#FF5F07' for(i in w_fes) if(w_fes[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/)) if(Number(RegExp.$1)==(m+1)) { t_1=Number(RegExp.$2) t_2=Number(RegExp.$3) this[((this.firstWeek>t_2)?7:0) + 7*(t_1-1) + t_2 - this.firstWeek].solar_festival += RegExp.$5 + ' ' } for(i in lunar_fes) if(lunar_fes[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) { t_1=Number(RegExp.$1)-first_lunarm if(t_1==-11) t_1=1 if(t_1 >=0 && t_1= 0 && t_2'; for(i=0;i<42;i++) { solar_obj=eval('SD'+ i); lunar_obj=eval('LD'+ i); solar_obj.style.background = ''; lunar_obj.style.background = ''; sD = i - cld.firstWeek; if(sD>-1 && sD'; else lunar_obj.innerHTML = cal_d(cld[sD].l_d); s=cld[sD].lunar_festival; if(s.length>0) { if(s.length>5) s = s.substr(0, 3)+'…'; } else { s=cld[sD].solar_festival; if(s.length>0) { size = (s.charCodeAt(0)>0 && s.charCodeAt(0)<128)?8:4; if(s.length>size+1) s = s.substr(0, size-1)+'…'; s = s.fontcolor('#FF5C33'); //节日 solar_obj.style.background = '#b1e3e7'; //節日底色 } else { s=cld[sD].solarTerms;//24节气 if(s.length>0) s = s.fontcolor('#2EBEB7'); } } if(s.length>0) lunar_obj.innerHTML = s; } else { solar_obj.innerHTML = ' '; lunar_obj.innerHTML = ' '; } } } function chaCld() { var y,m; y=calender_content.SY.selectedIndex+1900; m=calender_content.SM.selectedIndex; setCld(y,m); } // 年份,月份选择菜单栏 function BtN(V) { if(V=='year_d'&&calender_content.SY.selectedIndex>0) calender_content.SY.selectedIndex--; else if(V=='year_a'&&calender_content.SY.selectedIndex<149) calender_content.SY.selectedIndex++; else if(V=='month_d'){ if(calender_content.SM.selectedIndex>0) {calender_content.SM.selectedIndex--; }else {calender_content.SM.selectedIndex=11; if(calender_content.SY.selectedIndex>0) calender_content.SY.selectedIndex--; } } else if(V=='month_a'){ if(calender_content.SM.selectedIndex<11) { calender_content.SM.selectedIndex++; }else {calender_content.SM.selectedIndex=0; if(calender_content.SY.selectedIndex<149) calender_content.SY.selectedIndex++; } } else { calender_content.SY.selectedIndex=tY-1900; calender_content.SM.selectedIndex=tM; } chaCld(); //---年份月份更動呼叫父視窗函數--- window.parent.clanderDateOnChange(calender_content.SY.selectedIndex+1900,calender_content.SM.selectedIndex+1); } //生成日历数据 function addDay(v) { var s,fes; var solar_obj=eval('SD'+ v); var d=solar_obj.innerHTML-1; if(solar_obj.innerHTML!='') { if(cld[d].solar_festival.length>0){ solar_obj.style.cursor = 'pointer'; }else{ solar_obj.style.cursor = 'default'; } fes = ''+ '
'+''+cld[d].solarTerms + ' ' + cld[d].solar_festival + ' ' + cld[d].lunar_festival+'
'; day_detal= ''; date_content.innerHTML = day_detal; window.parent.clanderDateOnClickDay(cld[d].s_d); } } function setCookie(name, value) { var today = new Date() var expires = new Date() expires.setTime(today.getTime() + 1000*60*60*24*365) document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() } function getCookie(Name) { var search = Name + "=" if(document.cookie.length > 0) { offset = document.cookie.indexOf(search) if(offset != -1) { offset += search.length end = document.cookie.indexOf(";", offset) if(end == -1) end = document.cookie.length return unescape(document.cookie.substring(offset, end)) } else return "" } } function initial() { dStyle = detail.style; calender_content.SY.selectedIndex=tY-1900; calender_content.SM.selectedIndex=tM; setCld(tY,tM); }