JS output lunar calendar, Gregorian calendar, year, month, Zhou Xi example code _javascript tips

Source: Internet
Author: User
Tags getdate microsoft frontpage

Copy Code code as follows:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta content= "Microsoft FrontPage 4.0" >
<meta content= "FrontPage.Editor.Document" >
<style type= "Text/css" >
<!--TD {font-size:9pt font-family: Song Body}
--></style>
<title></title>
<script type= "Text/javascript" >
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 animals=new Array ("Rat", "ox", "Tiger", "Rabbit", "dragon", "Snake", "horse", "sheep", "monkey", "Chicken", "dog", "pig");
var gan=new Array ("A", "B", "C", "Ding", "E", "Self", "Geng", "Xin", "Ren", "GUI");
var zhi=new Array ("Zi", "ugly", "Yin", "Mao", "Chen", "Si", "Afternoon", "not", "Shen", "unitary", "Xu", "Hai");
var now = null;
var SY = null;
var SM = null;
var SD = null;
function Getdatelist (YY,MM,DD) {
if (yy) {
now= New Date (yy, MM, DD);
}else{
now = new Date ();
}
SY = Now.getfullyear ();
SM = Now.getmonth ();
SD = Now.getdate ();
return Setcalendar ();
}
= = Incoming offset returns Ganzhi, 0 = Jia Zi
function cyclical (num) {return (gan[num%10]+zhi[num%12])}

= = The total number of days returned to the lunar year Y
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))
}

= = The number of days to return the lunar calendar y-year leap
function Leapdays (y) {
if (Leapmonth (y)) return ((lunarinfo[y-1900] & 0x10000)? 30:29)
else return (0)
}

= = To return to the lunar calendar y year 1-12, no leap back to 0
function Leapmonth (y) {return (lunarinfo[y-1900] & 0xf)}

====================================== returns the total number of days of the lunar calendar Y-year m-months
function Monthdays (y,m) {return (lunarinfo[y-1900] & (0x10000>>m)) 30:29)}

= = Calculate the lunar calendar, incoming Date object, return the Lunar date object
The object property has. Year month. Isleap. yearcyl. daycyl. moncyl
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)//leap which month
This.isleap = False

For (I=1 i<13 && offset>0; i++) {
Leap
if (leap>0 && i== (leap+1) && this.isleap==false)
{I. THIS.ISLEAP = true; temp = Leapdays (this.year);}
Else
{temp = Monthdays (this.year, i);}

Lift Leap Month
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;--this.moncyl;}

if (offset<0) {offset = temp;--this.moncyl;

This.month = i
This.day = offset + 1
}

