Provides a good Perpetual calendar Query
<HTML> <HEAD> <TITLE> q jiayuan _ another great Perpetual calendar query </TITLE> <META http-equiv = Content-Type content = "text/html; charset = gb2312 "> <STYLE type = text/css> BODY {FONT-SIZE: 14px; SCROLLBAR-HIGHLIGHT-COLOR: buttonface; SCROLLBAR-SHADOW-COLOR: buttonface; COLOR: #333333; SCROLLBAR-3DLIGHT-COLOR: buttonhighlight; SCROLLBAR-TRACK-COLOR: # eeeeee; FONT-FAMILY: "Times New Roman", ""; SCROLLBAR-DARKSHADOW-COLOR: buttonshadow} TD {FONT-SIZE: 14px; COLOR: #333333 }. input1 {BORDER-RIGHT: # cccccc 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: # cccccc 1px solid; PADDING-LEFT: 1px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: # cccccc 1px solid; CURSOR: text; COLOR: #333333; PADDING-TOP: 1px; BORDER-BOTTOM: # cccccc 1px solid; FONT-FAMILY: "Times New Roman", ""; HEIGHT: 24px }</STYLE> <SCRIPT language = JavaScript> <! -- Function click () {if (event. button = 2) {// return (0); alert ('Welcome to the Perpetual calendar system! ') ;}} Document. onmousedown = click // --> SCRIPT <SCRIPT language = JavaScript> <! -- Var lunarInfo = new Array (0x04bd8, 0x04ae0, primary, 0x054d5, 0x0d260, 0x0d950, 0x16554, primary, 0x09ad0, 0x055d2, 0x04ae0, primary, primary, 0x0d250, primary, values, numbers, 0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566, primary, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, primary, 0x0c950, primary, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, primary X092d0, 0x0d2b2, numbers, numbers, 0x06ca0, 0x0b550, 0x15355, 0x04da0, numbers, 0x14573, numbers, numbers, 0x06aa0, 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, primary, 0x05260, primary, 0x0d950, 0x05b57, 0x056a0, 0x096d0, 0x04dd5, 0x04ad0, primary, primary, 0x0d250, primary, primary, 0x0b5a0, 0x195a6, primary, primary, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06 B58, 0x055c0, 0x0ab60, primary, primary, 0x0c960, 0x0d954, primary, 0x0da50, 0x07552, 0x056a0, 0x0abb7, primary, primary, 0x0cab5, primary, primary, 0x0baa4, primary, primary, 0x04ba0, primary, 0x15176, primary, primary, 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, primary, primary, 0x0d260, 0x0ea65, primary, 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, primary, 0x0dd45, 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0) var solarMonth = new Array (, 31, 31); var Gan = new Array ("", "B", "C", "ding", "E", "Ji", "Geng", "Xin", "Xi", "Xi "); var Zhi = new Array ("sub", "ugly", "Yin", "Mao", "Chen", "Si", "Wu", "wei ", "shen", "you", "shen", "Hai"); var Animals = new Array ("rat", "Ox", "Tiger", "rabbit ", "Dragon", "snake", "horse", "goat", "monkey", "chicken", "dog", "Swine "); var solarTerm = new Array ("Xiao Han", "da Han", "Li Chun", "Rain", "Jing zhe", "Spring Equinox", "Qingming", "Gu Yu ", "Summer", "small full", "Mountain", "Summer Solstice", "Small Heat", "great heat", "Autumn", "Summer heat", "White Dew", "Autumn Equinox", "Cold Dew", "frost", "Winter", "light snow", "heavy snow ", "") var sTermInfo = new Array (, California) var nStr1 = new Array ('day', 'yi', '2', '3', '4', '5', '6', '7 ', '8', '9', '10') var nStr2 = new Array ('chu', '10', 'hangzhou', 'hangzhou ','') // var monthName = new Array ("JAN", "FEB", "MAR", "APR ", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC "); var monthName = new Array ("1", "2", "3", "4", "5", "6", "7", "8 ", "9", "10", "11", "12"); var sFtv = new Array ("0101 * new Year's Day", "0214 Valentine's Day", "0308 Women's Day ", "0312 tree planting Festival", "0315 Consumer Rights Day", "0401 fools", "0501 Labor Day", "0504 Youth Day", "0512 nurse's Day", "0601 Children's Day ", "0701 founding Party Day Hong Kong return to commemorate", "0703 yanhuang Online's birthday", "0718 topic's birthday", "0801 Jianjun's Day", "0808 Father's Day", "0909 Mao Zedong's death memorial ", "0910 Teachers' Day", "0928 Confucius 'birthday", "1001 * National Day", "10 06 lao shu "," 1024 United Nations Day "," 1112 sun yat-sen's birthday "," 1220 Macao return memorial "," 1225 Christmas Day "," 1226 forbidden's birthday memorial ") var lFtv = new Array ("0101 * Spring Festival", "0115 Lantern Festival", "0505 Dragon Boat Festival", "0707 Valentine's Day", "0715 Mid-Autumn Festival", "0815 Mid-Autumn Festival ", "0909 Double Ninth Festival", "1208 lable Festival", "1224 ", "0100 * new Year's Eve") var wFtv = new Array ("0131 Martin Luther King Day ", "0231 President's Day", "0520 Mother's Day", "0530 Armed Forces Day", "0531 Victoria Day", "0716 Cooperation Day", "0730 slavery country Week ", 0811 Civic Holiday "," 0911 Labor Holiday "," 1021 Columbus Day "," 1144 Thanksgiving Day ") function lYearDays (y) {var I, sum = 348 for (I = 0x8000; I> 0x8; I >>= 1) sum + = (lunarInfo [y-1900] & I )? 1: 0 return (sum + leapDays (y)} function leapDays (y) {if (leapMonth (y) return (lunarInfo [y-1900] & 0x10000 )? 30: 29) else return (0)} function leapMonth (y) {return (lunarInfo [y-1900] & 0xf)} function monthDays (y, m) {return (lunarInfo [y-1900] & (0x10000> m ))? 30: 29)} 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 = lYearDays (I) offset-= temp this. monCyl + = 12} if (offset <0) {offset + = temp; I --; this. monCyl-= 12} 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 = t Rue; -- I; -- this. monCyl;} if (offset <0) {offset + = temp; -- I; -- this. monCyl;} this. month = I this. day = offset + 1} function solarDays (y, m) {if (m = 1) return (y % 4 = 0) & (y % 100! = 0) | (y % 400 = 0 ))? 29: 28) else return (solarMonth [m])} function semantic ical (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 = ''; // lunar festival this. solarFestival = ''; // calendar festival this. solarTerms = ''; // solar term} function sTerm (y, n) {var offDate = new Date (31556925974.7 * (y-1900) + sTermInfo [n] * 60000) + Date. UTC (, 5) return (offDate. getUTCDate ()} 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) // the current month's day Date this. length = solarDays (y, m) // number of days in the calendar month this. firstWeek = sDObj. getDay () // The Day of the day of the month in the country calendar for (var I = 0; I <this. length; I ++) {if (lD> lX) {sDObj = new Date (y, m, I + 1) // Date of the current month (lDObj = new Lunar (sDObj) // lunar lY = lDObj. year // year lM = lDObj. month // lunar month lD = lDObj. day // lunar day lL = lDObj. isLeap // is the lunar calendar a leap month 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, semantic ical (lDObj. yearCyl), semantic ical (lDObj. monCyl), logical ical (lDObj. dayCyl ++) if (I + this. firstWeek) % 7 = 0) this [I]. color = 'red' // Sunday color if (I + this. firstWeek) % 14 = 13) this [I]. color = 'red' // two-day week color} 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' // clear color 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) ([\ s \ *]) (. +) $/) if (Number (RegExp. $1) = (m + 1) {tmp1 = Number (RegExp. $2) tmp2 = Number (RegExp. $3) this [(this. firstWeek> tmp2 )?) + 7 * (tmp1-1) + tmp2-this. firstWeek]. solarFestival + = RegExp. $5 + ''} // lunar holiday 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 <n) {tmp2 = lDPOS [tmp1] + Number (RegExp. $2)-1 if (tmp2> = 0 & tmp2 <this. length) {this [tmp2]. lunarFestival + = RegExp. $4 + ''if (RegExp. $3 = '*') this [tmp2]. color = 'red '}}} // Black Friday if (this. firstWeek + 12) % 7 = 5) this [12]. solarFestival + = 'Black Friday' // Today if (y = tY & m = tM) this [tD-1]. isToday = true ;}//========================== Chinese Date function cDay (d) {var s; switch (d) {case 10: s = '10'; break; case 20: s = 'two'; break; case 30: s = '30'; break; break; default: s = nStr2 [Math. floor (d/10)]; s + = nStr1 [d % 10];} return (s );} //////////////////////////////////////// /// /// // Var cld; function drawCld (SY, SM) {var I, sD, s, size; cld = new calendar (SY, SM); if (SY> 1874 & SY <1909) yDisplay = 'guangxu '+ (SY-1874) = 1 )? 'Meta': SY-1874) if (SY> 1908 & SY <1912) yDisplay = 'xuantong '+ (SY-1908) = 1 )? 'Meta': SY-1908) if (SY> 1911 & SY <1950) yDisplay = 'Republic of China '+ (SY-1911) = 1 )? 'Meta': SY-1911) // if (SY> 1949) yDisplay = 'Republic '+ (SY-1949) = 1 )? 'Meta': SY-1949) // GZ. innerHTML = yDisplay + 'Year' + ical (SY-1900 + 36) + 'Year' ('+ Animals [(SY-4) % 12] +') '; if (SY> 1949) yDisplay = ''GZ. innerHTML = yDisplay + 'lunar calendar '+ ical (SY-1900 + 36) + 'year (' + Animals [(SY-4) % 12] + ')'; YMBG. innerHTML = SY + "year" + monthName [SM] + "month"; for (I = 0; I <42; I ++) {sObj = eval ('sd' + I); lObj = eval ('ld '+ I); sObj. className = ''; sD = I-cld. firstWeek; if (sD>-1 & sD <cld. length) {sObj. InnerHTML = sD + 1; if (cld [sD]. isToday) sObj. className = 'todyacolor'; sObj. style. color = cld [sD]. color; if (cld [sD]. lDay = 1) lObj. innerHTML = '<B>' + (cld [sD]. isLeap? 'Month': '') + cld [sD]. lMonth + 'month' + (monthDays (cld [sD]. lYear, cld [sD]. lMonth) = 29? '小': 'day') + '</B>'; else lObj. innerHTML = cDay (cld [sD]. lDay); s = cld [sD]. lunarFestival; if (s. length> 0) {if (s. length> 6) s = s. substr (0, 4) + '... '; S = s. fontcolor ('red');} else {// calendar Festival s = cld [sD]. solarFestival; if (s. length> 0) {size = (s. charCodeAt (0)> 0 & s. charCodeAt (0) <128 )? 8: 4; if (s. length> size + 2) s = s. substr (0, size) + '... '; S = s. fontcolor ('Blue ');} else {// s = cld [sD]. solarTerms; if (s. length> 0) s = s. fontcolor ('limegreen') ;}} if (s. length> 0) lObj. innerHTML = s;} else {// non-date sObj. innerHTML = ''; lObj. innerHTML = '';}} function changeLong () {var y, m, ly, lm, id, im, iy, yangy, yangm, deltm, miny, tt; CLD. SY. selectedIndex = CLD. d1.selectedIndex; CLD. SM. selectedIndex = CLD. d2.selectedIndex; yangm = 0; yangy = 0; tt = true; wh Ile (tt) {yangm = 0; yangy = 0; changeCld (); for (I = 0; I <42; I ++) {sD = I-cld. firstWeek; if (sD>-1 & sD <cld. length) {// if (cld [sD] In the date. lMonth = CLD. d2.selectedIndex + 1) & (cld [sD]. lYear = CLD. d1.selectedIndex + 1900) {yangy = CLD. SY. selectedindex+ 1900; yangm = CLD. SM. selectedIndex; tt = false; break ;}} if (! Tt) break; pushBtm ('md'); changeCld (); // alert (CLD. SY. selectedIndex + "" + CLD. SM. selectedIndex); for (I = 0; I <42; I ++) {sD = I-cld. firstWeek; if (sD>-1 & sD <cld. length) {// if (cld [sD] In the date. lMonth = CLD. d2.selectedIndex + 1) & (cld [sD]. lYear = CLD. d1.selectedIndex + 1900) {yangy = CLD. SY. selectedindex+ 1900; yangm = CLD. SM. selectedIndex; tt = false; break ;}} break ;}// alert (yangy + "" + yangm); // CLD. SY. sele CtedIndex = yangy; //-1900; // pushBtm ('yu '); // pushBtm ('yd'); CLD. SM. selectedIndex = yangm; pushBtm ('md'); pushBtm ('mu ');} // changeLong end function changeCld () {var y, m; y = CLD. SY. selectedindex+ 1900; m = CLD. SM. selectedIndex; drawCld (y, m);} function pushBtm (K) {switch (K) {case 'yu ': if (CLD. SY. selectedIndex> 0) CLD. SY. selectedIndex --; break; case 'yd ': if (CLD. SY. selectedIndex <149) CLD. SY. selectedInd Ex ++; break; case 'mu ': if (CLD. SM. selectedIndex> 0) {CLD. SM. selectedIndex --;} else {CLD. SM. selectedIndex = 11; if (CLD. SY. selectedIndex> 0) CLD. SY. selectedIndex --;} break; case 'md': if (CLD. SM. selectedIndex <11) {CLD. SM. selectedIndex ++;} else {CLD. SM. selectedIndex = 0; if (CLD. SY. selectedIndex <149) CLD. SY. selectedIndex ++;} break; default: CLD. SY. selectedIndex = tY-1900; CLD. SM. selectedIndex = tM ;} ChangeCld ();} 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; document. onmousemove = mEvn; // display detailed date information function mOvr (v) {var s, festiva L; var sObj = eval ('sd' + v); var d = sObj. innerHTML-1; // sYear, sMonth, sDay, week, // lYear, lMonth, lDay, isLeap, // cYear, cMonth, cDay if (sObj. innerHTML! = '') {SObj. style. cursor ='s-resize '; if (cld [d]. solarTerms = ''& cld [d]. solarFestival = ''& cld [d]. lunarFestival = '') festival = ''; else festival = '<table width = 100% BORDER = 0 CELLPADDING = 4 CELLSPACING = 0 BGCOLOR = "#333333"> <TR> <td align = "RIGHT">' +'' + cld [d]. solarTerms + ''+ cld [d]. solarFestival + ''+ cld [d]. lunarFestival + '</TD>' + '</TR> </TABLE>'; s = '<table width = "140" BORDER = 0 CELLPAD DING = "0" CELLSPACING = 0 BGCOLOR = "#000099"> <TR> <TD> '+' <table width = 100% BORDER = 0 CELLPADDING = 4 CELLSPACING = 0> <TR> <td align = "RIGHT" nowrap> '+ cld [d]. sYear + 'Year' + cld [d]. sMonth + 'month' + cld [d]. sDay + 'day Week' + cld [d]. week + ''+ 'lunar calendar '+ (cld [d]. isLeap? 'Region': '') + cld [d]. lMonth + 'month' + cld [d]. lDay + 'day' + ''+ cld [d]. cYear + 'Year' + cld [d]. cMonth + 'month' + cld [d]. cDay + 'day' + '</TD> </TR> </TABLE>' + festival + '</TD> </TR> </TABLE>'; document. all ["detail"]. innerHTML = s; if (snow = 0) {dStyle. left = x + offsetx-(width/2); dStyle. top = y + offsety; dStyle. visibility = "visible"; snow = 1 ;}}// clear detailed date information function mOut () {if (cnt> = 1) {sw = 0} if (sw = 0) {snow = 0; DStyle. visibility = "hidden";} else cnt ++;} // gets the position function mEvn () {x = event. x; y = event. y; if (document. body. scrollLeft) {x = event. x + document. body. scrollLeft; y = event. y + document. body. scrollTop;} if (snow) {dStyle. left = x + offsetx-(width/2) dStyle. top = y + offsety }}///////////////////////////////// //////////////////////////////////////// // function tick () {var today = new Date () Clock. inne RHTML = today. toLocaleString (). replace (/(Year | month)/g ,"/"). replace (/day/, ""); // Clock. innerHTML = TimeAdd (today. toGMTString (), CLD. TZ. value) window. setTimeout ("tick ()", 1000);} 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 ()} functi On 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; CLD. SY. selectedIndex = tY-1900; CLD. SM. selectedIndex = tM; drawCld (tY, tM); // CLD. TZ. selectedIndex = getCookie ("TZ"); // changeTZ (); tick () ;}// --> SCRIPT <STYLE>. todyaColor {BACKGROUND-COLOR: #99ff00} </STYLE> <META content = "MSHTML 6.00.2800.1106" name = GENERATOR> </HEAD> <BODY oncontextmenu = self. event. returnValue = false bgColor = beige leftMargin = 0 topMargin = 0 onload = initial ()> <TABLE height = "100%" cellSpacing = 0 cellPadding = 0 width = "100%" align = center border = 0> </TBODY> </TABLE> </BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]