A JavaScript code that displays the lunar calendar

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Script language = "JavaScript">
<! --
Var bsYear;
Var bsDate;
Var bsWeek;
Var arrLen = 8; // array Length
Var sValue = 0; // The number of seconds in the current year
Var dayiy = 0; // The day of the year
Var miy = 0; // subscript of the month
Var iyear = 0; // year mark
Var dayim = 0; // The day of the month
Var spd = 86400; // The number of seconds per day

Var year1999 = "30; 29; 29; 30; 29; 29; 30; 29; 30; 30; 29"; // 354
Var year2000 = "30; 30; 29; 29; 30; 29; 29; 30; 29; 30; 29"; // 354
Var year2001 = "30; 30; 29; 30; 29; 30; 29; 29; 30; 29; 30"; // 384
Var year2002 = "30; 30; 29; 30; 29; 30; 29; 29; 30; 29"; // 354
Var year2003 = "30; 30; 29; 30; 30; 29; 30; 29; 29; 30; 30"; // 355
Var year2004 = "29; 30; 29; 30; 30; 29; 30; 29; 30; 29; 30"; // 384
Var year2005 = "29; 30; 29; 30; 29; 30; 30; 29; 30; 29; 30; 29"; // 354
Var year2006 = "30; 29; 30; 29; 30; 30; 29; 29; 30; 30; 29; 30 ";

Var month1999 = "August 1,; August 1,; August 1,; August 1,; August 1,; August 1,; August 1"
Var month2001 = "August 1,; August 1,; August 1,; August 1,; August 1,; August 1,; August 1"
Var month2004 = "August 1,; August 1,; August 1,; August 1,; August 1,; August 1,; August 1"
Var month2006 = "August 1,; August 1,; August 1,; August 1,; August 1,; August 1,; August 1"
Var Dn = "1st; 2nd; 3rd; 4th; 5th; 6th; 7th; 8th; 9th; 10th; 11th; 12th; 13th; 14th; 15th; 16th; 17th; 18th; 19th; 20th; Region 1; Region 2; Region 3; region 4; Region 5; Region 6; Region 7; Region 8; Region 9; thirty ";

Var Ys = new Array (arrLen );
Ys [0] = 919094400; Ys [1] = 949680000; Ys [2] = 980265600;
Ys [3] = 1013443200; Ys [4] = 1044028800; Ys [5] = 1074700800;
Ys [6] = 1107878400; Ys [7] = 1138464000;

Var Yn = new Array (arrLen); // name of the calendar year
Yn [0] = ""; Yn [1] = ""; Yn [2] = "";
Yn [3] = ""; Yn [4] = ""; Yn [5] = "";
Yn [6] = ""; Yn [7] = "";
Var D = new Date ();
Var yy = D. getYear ();
Var mm = D. getMonth () + 1;
Var dd = D. getDate ();
Var ww = D. getDay ();
If (ww = 0) ww = "<font color = RED> Sunday ";
If (ww = 1) ww = "Monday ";
If (ww = 2) ww = "Tuesday ";
If (ww = 3) ww = "Wednesday ";
If (ww = 4) ww = "Thursday ";
If (ww = 5) ww = "Friday ";
If (ww = 6) ww = "<font color = RED> Saturday ";
Ww = ww;
Var ss = parseInt (D. getTime ()/1000 );
If (yy <100) yy = "19" + yy;

For (I = 0; I <arrLen; I ++)
If (ss> = Ys [I])... {
Iyear = I;
SValue = ss-Ys [I]; // The number of seconds in the current year
}
Dayiy = parseInt (sValue/spd) + 1; // the number of days in the current year

Var dpm = year1999;
If (iyear = 1) dpm = year2000;
If (iyear = 2) dpm = year2001;
If (iyear = 3) dpm = year2002;
If (iyear = 4) dpm = year2003;
If (iyear = 5) dpm = year2004;
If (iyear = 6) dpm = year2005;
If (iyear = 7) dpm = year2006;
Dpm = dpm. split (";");

Var Mn = month1999;
If (iyear = 2) Mn = month2001;
If (iyear = 5) Mn = month2004;
If (iyear = 7) Mn = month2006;
Mn = Mn. split (";");

Var Dn = "1st; 2nd; 3rd; 4th; 5th; 6th; 7th; 8th; 9th; 10th; 11th; 12th; 13th; 14th; 15th; 16th; 17th; 18th; 19th; 20th; Region 1; Region 2; Region 3; region 4; Region 5; Region 6; Region 7; Region 8; Region 9; thirty ";
Dn = Dn. split (";");

Dayim = dayiy;

Var total = new Array (13 );
Total [0] = parseInt (dpm [0]);
For (I = 1; I <dpm. length-1; I ++) total [I] = parseInt (dpm [I]) + total [I-1];
For (I = dpm. length-1; I> 0; I --)
If (dayim> total [I-1])... {
Dayim = dayim-total [I-1];
Miy = I;
}
BsWeek = ww;
BsDate = yy + "year" + mm + "month ";
BsDate2 = dd;
BsYear = "" + Yn [iyear];
BsYear2 = Mn [miy] + Dn [dayim-1];
If (ss> = Ys [7] | ss <Ys [0]) bsYear = Yn [7];
Function CAL ()...{
Document. write ("<table border = '1' cellspacing = '3' width = '90' bordercolor = '#000000 'bgcolor =' # ffff' height = '2016' cellpadding =' 2 '");
Document. write ("<tr> <td align = 'center'> <B> <font color = #008040>" + bsDate + "</font> <br> <font face = 'arial' size = '6' color = # FF8040> "+ bsDate2 +" </font> <br> <font color = #008040> <span style = 'font-SIZE: 10.5pt '> ");
Document. write (bsWeek + "</span> <br>" + "<br> </B> <font color = #9B4E00> ");
Document. write (bsYear + "<br>" + bsYear2 + "</td> </tr> </table> ");
}
// -->
</Script>
<Script language = "javascript"> CAL (); </script>

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.