function YYMMDD () {
var cl = ' <font color= ' #0000df ' style= ' font-size:9pt; > ';
if (now.getday () = = 0) cl = ' <font color= ' #c00000 "style=" FONT-SIZE:9PT; " > ';
if (now.getday () = = 6) cl = ' <font color= ' #00c000 "style=" FONT-SIZE:9PT; " > ';
Return (cl+sy+ ' year ' + (sm+1) + ' month ' +sd+ ' Day </font> ');
}
Function Weekday () {
var day = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var cl = ' <font color= ' #ff0000 ' style= ' font-size:9pt; > ';
if (now.getday () = = 0) cl = ' <font color= ' #c00000 "style=" FONT-SIZE:9PT; " > ';
if (now.getday () = = 6) cl = ' <font color= ' #00c000 "style=" FONT-SIZE:9PT; " > ';
Return (cl+ day[now.getday ()]+ ' </font> ');
}
= = Chinese Date
function Cday (m,d) {
var nStr1 = new Array (' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six ', ' seven ', ' eight ', ' nine ', ' ten ');
var nStr2 = new Array (' early ', ' ten ', ' 20 ', ' 30 ', ');
var s;
if (m>10) {s = ' ten ' +nstr1[m-10]} else {s = nstr1[m]} s + = ' month '
Switch (d) {
Case 10:s + = ' decade '; Break
Case 20:s + = ' 20 '; Break
Case 30:s + = ' 30 '; Break
Default:s + + Nstr2[math.floor (D/10)]; s + + nstr1[d%10];
}
return (s);
}
function SolarDay1 () {
var sdobj = new Date (SY,SM,SD);
var ldobj = new Lunar (sdobj);
var cl = ' <font color= ' violet ' style= ' font-size:9pt; > ';
var tt = ' "' +animals[(SY-4)%12]+ '" ' +cyclical (ldobj.moncyl) + ' month ' +cyclical (ldobj.daycyl++) + ' Day ';
Return (cl+tt+ ' </font> ');
}
function SolarDay2 () {
var sdobj = new Date (SY,SM,SD);
var ldobj = new Lunar (sdobj);
var cl = ' <font color= ' #000066 ' style= ' font-size:9pt; > ';
Lunar New Year BB ' + (cld[d].isleap? ') Leap ': ' +cld[d].lmonth+ ' month ' +cld[d].lday+ ' Day
var tt = cyclical (sy-1900+36) + ' year ' +cday (Ldobj.month,ldobj.day);
Return (cl+tt+ ' </font> ');
}
function SolarDay3 () {
var sterminfo = new Array ( 0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,3974 47,419210,440795,462224,483532,504758)
var solarterm = new Array ("Xiaohan", "Dahan", "Spring", "rainwater," insects "," vernal Equinox "," Qingming "," Rain "," Summer "," Xiaoman "," grain "," Summer solstice "," slight heat "," Great Heat "," beginning of Autumn "," Chushu "," Lu "," Autumnal Equinox " "," Dew "," Frost "," Winter "," Snow "," Snow "," Winter Solstice ")
var lftv = new Array ("0101* Spring Festival", "0115 Lantern Festival", "0505 Dragon Boat Festival", "7,077 St. Valentine's Day", "0715 Zhongyuanjie", "0815 Mid-Autumn Festival", "0909 Double Ninth Festival", "1208 Laba Festival", "1224 Year", "0 100* New Year's Eve ")
var SFTV = new Array ("0101* New Year's Day", "0214 Valentine", "0308 Women's Day", "0312 Arbor Day", "0315 Consumer equity Days",
"0401 April Fools", "0501 Labor Day", "0504 Youth Festival", "0512 Nurses ' section", "0601 children's Day", "0701 Party Building, Hong Kong reunification Memorial",
"0801 army", "0808 Father's Day", "0908 Mao Birthday", "0909 Mao Zedong's death commemoration", "0910 Teachers Day", "0928 Confucius ' Birthday", "1001* National holiday",
"1006 old people's Day", "1001 Listenwind Birthday", "1024 un Day", "1112 Sun Yat-sen's Birthday", "1220 Macao Return Commemoration", "1225 Christmas", "1226 Mao Zedong's Birthday")

var sdobj = new Date (SY,SM,SD);
var ldobj = new Lunar (sdobj);
var ldpos = new Array (3)
var festival= ', solarterms= ', solarfestival= ', lunarfestival= ', TMP1,TMP2;
Lunar Festival
For (i in LFTV)
if (Lftv[i].match/^ (/d{2}) (. { 2}) ([/s/*]) (. +) $/)) {
Tmp1=number (regexp.$1)-ldobj.month
Tmp2=number (regexp.$2)-ldobj.day
if (tmp1==0 && tmp2==0) lunarfestival=regexp.$4
}
National Calendar Festival
For (i in SFTV)
if (Sftv[i].match/^ (/d{2}) (/d{2}) ([/s/*]) (. +) $/)) {
Tmp1=number (regexp.$1)-(sm+1)
Tmp2=number (regexp.$2)-SD
if (tmp1==0 && tmp2==0) Solarfestival = regexp.$4
}
Throttle
TMP1 = new Date ((31556925974.7* (SY-1900) +sterminfo[sm*2+1]*60000) +DATE.UTC (1900,0,6,2,5))
TMP2 = Tmp1.getutcdate ()
if (TMP2==SD) solarterms = solarterm[sm*2+1]
TMP1 = new Date ((31556925974.7* (SY-1900) +sterminfo[sm*2]*60000) +DATE.UTC (1900,0,6,2,5))
Tmp2= Tmp1.getutcdate ()
if (TMP2==SD) solarterms = solarterm[sm*2]

if (solarterms = = ' && Solarfestival = = ' && Lunarfestival = = ')
Festival = ';
Else
Festival = ' <table width=100% border=0 cellpadding=2 cellspacing=0 bgcolor= ' #CCFFCC ' ><TR><TD> ' +
"<font color=" #000000 "style=" FONT-SIZE:9PT; > ' +solarterms + ' + solarfestival + ' + lunarfestival+ ' </FONT></TD> ' +
' </TR></TABLE> ';

var cl = ' <font color= ' #000066 ' style= ' font-size:9pt; > ';
Return (cl+festival+ ' </font> ');
}
function Setcalendar () {
var html= ';
html+= ' <table align=right cellpadding=2 cellspacing=0 border=0><tr><td bgcolor= #FEFEEF ><table border=0 cellpadding=0 cellspacing=0><tr><td align=center> ';
HTML+=YYMMDD () + ' +weekday ();
html+= ' </td> ';
html+= ' <td align=center> ';
Html+=solarday1 ();
html+= ' </td><td align=center> ';
Html+=solarday2 ();
html+= ' </td><td align=center> ';
Html+=solarday3 ();
html+= ' </td></tr></table></td></tr></table> ';
return HTML;
}
</script>
<script type= "Text/javascript" src= "Js/jquery-1.4.2.min.js" ></script>
<script type= "Text/javascript" >
var temdate=new Date ();
var m=parseint (Temdate.getdate ());
var xxx = getdatelist (Temdate.getfullyear (), (M<31?temdate.getmonth (): Temdate.getmonth () +1), m<31?m:0);

$ (document). Ready (function () {
$ ("#sss"). html (XXX);
})
</script>
<body topmargin= "0" leftmargin= "0" >

<div align= "center" ><center>

<table border= "0" cellpadding= "0" cellspacing= "0" width= "100%" bgcolor= "#FFFFFF" height= "0%" bgcolor= "#C0C0C0" >
<tr>
<TD width= "100%" align= "right" ><div id= "SSS" ></div></td>
</tr>
</table>
</center></div>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.