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

Source: Internet
Author: User
Tags getdate microsoft frontpage

  This article is mainly to JS output of the lunar calendar, Gregorian calendar, year, month, Zhou Xi example code is introduced, the need for friends can come to the reference, I hope to help you.

The code is as follows: <html> <head> <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: Arial}--></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 (); &nbs P;}  sY = Now.getfullyear ();   sm = Now.getmonth ();  SD = Now.getdate ();  return Setcalendar (); //==== incoming offset back to Ganzhi, 0 = number of cyclical (num) {return (gan[num%10]+zhi[num%12])}  //==== returns the total days of the lunar y year 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))}  //==== returns the number of days of the lunar calendar Y-year leap month function leapdays (y) {   if (Leapmonth (y) )  return ((lunarinfo[y-1900] & 0x10000)? 30:29)    else return (0)}  //==== returns to the Lunar New Year Y, which month 1-12, no The leap returns 0 function Leapmonth (y) {return (lunarinfo[y-1900] & 0xf)}  //====================================== back to lunar y Total days of year m months function monthdays (y,m) {return ((lunarinfo[y-1900) & (0x10000>>m)) 30:29)}  //==== calculate the lunar calendar, incoming date Object, returns the Lunar Date object//    The object property has a. Year month. Isleap. yearcyl daycyl. moncyl function Lunar (objdate) {  & Nbsp;var I, Leap=0, temp=0   var basedate = new Date (1900,0,31)    var offset   = (objdate-basedate)/86400000   &nbs P  this.daycyl = offset +    this.moncyl =      for (i=1900; i<2050 && offset& gt;0; i++) {      temp = lyeardays (i)       offset = temp       This.moncyl + 12   &nbsp    if (offset<0) {      offset + + temp;       i--;   &NBSP ;   this.moncyl =          this.year = i    this.yearcyl = i-1864      leap = Leapmonth (i)/leap which month    this.isleap = False      for (i=1; i<13 && offset& gt;0; i++) {     //Leap month       if (leap>0 && i== (leap+1) && This.isleap==false) & nbsp        {-I. THIS.ISLEAP = true; temp = Leapdays (this.year);}       else   &NBSP ;      {temp = monthdays (this.year, i);}        //lifting Leap month       if (this.i Sleap==true && i== (leap+1)) This.isleap = False         offset = temp       IF (This.isleap = = false) This.moncyl + +   &NBSP}      if (offset==0 && leap>0 && i==l eap+1)       if (this.isleap)          {this.isleap = false;}     &NBSP ; else          {this.isleap = true;--this.moncyl;}      if (offset<0) {off Set + + temp; I.; --this.moncyl; }      this.month = i    this.day = offset + 1}    function YYMMDD () {    &NB Sp 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 '; nbsp Case 20:s + = ' 20 '; Break   Case 30:s + = ' 30 '; Break   Default:s + + Nstr2[math.floor (D/10)]; S + + NSTR1[D%10]; &NBSP}  return (s); }  function SolarDay1 () {    var sdobj = new Date (SY,SM,SD);     var ldobj = new Lunar (sdobj); &n Bsp   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> '); &NBSP}  function SolarDay2 () {    var sdobj = new Date (SY,SM,SD);     var ldobj = new Lunar (sdob j);     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> '); &NBSP}  function SolarDay3 () {var 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) var solarterm = new Array ("Xiaohan", "Dahan", "Spring", "Rain", "insects", "vernal Equinox", "Qingming", "Rain", "Summer", "Xiaoman", "grain", "Summer Solstice", "Slight heat", "Great Heat", "the 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 Eve Valentine's Day "," 0715 Zhongyuanjie "," 0815 Mid-Autumn Festival "," 0909 Double Ninth Festival "," 1208 Laba Festival "," 1224 Year "," 0100* Eve ") var Sftv = new Array (" 0101* New Year's Day "," 0214 Valentine's Day "," 03 08 Women's Day "", "0312 Tree Arbor", "0315 Consumer rights Days", "0401 April Fools '," "0501 Labor Day", "0504 Youth Festival", "0512 Nurses section", "0601 Children's Days", "0701 Party Building Festival Hong Kong Reunification Memorial", "0801 army", "08 08 Father's Day "," 0908 Mao Birthday "," 0909 Mao Zedong's death Memorial "," 0910 teachers ' Day "," 0928 Confucius's Birthday "," 1001* National holiday "," 1006 old people's Day "," 1001 Listenwind Birthday "," 1024 United Nations 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 calendar     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   }  /Calendar Festivals   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 = NE W 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 = = ' & amp;& 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></ta Ble> ';     var cl = ' <font color= ' #000066 ' style= ' font-size:9pt; > ';   Return (cl+festival+ ' </font> '); &NBSP}  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; &NBSP} </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> </head> <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> </html>

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.