Urgently need "Lunar JAVA Code"
Just copy the code to a new blank web page, don't look at the demo, the demo code is wrong. )
The code is as follows:
& lt scripting language = JavaScript & gt
& lt! -
/*****************************************************************************
Date information
*****************************************************************************/
Var lunarInfo = new array (
0x04bd8,0x04ae0,0570,0x054d5,0x0d260,0x0d950,0x 16554,0x056a0,0x09ad0,0x055d2,
0x04ae0,05b6,04d0,0x0d250,0x 1d255,0x0b540,0x0d6a0,0da2,0x095b0,0x 14977,
0x04970,04b0,0x0b4b5,0x06a50,0x06d40,0x 1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x 186e3,0x092e0,0x 1c8d7,0x0c950,
0x0d4a0,0x 1d8a6,0x0b550,0x056a0,0x 1a5b4,0x025d0,0x092d0,0x0d2b2,0950,0x0b557,
0x06ca0,0x0b550,0x 15355,0x04da0,05d0,0x 14573,0x052d0,09a8,0x0e950,0x06aa0,
0ea6,0b50,0x04b60,0ae4,0570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,
0x096d0,0x04dd5,0x04ad0,04d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x 195a6,
0x095b0,0x049b0,0974,04b0,0x0b27a,0x06a50,0x06d40,0f46,0b60,0x09570,
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0b60,0x096d5,0x092e0,
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0bb7,0x025d0,0x092d0,0x0cab5,
0950,0x0b4a0,0x 0ba 4,0d50,0x055d9,0x04ba0,05b0,0x 15 176,0x052b0,0930,
0x07954,0x06aa0,0d50,0x05b52,0x04b60,06e6,04e0,0x0d260,0x0ea65,0x0d530,
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,04d0,0x 1d0b6,0x0d250,0x0d520,0x0dd45,
0x0b5a0,0x056d0,0x055b2,0x049b0,0577,04b0,0a50,0x 1b255,0x06d20,0da0)
var solar month = new Array(3 1,28,3 1,30,3 1,30,3 1,30,3 1,30,3 1);
Var Gan = new array ("A", "B", "C", "D", "E", "Ji", "Geng", "Xin", "Man" and "Ghost");
Var Zhi = new array ("Zi", "Ugly", "Yin", "Mao", "Chen", "Si", "Wu", "Wei", "Shen", "You", "Xu" and "Hai");
Var Animals = new array ("mouse", "cow", "tiger", "rabbit", "dragon", "snake", "horse", "sheep", "monkey", "chicken", "dog" and "pig");
Var solarTerm = new array ("slight cold", "severe cold", "beginning of spring", "rain", "fright", "vernal equinox", "Qingming", "Grain Rain", "long summer", "small full", "awn seed", "summer solstice" and "slight summer heat".
var sTermInfo = new Array(0,2 1208,42467,63836,85337, 1070 14, 128867, 15092 1, 173 149, 1955565438
Var nStr 1 = new array ('days',' one',' two',' three',' four',' five',' six',' seven',' eight',' nine' and' ten').
Var nStr2 = new array ('early',' ten',' 20',' 30','')
Var monthName = new array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" and "December");
//National holidays * refers to holidays.
Var sFtv = new array (
0 10 1* new year's day,
02 14 valentine's day,
0308 Women's Day,
03 12 Arbor Day,
03 15 consumer rights day,
03 17 St. Patrick,
040 1 April fool's day,
050 1 labor day,
0504 Youth Day,
05 12 nurses' day,
"05 12 Yin Birthday",
060 1 Children's Day,
"06 14 flag selling day",
"070 1 Commemorating Hong Kong's Return to the Founding of the Party",
"0703 Huang Yan Online Birthday",
07 18 top's birthday,
080 1 Army Day,
Father's Day 0808,
0909 Mao Zedong Death Memorial Hall,
09 10 teacher's day,
"0928 Confucius' birthday",
100 1* National Day,
1006 festival for the elderly,
"1024 United Nations Day",
"1111veterans/memorial day",
1 1 12 Sun Yat-sen's birthday commemoration,
"1220 to commemorate the return of Macao",
1225 Christmas,
1226 Mao Zedong's birthday)
//Lunar Festival * means a holiday.
Var lFtv = new array (
"0 10 1* Spring Festival",
0 1 15 Lantern Festival,
0328 my birthday,
0505 Dragon Boat Festival,
"0707 Qixi Valentine's Day",
"07 15 mid-autumn festival",
"08 15 Mid-Autumn Festival",
0909 Double Ninth Festival,
1208 Laba Festival,
"1224 off-year",
"0 100* New Year's Eve")
//What day is a month?
Var wFtv = new array (
"0 13 1 Martin Luther king day",
023 1 President's Day,
"0520 Mother's Day",
"0530 Armed Forces Day",
053 1 Victoria Day,
07 16 cooperation festival,
"0730 enslaved country week",
08 1 1 public holiday,
09 1 1 labor holiday,
102 1 Columbus Day,
"1 144 Thanksgiving Day")
/*****************************************************************************
Date calculation
*****************************************************************************/
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Returns the total number of days in the Y year of the lunar calendar.
Function delay time (y) {
var i,sum = 348
for(I = 0x 8000; I & gt0x8 I>> =1) sum+= (lunarinfo [y-1900] & Me)? 1: 0
return(sum+leapDays(y))
}
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Returns the number of days in a leap month in Y year of the lunar calendar.
Function leapDays(y) {
if(leap month(y))return((lunar info[y- 1900]& amp; 0x 10000)? 30: 29)
Otherwise return (0)
}
//= = = = = = = = = = = = = = = = = = = = = = = = = Returns the month of the lunar leap year Y, that is, 1- 12, or 0 if there is no leap year.
Function leapMonth(y) {
return(lunar info[y- 1900]& amp; 0xf)
}
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Returns the total number of days in M months of the lunar year Y.
Function Months (y, m) {
return((lunar info[y- 1900]& amp; (0x 10000 & gt; & gtm))? 30: 29 )
}
//= = = = = = = = = = = = = = = = = = = = = Calculate the lunar calendar, pass in the date object, and return the lunar date object.
//The property of this object is .year.month.day.islam.yearcyl.daycyl.moncyl.
Function lunar (objdate) (
Variable I, leap=0, temp=0.
Var base date = new date (1900,0,31)
var offset =(objDate-baseDate)/86400000
this.dayCyl = offset + 40
this.monCyl = 14
for(I = 1900; I & lt2050 & amp& ampoffset & gt0; i++) {
temp = lYearDays(i)
Offset-= temperature
this.monCyl += 12
}
if(offset & lt; 0) {
offset+= temp;
I-;
this.monCyl -= 12
}
This year = me
this.yearCyl = i- 1864
Leap = leapMonth(i) // leap month?
this.isLeap = false
for(I = 1; I< 13. & ampoffset & gt0; i++) {
//leap month
if(leap & gt; 0 & amp& ampI = =(leap+ 1)& amp; & ampthis.isLeap==false)
{-I; this.isLeap = truetemp = leap days(this . year); }
other
{temp = monthDays (this year, I); }
//mention leap month
if(this . is leap = = true & amp; & ampI = =(leap+ 1))this . is leap = false
Offset-= temperature
if(this . is leap = = false)this . moncyl++
}
if(offset = = 0 & amp; & ampleap & gt0 & amp& ampi==leap+ 1)
If (this.isLeap)
{ this.isLeap = false}
other
{this.isreap = true-me; -this . moncyl; }
if(offset & lt; 0){ offset+= temp; -Me; -this . moncyl; }
This month = me
this.day = offset + 1
}
//= = = = = = = = = = = = = = = = = = = = = = = = = The number of days in a certain m+ 1 month in calendar year Y.
Function solarDays(y, m) (
If (m== 1)
return((y % 4 = = 0)& amp; & amp(y% 100! = 0) || (y%400 == 0))? 29: 28)
other
return(solarMonth[m])
}
//= = = = = = = = = = = = = = = = = = = = = = = The incoming offset returns to the main branch, and 0= Jiazi.
Cyclic Function (Quantity) (
Return (Gan [num% 10]+ Zhi [num% 12])
}
//= = = = = = = = = = = = = = = = = = = = = = Calendar attribute
Function calElement (year, month, day, week, year, month, day, month, day, year, month, day) {
this.isToday = false
//National calendar
this.sYear = sYear
this . sm onth = sm onth;
this.sDay = sDay
This.week = week;
//lunar calendar
this . ly ear = ly ear;
this.lMonth = lMonth
this.lDay = lDay
this . is leap = is leap;
//main branch
this . cy ear = cy ear;
this.cMonth = cMonth
this.cDay = cDay
this . color =“”;
this . lunar festival =“”; //Lunar New Year
this . solarfestival =“”; //National Calendar Festival
this . solarterms =“”; //solar terms
}
//= = = = How many days is the nth solar term in a certain year (starting from 0 slight cold)?
Function sTerm(y, n) {
Var offDate = new date ((31556925974.7 * (y-1900)+terminfo [n] * 60000)+date. UTC( 1900,0,6,2,5))
return(offDate.getUTCDate())
}
//= = = = = = = = = = = = = = Returns a calendar object (y year, m+ 1 month).
Function calendar (y, m) {
var sDObj,lDObj,lY,lM,lD= 1,lL,lX=0,tmp 1,tmp2
Var lDPOS = new array (3)
var n = 0
var firstLM = 0
SDObj = new Date(y, m, 1) // the date of the current month.
This.length = solarDays(y, m) // The number of days in the current month in the national calendar.
This.firstweek = sdobj.getday ()/1What is the date in the national calendar?
for(var I = 0; I & ltthis. Length; i++) {
if(lD & gt; lX) {
SDObj = new Date(y, m, i+ 1) // the date of the current month.
LDObj = new Lunar(sDObj) // lunar calendar
LY = lDObj.year // Lunar New Year
LM = lDObj.month // lunar month
LD = lDObj.day // lunar calendar day
LL = lDObj.isLeap // Is the lunar calendar a leap month?
lX = lL? Leap day (ly): the day of the month (ly, lm)// the last day of the lunar month.
if(n==0) firstLM = lM
lDPOS[n++] = i-lD+ 1
}
//year, month, day, week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
this[i] = new calElement(y,m+ 1,i+ 1,nstr 1[(I+this . first week)% 7),
lY,lM,lD++,lL,
circular(ldobj . year cyl)、circular(ldobj . moncyl)、circular(ldobj . day cyl++))
If ((I+this. firstweek)% 7 = = 0) this [I]。 Color =' red'/ Sunday color
If ((I+this. First week)%14 = =13) This [me]. Take two days off at the weekend.
}
//solar terms
tmp 1=sTerm(y,m*2 )- 1
tmp2=sTerm(y,m*2+ 1)- 1
This [tmp 1]. solarTerms = solarTerm[m*2]
This [tmp2]. solarTerms = solarTerm[m * 2+ 1]
If (m = = 3) this [tmp 1]。 Color =' red'/Qingming color.
//National Calendar Festival
For (I am at 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 '
}
//Month and week festivals
For (I'm at wFtv)
if(wFtv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/))
if(Number(RegExp。 $ 1)==(m+ 1)) {
tmp 1=Number(RegExp。 $2)
tmp2=Number(RegExp。 $3)
This is the first week. tmp2)? 7:0)+7 *(tmp 1- 1)+tmp 2-this . first week】。 solarFestival += RegExp。 $5 + ' '
}
//Lunar New Year
For (I'm at lFtv)
if(lFtv[i].match(/^(\d{2})(.{2})([\s\*])(。 +)$/)) {
tmp 1=Number(RegExp。 $ 1)- the first LM
if(tmp 1 = =- 1 1)tmp 1 = 1
if(tmp 1 & gt; = 0 & amp& amptmp 1 & lt; n) {
tmp 2 = lDPOS[tmp 1]+Number(RegExp。 $2) - 1
if(tmp 2 & gt; = 0 & amp& amptmp2 & ltthis . length)}
This [tmp2]. lunarFestival += RegExp。 $4 + ' '
if(RegExp。 $3 =' *') This [tmp2]. color = 'red '
}
}
}
//Black Friday
if((this . first week+ 12)% 7 = = 5)
This [12]. SolarFestival +=' Black Friday'
//Today
if(y = = tY & amp; & ampm==tM) this [tD- 1]. isToday = true
}
//= = = = = = = = = China date
Function cDay(d){
var s;
Switch (d)
Case 10:
S =' Day 10'; Break;
Case 20:
S =' twenty'; Break;
Break;
Case 30:
S =' thirty'; Break;
Break;
Default value:
s = nstr 2[math . floor(d/ 10)];
s+= nstr 1[d % 10];
}
Return order;
}
///////////////////////////////////////////////////////////////////////////////
var cld
Function drawCld(SY, sm) (
var i,sD,s,size
Cld = new calendar (SY, sm);
if(SY & gt; 1874。 & ampSY & lt 1909) yDisplay =' Guangxu' +((SY- 1874) = = 1)? Yuan: SY- 1874)
if(SY & gt; 1908。 & ampsy & lt1912) ydisplay =' Xuan Tong'+((sy-1908) =1)? Yuan': SY- 1908)
if(SY & gt; 19 1 1。 & ampSY & lt 1950) yDisplay =' Republic of China'+((sy-191) =1)? Yuan': SY- 19 1 1)
//if(SY & gt; 1949) y display =' * * and China'+((sy-1949) =1)? Yuan: SY- 1949)
// GZ.innerHTML = yDisplay+' Lunar Calendar'+Cycle (SY- 1900+36)+' Year'+Animals [(SY-4)%12]+'';
if(SY & gt; 1949) yDisplay = ' '
GZ.innerHTML = yDisplay+' Lunar Calendar'+Cycle (SY- 1900+36)+' Year'+Animals [(SY-4)%12]+'';
YMBG.innerHTML = "? +SY+" & lt; BR & gt? "+month name[SM];
for(I = 0; I & lt42; i++) {
sObj = eval(' SD '+I);
lObj = eval(' LD '+I);
sobj . class name =“”;
sD = I-CLD . first week;
if(sD & gt; - 1 & amp; & ampsD & ltCld.length) {// within the date.
sobj . innerhtml = sD+ 1;
if(cld[sD])。 isto day)sobj . class name = ' todyaColor '; //Today's color
sObj.style.color = cld[sD]。 Color; //national holiday colors
If(cld[sD])。 LDay = =1)/Displays the lunar month.
lObj.innerHTML = ' & ltb & gt'+(cld[sD]。 isLeap? leap ':')+CLD[sD]。 lMonth+' Month '+(Month days(CLD[SD])。 Lyle, CLD LMONTH) = = 29? Small':' big')+'
Else // Show Lunar New Year
lObj.innerHTML = cDay(cld[sD])。 lDay);
S = CLD[ SD]. lunarFestival
if(s . length & gt; 0) {// Lunar Festival
if(s . length & gt; 6) s = s.substr(0,4)+'…';
s = s . font color(' red ');
}
Else {// National Calendar Festival
S = CLD[ SD]. solarFestival
if(s . length & gt; 0) {
size = (s.charCodeAt(0)>0 & amp& amps . charcodeat(0)& lt; 128)? 8:4;
if(s . length & gt; size+2) s = s.substr(0,size)+'…';
s = s . font color(' blue ');
}
Else {// 24 solar terms
S = CLD[ SD]. solarTerms
if(s . length & gt; 0)s = s . font color(' lime green ');
}
}
if(s . length & gt; 0)lobj . innerhtml = s;
}
Else {// Non-date
sobj . innerhtml =“”;
lobj . innerhtml =“”;
}
}
}
Function changeLong ()
{
Variables y, m, ly, lm, id, im, iy, yangy, yangm, deltm, miny, TT;
CLD。 CLD。 d 1 . selectedindex;
CLD。 CLD。 D2.selectedIndex
yangm = 0; yangy = 0;
TT = true;
while (tt)
{
yangm = 0; yangy = 0;
change CLD();
for(I = 0; I & lt42; i++)
{
sD = I-CLD . first week;
if(sD & gt; - 1 & amp; & ampsD & ltcld. Length)
Within {//date
if ((cld[sD])。 CLD。 D2 . selectedindex+ 1)& amp; & amp(cld[sD]。 Lyle ==CLD. d 1 . selectedindex+ 1900))
{
Yang =CLD. sy . selectedindex+ 1900; Yang =CLD. SM.selectedIndex
TT = false;
Break;
}
}
}
If (! Tt) break through;
push TM(' MD ');
change CLD();
//alert (CLD. SY.selectedIndex+" "+CLD。 sm . selectedindex);
for(I = 0; I & lt42; i++)
{
sD = I-CLD . first week;
if(sD & gt; - 1 & amp; & ampsD & ltcld. Length)
Within {//date
if ((cld[sD])。 CLD。 D2 . selectedindex+ 1)& amp; & amp(cld[sD]。 Lyle ==CLD. d 1 . selectedindex+ 1900))
{
Yang =CLD. sy . selectedindex+ 1900; Yang =CLD. SM.selectedIndex
TT = false;
Break;
}
}
}
Break;
}
//alert(yangy+" "+yangm);
//CLD。 SY.selectedIndex = yangy//- 1900;
//push TM(' YU ');
//push TM(' YD ');
CLD。 SM.selectedIndex = yangm
push TM(' MD ');
push TM(' MU ');
}
//changeLong end
Function changeCld() {
var y,m;
y=CLD。 sy . selectedindex+ 1900;
m=CLD。 SM.selectedIndex
drawCld(y,m);
}
Function pushtm (k) (
Switch (k)
Case' Yu':
If (CLD. SY.selectedIndex & gt0) CLD。 sy . selectedindex-;
Break;
Case "YD":
If (CLD. SY.selectedIndex & lt 149) CLDsy . selectedindex++;
Break;
Case "Management Department":
If (CLD. SM.selectedIndex & gt0) {
CLD。 sm . selectedindex-;
}
Otherwise {
CLD。 sm . selectedindex = 1 1;
If (CLD. SY.selectedIndex & gt0) CLD。 sy . selectedindex-;
}
Break;
Case "MD":
If (CLD. SM.selectedIndex & lt 1 1) {
CLD。 sm . selectedindex++;
}
Otherwise {
CLD。 sm . selectedindex = 0;
If (CLD. SY.selectedIndex & lt 149) CLDsy . selectedindex++;
}
Break;
Default value:
CLD。 sy . selectedindex = tY- 1900;
CLD。 SM.selectedIndex = tM
}
change CLD();
}
var Today = new Date();
var tY = today . get full year();
var tM = today . getmonth();
var tD = today . getdate();
//////////////////////////////////////////////////////////////////////////////
var width = " 130 ";
var offsetx = 2;
var off sety = 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, festivals;
var sObj = eval(' SD '+v);
var d = sobj . innerhtml- 1;
//year, month, day, week,
//lYear,lMonth,lDay,isLeap,
//cYear,cMonth,cDay
if(sObj.innerHTML! ='') {
sobj . style . cursor = ' s-resize ';
if(cld[d]。 solarTerms = = ' ' & amp& ampcld[d]。 solarFestival = = ' ' & amp& ampcld[d]。 lunarFestival == ' ')
festival =“”;
other
Festival ='< Table width =100% border = 0cell padding = 2cell spacing = 0bgcolor = "# CCFFCC" > & ltTR & gt& lt“TD & gt”+
& ltFONT COLOR = " # 000000 " STYLE = " FONT-size:9pt;" & gt+cld[d]。 solarTerms + ' ' + cld[d]。 solarFestival + ' ' + cld[d]。 lunar festival+' & lt; /FONT & gt; & lt/TD & gt; +
& lt/TR & gt; & lt/TABLE & gt; ';
s = ' & ltTABLE WIDTH = " 130 " BORDER = 0 cell padding = " 2 " cell spacing = 0 BGCOLOR = " # 000066 " >& ltTR & gt& lt“TD & gt”+
& lt table width = 100% BORDER=0 cell filling =0 cell spacing = 0> & lttr & gt & lttdalign = "right" >< font color = "# ffffff" style = "font-size: 9pt;" & gt+
Cld[d]。 sYear+' year' +cld[d]。 sMonth+' month' +cld[d]。 SDay+' day < br> week' +CLD [d]. Week+'
& ltfont color="violet "> lunar calendar' +(CLD [d]. islap? Leap':'') +cld[d]。 lMonth+' month' +cld[d]。 lDay+' day +cld[d]。 cYear+' Year' +cld[d]。 cMonth+' Month' +cld[d]。 CDay+' days
& ltTABLE width = " 672 " align = " right " height = " 259 " bordercolordark = " # cc 9900 " border = " 4 " background = " l 1 1 . gif " & gt;
& lt center & gt
& lt center & gt
& ltTBODY & gt
& lt/center & gt; & lt/center & gt;
& ltTR & gt
& ltTD align = middle vAlign = top width = " 170 " height = " 255 " >
& ltdiv align="center " >
& lt center & gt
& lt table border =1colspan = 2width = "221">
& lt center & gt
& lt center & gt& lt font size =2
style="FONT-SIZE: 9pt " >
& lttd width="209 " >
& ltp align="center " >& ltfont style = " font-size: 10.8 pt " color = RED & gt。 Local computer time:
id=Clock size=3 align="center " >& lt/FONT & gt;
& ltP & gt& lt! -Time zone * means automatic adjustment to daylight saving time->
& lt/center & gt;
& lt/CENTER & gt;
& lt/TABLE & gt;
& lt/center & gt;
& lt/div & gt;
& ltdiv align="center " >
& lt center & gt
& lt table border =1height = "1"width = "16" >
& lttd height=" 1" width="255 " >
& lt table width = "212" height = "1">< center & gt
& lt center & gt
& ltFONT id=tSave
Style="COLOR: red; Font family: Wingdings font