1<!--
2/*****************************************************************************
3 日期资料
4*****************************************************************************/
5
6var lunarInfo=new Array(
70x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
80x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
90x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
100x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
110x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
120x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,
130x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
140x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,
150x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
160x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
170x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
180x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
190x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
200x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
210x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0)
22
23var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
24var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
25var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
26var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");
27var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至")
28var sTermInfo = 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)
29var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十')
30var nStr2 = new Array('初','十','廿','卅',' ')
31var monthName = new Array("1 月","2 月","3 月","4 月","5 月","6 月","7 月","8 月","9 月","10 月","11 月","12 月");
32
33//国历节日 *表示放假日
34var sFtv = new Array(
35"0101*元旦",
36"0214 情人节",
37"0308 妇女节",
38"0312 植树节",
39"0315 消费者权益日",
40"0401 愚人节",
41"0501 劳动节",
42"0504 青年节",
43"0512 护士节",
44"0601 儿童节",
45"0701 建党节",
46"0801 建军节",
47"0808 父亲节",
48"0909 ***逝世纪念",
49"0910 教师节",
50"0928 孔子诞辰",
51"1001*国庆节",
52"1006 老人节",
53"1024 联合国日",
54"1112 孙中山诞辰",
55"1220 澳门回归",
56"1225 圣诞节",
57"1226 ***诞辰")
58
59//农历节日 *表示放假日
60var lFtv = new Array(
61"0101*农历春节",
62"0115 元宵节",
63"0505 端午节",
64"0707 七夕情人节",
65"0815 中秋节",
66"0909 重阳节",
67"1208 腊八节",
68"1224 小年",
69"0100*除夕")
70
71//某月的第几个星期几
72var wFtv = new Array(
73"0520 母亲节")
74
75/*****************************************************************************
76 日期计算
77*****************************************************************************/
78
79//====================================== 传回农历 y年的总天数
80function lYearDays(y) {
81 var i, sum = 348
82 for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0
83 return(sum+leapDays(y))
84}
85
86//====================================== 传回农历 y年闰月的天数
87function leapDays(y) {
88 if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29)
89 else return(0)
90}
91
92//====================================== 传回农历 y年闰哪个月 1-12 , 没闰传回 0
93function leapMonth(y) {
94 return(lunarInfo[y-1900] & 0xf)
95}
96
97//====================================== 传回农历 y年m月的总天数
98function monthDays(y,m) {
99 return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 )
100}
101
102//====================================== 算出农历, 传入日期物件, 传回农历日期物件
103// 该物件属性有 .year .month .day .isLeap .yearCyl .dayCyl .monCyl
104function Lunar(objDate) {
105
106 var i, leap=0, temp=0
107 var baseDate = new Date(1900,0,31)
108 var offset = (objDate - baseDate)/86400000
109
110 this.dayCyl = offset + 40
111 this.monCyl = 14
112
113 for(i=1900; i<2050 && offset>0; i++) {
114 temp = lYearDays(i)
115 offset -= temp
116 this.monCyl += 12
117 }
118
119 if(offset<0) {
120 offset += temp;
121 i--;
122 this.monCyl -= 12
123 }
124
125 this.year = i
126 this.yearCyl = i-1864
127
128 leap = leapMonth(i) //闰哪个月
129 this.isLeap = false
130
131 for(i=1; i<13 && offset>0; i++) {
132 //闰月
133 if(leap>0 && i==(leap+1) && this.isLeap==false)
134 { --i; this.isLeap = true; temp = leapDays(this.year); }
135 else
136 { temp = monthDays(this.year, i); }
137
138 //解除闰月
139 if(this.isLeap==true && i==(leap+1)) this.isLeap = false
140
141 offset -= temp
142 if(this.isLeap == false) this.monCyl ++
143 }
144
145 if(offset==0 && leap>0 && i==leap+1)
146 if(this.isLeap)
147 { this.isLeap = false; }
148 else
149 { this.isLeap = true; --i; --this.monCyl;}
150
151 if(offset<0){ offset += temp; --i; --this.monCyl; }
152
153 this.month = i
154 this.day = offset + 1
155}
156
157//==============================传回国历 y年某m+1月的天数
158function solarDays(y,m) {
159 if(m==1)
160 return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28)
161 else
162 return(solarMonth[m])
163}
164//============================== 传入 offset 传回干支, 0=甲子
165function cyclical(num) {
166 return(Gan[num%10]+Zhi[num%12])
167}
168
169//============================== 月历属性
170function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {
171
172 this.isToday = false;
173 //国历
174 this.sYear = sYear;
175 this.sMonth = sMonth;
176 this.sDay = sDay;
177 this.week = week;
178 //农历
179 this.lYear = lYear;
180 this.lMonth = lMonth;
181 this.lDay = lDay;
182 this.isLeap = isLeap;
183 //干支
184 this.cYear = cYear;
185 this.cMonth = cMonth;
186 this.cDay = cDay;
187
188 this.color = '';
189
190 this.lunarFestival = ''; //农历节日
191 this.solarFestival = ''; //国历节日
192 this.solarTerms = ''; //节气
193
194}
195
196//===== 某年的第n个节气为几日(从0小寒起算)
197function sTerm(y,n) {
198 var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) )
199 return(offDate.getUTCDate())
200}
201
202//============================== 传回月历物件 (y年,m+1月)
203function calendar(y,m) {
204
205 var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2
206 var lDPOS = new Array(3)
207 var n = 0
208 var firstLM = 0
209
210 sDObj = new Date(y,m,1) //当月一日日期
211
212 this.length = solarDays(y,m) //国历当月天数
213 this.firstWeek = sDObj.getDay() //国历当月1日星期几
214
215
216 for(var i=0;i<this.length;i++) {
217
218 if(lD>lX) {
219 sDObj = new Date(y,m,i+1) //当月一日日期
220 lDObj = new Lunar(sDObj) //农历
221 lY = lDObj.year //农历年
222 lM = lDObj.month //农历月
223 lD = lDObj.day //农历日
224 lL = lDObj.isLeap //农历是否闰月
225 lX = lL? leapDays(lY): monthDays(lY,lM) //农历当月最後一天
226
227 if(n==0) firstLM = lM
228 lDPOS[n++] = i-lD+1
229 }
230
231 //sYear,sMonth,sDay,week,
232 //lYear,lMonth,lDay,isLeap,
233 //cYear,cMonth,cDay
234 this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],
235 lY, lM, lD++, lL,
236 cyclical(lDObj.yearCyl) ,cyclical(lDObj.monCyl), cyclical(lDObj.dayCyl++) )
237
238
239 if((i+this.firstWeek)%7==0) this[i].color = 'red' //周日颜色
240 if((i+this.firstWeek)%14==13) this[i].color = 'red' //周休二日颜色
241 }
242
243 //节气
244 tmp1=sTerm(y,m*2 )-1
245 tmp2=sTerm(y,m*2+1)-1
246 this[tmp1].solarTerms = solarTerm[m*2]
247 this[tmp2].solarTerms = solarTerm[m*2+1]
248 if(m==3) this[tmp1].color = 'red' //清明颜色
249
250 //国历节日
251 for(i in sFtv)
252 if(sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/))
253 if(Number(RegExp.$1)==(m+1)) {
254 this[Number(RegExp.$2)-1].solarFestival += RegExp.$4 + ' '
255 if(RegExp.$3=='*') this[Number(RegExp.$2)-1].color = 'red'
256 }
257
258 //月周节日
259 for(i in wFtv)
260 if(wFtv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/))
261 if(Number(RegExp.$1)==(m+1)) {
262 tmp1=Number(RegExp.$2)
263 tmp2=Number(RegExp.$3)
264 this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += RegExp.$5 + ' '
265 }
266
267 //农历节日
268 for(i in lFtv)
269 if(lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {
270 tmp1=Number(RegExp.$1)-firstLM
271 if(tmp1==-11) tmp1=1
272 if(tmp1 >=0 && tmp1<n) {
273 tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1
274 if( tmp2 >= 0 && tmp2<this.length) {
275 this[tmp2].lunarFestival += RegExp.$4 + ' '
276 if(RegExp.$3=='*') this[tmp2].color = 'red'
277 }
278 }
279 }
280
281 //黑色星期五
282 if((this.firstWeek+12)%7==5)
283 this[12].solarFestival += '黑色星期五 '
284
285 //今日
286 if(y==tY && m==tM) this[tD-1].isToday = true;
287
288}
289
290//====================== 中文日期
291function cDay(d){
292 var s;
293
294 switch (d) {
295 case 10:
296 s = '初十'; break;
297 case 20:
298 s = '二十'; break;
299 break;
300 case 30:
301 s = '三十'; break;
302 break;
303 default :
304 s = nStr2[Math.floor(d/10)];
305 s += nStr1[d%10];
306 }
307 return(s);
308}
309
310///////////////////////////////////////////////////////////////////////////////
311
312var cld;
313
314function drawCld(SY,SM) {
315 var i,sD,s,size;
316 cld = new calendar(SY,SM);
317
318 if(SY>1874 && SY<1909) yDisplay = '光绪' + (((SY-1874)==1)?'元':SY-1874)+'年'
319 if(SY>1908 && SY<1912) yDisplay = '宣统' + (((SY-1908)==1)?'元':SY-1908)+'年'
320 if(SY>1911 && SY<1950) yDisplay = '民国' + (((SY-1911)==1)?'元':SY-1911)+'年'
321 if(SY>1949) yDisplay = ' '
322
323
324
325 GZ.innerHTML = yDisplay +' 农历' + cyclical(SY-1900+36) + '年 【'+Animals[(SY-4)%12]+'】';
326
327 YMBG.innerHTML = " " + SY + "<BR> " + monthName[SM];
328
329
330 for(i=0;i<42;i++) {
331
332 sObj=eval('SD'+ i);
333 lObj=eval('LD'+ i);
334
335 sObj.className = '';
336
337 sD = i - cld.firstWeek;
338
339 if(sD>-1 && sD<cld.length) { //日期内
340 sObj.innerHTML = sD+1;
341
342 if(cld[sD].isToday) sObj.className = 'todyaColor'; //今日颜色
343
344 sObj.style.color = cld[sD].color; //国定假日颜色
345
346 if(cld[sD].lDay==1) //显示农历月
347 lObj.innerHTML = '<b>'+(cld[sD].isLeap?'闰':'') + cld[sD].lMonth + '月' + (monthDays(cld[sD].lYear,cld[sD].lMonth)==29?'小':'大')+'</b>';
348 else //显示农历日
349 lObj.innerHTML = cDay(cld[sD].lDay);
350
351 s=cld[sD].lunarFestival;
352 if(s.length>0) { //农历节日
353 if(s.length>6) s = s.substr(0, 4)+'…';
354 s = s.fontcolor('red');
355 }
356 else { //国历节日
357 s=cld[sD].solarFestival;
358 if(s.length>0) {
359 size = (s.charCodeAt(0)>0 && s.charCodeAt(0)<128)?8:4;
360 if(s.length>size+2) s = s.substr(0, size)+'…';
361 s = s.fontcolor('blue');
362 }
363 else { //廿四节气
364 s=cld[sD].solarTerms;
365 if(s.length>0) s = s.fontcolor('limegreen');
366 }
367 }
368 if(s.length>0) lObj.innerHTML = s;
369
370 }
371 else { //非日期
372 sObj.innerHTML = '';
373 lObj.innerHTML = '';
374 }
375 }
376}
377
378
379function changeCld() {
380 var y,m;
381 y=CLD.SY.selectedIndex+1900;
382 m=CLD.SM.selectedIndex;
383 drawCld(y,m);
384}
385
386function pushBtm(K) {
387 switch (K){
388 case 'YU' :
389 if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;
390 break;
391 case 'YD' :
392 if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;
393 break;
394 case 'MU' :
395 if(CLD.SM.selectedIndex>0) {
396 CLD.SM.selectedIndex--;
397 }
398 else {
399 CLD.SM.selectedIndex=11;
400 if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;
401 }
402 break;
403 case 'MD' :
404 if(CLD.SM.selectedIndex<11) {
405 CLD.SM.selectedIndex++;
406 }
407 else {
408 CLD.SM.selectedIndex=0;
409 if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;
410 }
411 break;
412 default :
413 CLD.SY.selectedIndex=tY-1900;
414 CLD.SM.selectedIndex=tM;
415 }
416 changeCld();
417}
418
419
420
421var Today = new Date();
422var tY = Today.getFullYear();
423var tM = Today.getMonth();
424var tD = Today.getDate();
425//////////////////////////////////////////////////////////////////////////////
426
427var width = "130";
428var offsetx = 2;
429var offsety = 16;
430
431var x = 135;
432var y = 260;
433var snow = 0;
434var sw = 0;
435var cnt = 0;
436
437var dStyle;
438//document.onmousemove = mEvn;
439
440//显示详细日期资料
441function mOvr(v) {
442 var s,festival;
443 var sObj=eval('SD'+ v);
444 var d=sObj.innerHTML-1;
445
446 //sYear,sMonth,sDay,week,
447 //lYear,lMonth,lDay,isLeap,
448 //cYear,cMonth,cDay
449
450 if(sObj.innerHTML!='') {
451
452 //sObj.style.cursor = 's-resize'; //s-resize
453
454 if(cld[d].solarTerms == '' && cld[d].solarFestival == '' && cld[d].lunarFestival == '')
455 festival = '';
456 else
457 festival = '<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>'+
458 '<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].solarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD>'+
459 '</TR></TABLE>';
460
461 s= '<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066"><TR><TD>' +
462 '<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#99CCFF" STYLE="font-size:9pt;">'+
463 cld[d].sYear+' 年 '+cld[d].sMonth+' 月 '+cld[d].sDay+' 日<br>星期'+cld[d].week+'<br>'+
464 '<font color="violet">农历'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日</font><br>'+
465 '<font color="yellow">'+cld[d].cYear+'年 '+cld[d].cMonth+'月 '+cld[d].cDay + '日</font>'+
466 '</FONT></TD></TR></TABLE>'+ festival +'</TD></TR></TABLE>';
467
468
469 document.all["detail"].innerHTML = s;
470
471 if (snow == 0) {
472 dStyle.left = x+offsetx-(width/2);
473 dStyle.top = y+offsety;
474 dStyle.visibility = "visible";
475 snow = 1;
476 }
477 }
478}
479
480//清除详细日期资料
481function mOut() { }
482
483//取得位置
484function mEvn() {
485 x=event.x;
486 y=event.y;
487 if (document.body.scrollLeft)
488 {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
489 if (snow){
490 dStyle.left = x+offsetx-(width/2)
491 dStyle.top = y+offsety
492 }
493}
494
495///////////////////////////////////////////////////////////////////////////
496
497function changeTZ() {
498 CITY.innerHTML = CLD.TZ.value.substr(6)
499 setCookie("TZ",CLD.TZ.selectedIndex)
500}
501
502function tick() {
503 var today
504 today = new Date()
505 Clock.innerHTML = today.toLocaleString().replace(/(年|月)/g, "/").replace(/日/, "");
506 Clock.innerHTML = TimeAdd(today.toGMTString(), CLD.TZ.value)
507 window.setTimeout("tick()", 1000);
508}
509
510function setCookie(name, value) {
511 var today = new Date()
512 var expires = new Date()
513 expires.setTime(today.getTime() + 1000*60*60*24*365)
514 document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString()
515}
516
517function getCookie(Name) {
518 var search = Name + "="
519 if(document.cookie.length > 0) {
520 offset = document.cookie.indexOf(search)
521 if(offset != -1) {
522 offset += search.length
523 end = document.cookie.indexOf(";", offset)
524 if(end == -1) end = document.cookie.length
525 return unescape(document.cookie.substring(offset, end))
526 }
527 else return ""
528 }
529}
530
531/////////////////////////////////////////////////////////
532
533function initial() {
534 dStyle = detail.style;
535 CLD.SY.selectedIndex=tY-1900;
536 CLD.SM.selectedIndex=tM;
537 drawCld(tY,tM);
538
539 CLD.TZ.selectedIndex=getCookie("TZ");
540 changeTZ();
541 tick();
542}
543
544
545
546//-->
547</SCRIPT>
2/*****************************************************************************
3 日期资料
4*****************************************************************************/
5
6var lunarInfo=new Array(
70x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,
80x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,
90x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
100x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
110x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,
120x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,
130x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
140x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,
150x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,
160x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,
170x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,
180x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,
190x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,
200x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,
210x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0)
22
23var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
24var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
25var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
26var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");
27var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至")
28var sTermInfo = 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)
29var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十')
30var nStr2 = new Array('初','十','廿','卅',' ')
31var monthName = new Array("1 月","2 月","3 月","4 月","5 月","6 月","7 月","8 月","9 月","10 月","11 月","12 月");
32
33//国历节日 *表示放假日
34var sFtv = new Array(
35"0101*元旦",
36"0214 情人节",
37"0308 妇女节",
38"0312 植树节",
39"0315 消费者权益日",
40"0401 愚人节",
41"0501 劳动节",
42"0504 青年节",
43"0512 护士节",
44"0601 儿童节",
45"0701 建党节",
46"0801 建军节",
47"0808 父亲节",
48"0909 ***逝世纪念",
49"0910 教师节",
50"0928 孔子诞辰",
51"1001*国庆节",
52"1006 老人节",
53"1024 联合国日",
54"1112 孙中山诞辰",
55"1220 澳门回归",
56"1225 圣诞节",
57"1226 ***诞辰")
58
59//农历节日 *表示放假日
60var lFtv = new Array(
61"0101*农历春节",
62"0115 元宵节",
63"0505 端午节",
64"0707 七夕情人节",
65"0815 中秋节",
66"0909 重阳节",
67"1208 腊八节",
68"1224 小年",
69"0100*除夕")
70
71//某月的第几个星期几
72var wFtv = new Array(
73"0520 母亲节")
74
75/*****************************************************************************
76 日期计算
77*****************************************************************************/
78
79//====================================== 传回农历 y年的总天数
80function lYearDays(y) {
81 var i, sum = 348
82 for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0
83 return(sum+leapDays(y))
84}
85
86//====================================== 传回农历 y年闰月的天数
87function leapDays(y) {
88 if(leapMonth(y)) return((lunarInfo[y-1900] & 0x10000)? 30: 29)
89 else return(0)
90}
91
92//====================================== 传回农历 y年闰哪个月 1-12 , 没闰传回 0
93function leapMonth(y) {
94 return(lunarInfo[y-1900] & 0xf)
95}
96
97//====================================== 传回农历 y年m月的总天数
98function monthDays(y,m) {
99 return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 )
100}
101
102//====================================== 算出农历, 传入日期物件, 传回农历日期物件
103// 该物件属性有 .year .month .day .isLeap .yearCyl .dayCyl .monCyl
104function Lunar(objDate) {
105
106 var i, leap=0, temp=0
107 var baseDate = new Date(1900,0,31)
108 var offset = (objDate - baseDate)/86400000
109
110 this.dayCyl = offset + 40
111 this.monCyl = 14
112
113 for(i=1900; i<2050 && offset>0; i++) {
114 temp = lYearDays(i)
115 offset -= temp
116 this.monCyl += 12
117 }
118
119 if(offset<0) {
120 offset += temp;
121 i--;
122 this.monCyl -= 12
123 }
124
125 this.year = i
126 this.yearCyl = i-1864
127
128 leap = leapMonth(i) //闰哪个月
129 this.isLeap = false
130
131 for(i=1; i<13 && offset>0; i++) {
132 //闰月
133 if(leap>0 && i==(leap+1) && this.isLeap==false)
134 { --i; this.isLeap = true; temp = leapDays(this.year); }
135 else
136 { temp = monthDays(this.year, i); }
137
138 //解除闰月
139 if(this.isLeap==true && i==(leap+1)) this.isLeap = false
140
141 offset -= temp
142 if(this.isLeap == false) this.monCyl ++
143 }
144
145 if(offset==0 && leap>0 && i==leap+1)
146 if(this.isLeap)
147 { this.isLeap = false; }
148 else
149 { this.isLeap = true; --i; --this.monCyl;}
150
151 if(offset<0){ offset += temp; --i; --this.monCyl; }
152
153 this.month = i
154 this.day = offset + 1
155}
156
157//==============================传回国历 y年某m+1月的天数
158function solarDays(y,m) {
159 if(m==1)
160 return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28)
161 else
162 return(solarMonth[m])
163}
164//============================== 传入 offset 传回干支, 0=甲子
165function cyclical(num) {
166 return(Gan[num%10]+Zhi[num%12])
167}
168
169//============================== 月历属性
170function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {
171
172 this.isToday = false;
173 //国历
174 this.sYear = sYear;
175 this.sMonth = sMonth;
176 this.sDay = sDay;
177 this.week = week;
178 //农历
179 this.lYear = lYear;
180 this.lMonth = lMonth;
181 this.lDay = lDay;
182 this.isLeap = isLeap;
183 //干支
184 this.cYear = cYear;
185 this.cMonth = cMonth;
186 this.cDay = cDay;
187
188 this.color = '';
189
190 this.lunarFestival = ''; //农历节日
191 this.solarFestival = ''; //国历节日
192 this.solarTerms = ''; //节气
193
194}
195
196//===== 某年的第n个节气为几日(从0小寒起算)
197function sTerm(y,n) {
198 var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) )
199 return(offDate.getUTCDate())
200}
201
202//============================== 传回月历物件 (y年,m+1月)
203function calendar(y,m) {
204
205 var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2
206 var lDPOS = new Array(3)
207 var n = 0
208 var firstLM = 0
209
210 sDObj = new Date(y,m,1) //当月一日日期
211
212 this.length = solarDays(y,m) //国历当月天数
213 this.firstWeek = sDObj.getDay() //国历当月1日星期几
214
215
216 for(var i=0;i<this.length;i++) {
217
218 if(lD>lX) {
219 sDObj = new Date(y,m,i+1) //当月一日日期
220 lDObj = new Lunar(sDObj) //农历
221 lY = lDObj.year //农历年
222 lM = lDObj.month //农历月
223 lD = lDObj.day //农历日
224 lL = lDObj.isLeap //农历是否闰月
225 lX = lL? leapDays(lY): monthDays(lY,lM) //农历当月最後一天
226
227 if(n==0) firstLM = lM
228 lDPOS[n++] = i-lD+1
229 }
230
231 //sYear,sMonth,sDay,week,
232 //lYear,lMonth,lDay,isLeap,
233 //cYear,cMonth,cDay
234 this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],
235 lY, lM, lD++, lL,
236 cyclical(lDObj.yearCyl) ,cyclical(lDObj.monCyl), cyclical(lDObj.dayCyl++) )
237
238
239 if((i+this.firstWeek)%7==0) this[i].color = 'red' //周日颜色
240 if((i+this.firstWeek)%14==13) this[i].color = 'red' //周休二日颜色
241 }
242
243 //节气
244 tmp1=sTerm(y,m*2 )-1
245 tmp2=sTerm(y,m*2+1)-1
246 this[tmp1].solarTerms = solarTerm[m*2]
247 this[tmp2].solarTerms = solarTerm[m*2+1]
248 if(m==3) this[tmp1].color = 'red' //清明颜色
249
250 //国历节日
251 for(i in sFtv)
252 if(sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/))
253 if(Number(RegExp.$1)==(m+1)) {
254 this[Number(RegExp.$2)-1].solarFestival += RegExp.$4 + ' '
255 if(RegExp.$3=='*') this[Number(RegExp.$2)-1].color = 'red'
256 }
257
258 //月周节日
259 for(i in wFtv)
260 if(wFtv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/))
261 if(Number(RegExp.$1)==(m+1)) {
262 tmp1=Number(RegExp.$2)
263 tmp2=Number(RegExp.$3)
264 this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += RegExp.$5 + ' '
265 }
266
267 //农历节日
268 for(i in lFtv)
269 if(lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {
270 tmp1=Number(RegExp.$1)-firstLM
271 if(tmp1==-11) tmp1=1
272 if(tmp1 >=0 && tmp1<n) {
273 tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1
274 if( tmp2 >= 0 && tmp2<this.length) {
275 this[tmp2].lunarFestival += RegExp.$4 + ' '
276 if(RegExp.$3=='*') this[tmp2].color = 'red'
277 }
278 }
279 }
280
281 //黑色星期五
282 if((this.firstWeek+12)%7==5)
283 this[12].solarFestival += '黑色星期五 '
284
285 //今日
286 if(y==tY && m==tM) this[tD-1].isToday = true;
287
288}
289
290//====================== 中文日期
291function cDay(d){
292 var s;
293
294 switch (d) {
295 case 10:
296 s = '初十'; break;
297 case 20:
298 s = '二十'; break;
299 break;
300 case 30:
301 s = '三十'; break;
302 break;
303 default :
304 s = nStr2[Math.floor(d/10)];
305 s += nStr1[d%10];
306 }
307 return(s);
308}
309
310///////////////////////////////////////////////////////////////////////////////
311
312var cld;
313
314function drawCld(SY,SM) {
315 var i,sD,s,size;
316 cld = new calendar(SY,SM);
317
318 if(SY>1874 && SY<1909) yDisplay = '光绪' + (((SY-1874)==1)?'元':SY-1874)+'年'
319 if(SY>1908 && SY<1912) yDisplay = '宣统' + (((SY-1908)==1)?'元':SY-1908)+'年'
320 if(SY>1911 && SY<1950) yDisplay = '民国' + (((SY-1911)==1)?'元':SY-1911)+'年'
321 if(SY>1949) yDisplay = ' '
322
323
324
325 GZ.innerHTML = yDisplay +' 农历' + cyclical(SY-1900+36) + '年 【'+Animals[(SY-4)%12]+'】';
326
327 YMBG.innerHTML = " " + SY + "<BR> " + monthName[SM];
328
329
330 for(i=0;i<42;i++) {
331
332 sObj=eval('SD'+ i);
333 lObj=eval('LD'+ i);
334
335 sObj.className = '';
336
337 sD = i - cld.firstWeek;
338
339 if(sD>-1 && sD<cld.length) { //日期内
340 sObj.innerHTML = sD+1;
341
342 if(cld[sD].isToday) sObj.className = 'todyaColor'; //今日颜色
343
344 sObj.style.color = cld[sD].color; //国定假日颜色
345
346 if(cld[sD].lDay==1) //显示农历月
347 lObj.innerHTML = '<b>'+(cld[sD].isLeap?'闰':'') + cld[sD].lMonth + '月' + (monthDays(cld[sD].lYear,cld[sD].lMonth)==29?'小':'大')+'</b>';
348 else //显示农历日
349 lObj.innerHTML = cDay(cld[sD].lDay);
350
351 s=cld[sD].lunarFestival;
352 if(s.length>0) { //农历节日
353 if(s.length>6) s = s.substr(0, 4)+'…';
354 s = s.fontcolor('red');
355 }
356 else { //国历节日
357 s=cld[sD].solarFestival;
358 if(s.length>0) {
359 size = (s.charCodeAt(0)>0 && s.charCodeAt(0)<128)?8:4;
360 if(s.length>size+2) s = s.substr(0, size)+'…';
361 s = s.fontcolor('blue');
362 }
363 else { //廿四节气
364 s=cld[sD].solarTerms;
365 if(s.length>0) s = s.fontcolor('limegreen');
366 }
367 }
368 if(s.length>0) lObj.innerHTML = s;
369
370 }
371 else { //非日期
372 sObj.innerHTML = '';
373 lObj.innerHTML = '';
374 }
375 }
376}
377
378
379function changeCld() {
380 var y,m;
381 y=CLD.SY.selectedIndex+1900;
382 m=CLD.SM.selectedIndex;
383 drawCld(y,m);
384}
385
386function pushBtm(K) {
387 switch (K){
388 case 'YU' :
389 if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;
390 break;
391 case 'YD' :
392 if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;
393 break;
394 case 'MU' :
395 if(CLD.SM.selectedIndex>0) {
396 CLD.SM.selectedIndex--;
397 }
398 else {
399 CLD.SM.selectedIndex=11;
400 if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;
401 }
402 break;
403 case 'MD' :
404 if(CLD.SM.selectedIndex<11) {
405 CLD.SM.selectedIndex++;
406 }
407 else {
408 CLD.SM.selectedIndex=0;
409 if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;
410 }
411 break;
412 default :
413 CLD.SY.selectedIndex=tY-1900;
414 CLD.SM.selectedIndex=tM;
415 }
416 changeCld();
417}
418
419
420
421var Today = new Date();
422var tY = Today.getFullYear();
423var tM = Today.getMonth();
424var tD = Today.getDate();
425//////////////////////////////////////////////////////////////////////////////
426
427var width = "130";
428var offsetx = 2;
429var offsety = 16;
430
431var x = 135;
432var y = 260;
433var snow = 0;
434var sw = 0;
435var cnt = 0;
436
437var dStyle;
438//document.onmousemove = mEvn;
439
440//显示详细日期资料
441function mOvr(v) {
442 var s,festival;
443 var sObj=eval('SD'+ v);
444 var d=sObj.innerHTML-1;
445
446 //sYear,sMonth,sDay,week,
447 //lYear,lMonth,lDay,isLeap,
448 //cYear,cMonth,cDay
449
450 if(sObj.innerHTML!='') {
451
452 //sObj.style.cursor = 's-resize'; //s-resize
453
454 if(cld[d].solarTerms == '' && cld[d].solarFestival == '' && cld[d].lunarFestival == '')
455 festival = '';
456 else
457 festival = '<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>'+
458 '<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].solarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD>'+
459 '</TR></TABLE>';
460
461 s= '<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066"><TR><TD>' +
462 '<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#99CCFF" STYLE="font-size:9pt;">'+
463 cld[d].sYear+' 年 '+cld[d].sMonth+' 月 '+cld[d].sDay+' 日<br>星期'+cld[d].week+'<br>'+
464 '<font color="violet">农历'+(cld[d].isLeap?'闰 ':' ')+cld[d].lMonth+' 月 '+cld[d].lDay+' 日</font><br>'+
465 '<font color="yellow">'+cld[d].cYear+'年 '+cld[d].cMonth+'月 '+cld[d].cDay + '日</font>'+
466 '</FONT></TD></TR></TABLE>'+ festival +'</TD></TR></TABLE>';
467
468
469 document.all["detail"].innerHTML = s;
470
471 if (snow == 0) {
472 dStyle.left = x+offsetx-(width/2);
473 dStyle.top = y+offsety;
474 dStyle.visibility = "visible";
475 snow = 1;
476 }
477 }
478}
479
480//清除详细日期资料
481function mOut() { }
482
483//取得位置
484function mEvn() {
485 x=event.x;
486 y=event.y;
487 if (document.body.scrollLeft)
488 {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
489 if (snow){
490 dStyle.left = x+offsetx-(width/2)
491 dStyle.top = y+offsety
492 }
493}
494
495///////////////////////////////////////////////////////////////////////////
496
497function changeTZ() {
498 CITY.innerHTML = CLD.TZ.value.substr(6)
499 setCookie("TZ",CLD.TZ.selectedIndex)
500}
501
502function tick() {
503 var today
504 today = new Date()
505 Clock.innerHTML = today.toLocaleString().replace(/(年|月)/g, "/").replace(/日/, "");
506 Clock.innerHTML = TimeAdd(today.toGMTString(), CLD.TZ.value)
507 window.setTimeout("tick()", 1000);
508}
509
510function setCookie(name, value) {
511 var today = new Date()
512 var expires = new Date()
513 expires.setTime(today.getTime() + 1000*60*60*24*365)
514 document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString()
515}
516
517function getCookie(Name) {
518 var search = Name + "="
519 if(document.cookie.length > 0) {
520 offset = document.cookie.indexOf(search)
521 if(offset != -1) {
522 offset += search.length
523 end = document.cookie.indexOf(";", offset)
524 if(end == -1) end = document.cookie.length
525 return unescape(document.cookie.substring(offset, end))
526 }
527 else return ""
528 }
529}
530
531/////////////////////////////////////////////////////////
532
533function initial() {
534 dStyle = detail.style;
535 CLD.SY.selectedIndex=tY-1900;
536 CLD.SM.selectedIndex=tM;
537 drawCld(tY,tM);
538
539 CLD.TZ.selectedIndex=getCookie("TZ");
540 changeTZ();
541 tick();
542}
543
544
545
546//-->
547</SCRIPT>