JS get the Lunar date specific examples _javascript skills

Source: Internet
Author: User

Copy Code code as follows:

<script type= "Text/javascript" >
var calendardata = new Array (100);
var madd = new Array (12);
var tgstring = "Methyl ethyl propionate Xing";
var dzstring = "Kaniko chen has not Shin Hai";
var numstring = "1,234,567,890";
var monstring = "234,567,890 Winter wax";
var weekstring = "Day 123456";
var sx = "Rat bovine tiger rabbit snake horse sheep monkey chicken Dog pig";
var cyear, Cmonth, Cday, thedate;
CalendarData = new Array (0xa4b, 0x5164b, 0x6a5, 0x6d4, 0x415b5, 0x2b6, 0x957, 0x2092f, 0x497, 0x60c96, 0xd4a, 0xEA5, 0x50D A9, 0X5AD, 0x2b6, 0x3126e, 0x92e, 0x7192d, 0xc95, 0xd4a, 0x61b4a, 0xb55, 0x56a, 0x4155b, 0x25d, 0x92d, 0x2192b, 0xA95, 0x7 1695, 0x6ca, 0xb55, 0x50ab5, 0x4da, 0xa5b, 0x30a57, 0x52b, 0x8152a, 0xe95, 0x6aa, 0X615AA, 0xab5, 0x4b6, 0x414AE, 0xA57, 0 x526, 0x31d26, 0xd95, 0x70b55, 0x56a, 0x96d, 0x5095d, 0X4AD, 0xa4d, 0x41a4d, 0xd25, 0x81aa5, 0xb54, 0xb6a, 0x612DA, 0x95B, 0x49b, 0x41497, 0xa4b, 0xa164b, 0x6a5, 0x6d4, 0X615B4, 0xab6, 0x957, 0x5092f, 0x497, 0x64b, 0x30d4a, 0xEA5, 0x80D65, 0x5A C, 0xab6, 0x5126d, 0x92e, 0xc96, 0x41a95, 0xd4a, 0xda5, 0x20b55, 0x56a, 0x7155b, 0x25d, 0x92d, 0x5192b, 0xA95, 0xB4A, 0x41 6AA, 0xad5, 0x90ab5, 0x4ba, 0xa5b, 0x60a57, 0x52b, 0xa93, 0x40e95);
Madd[0] = 0;
Madd[1] = 31;
Madd[2] = 59;
MADD[3] = 90;
MADD[4] = 120;
MADD[5] = 151;
MADD[6] = 181;
MADD[7] = 212;
MADD[8] = 243;
MADD[9] = 273;
MADD[10] = 304;
MADD[11] = 334;

    function Getbit (m, n) {
        return (M >> N) & 1;
   }
    function e2c () {
        thedate = (arguments.length!= 3 ) ? New Date (): new Date (Arguments[0], arguments[1], arguments[2]);
        var total, M, N, K;
        var isend = false;
        var tmp = Thedate.getyear ();
        if (tmp < 1900) {
             tmp + + 1900;
       }
        total = (tmp-1921) * 365 + Math.floor ((tmp-1921)/4) + madd[thedate.ge Tmonth ()] + thedate.getdate ()-

if (thedate.getyear ()% 4 = 0 && thedate.getmonth () > 1) {
total++;
}
for (m = 0;; m++) {
K = (Calendardata[m] < 0XFFF)? 11:12;
for (n = k; n >= 0; n--) {
if (total <= + getbit (calendardata[m], n)) {
Isend = true; Break
}
Total = Total-29-getbit (Calendardata[m], n);
}
if (isend) break;
}
Cyear = 1921 + M;
Cmonth = k-n + 1;
Cday = total;
if (k = = 12) {
if (Cmonth = = Math.floor (calendardata[m]/0x10000) + 1) {
Cmonth = 1-cmonth;
}
if (Cmonth > Math.floor (calendardata[m)/0x10000) + 1) {
cmonth--;
}
}
}

function getcdatestring () {
var tmp = "";
TMP + = Tgstring.charat ((cYear-4)% 10);
TMP + = Dzstring.charat ((cYear-4)% 12);
TMP + = "(";
TMP + = Sx.charat ((cYear-4)% 12);
TMP + = "Year";
if (Cmonth < 1) {
TMP + = "(Leap)";
TMP + + Monstring.charat (-cmonth-1);
} else {
TMP + + Monstring.charat (cMonth-1);
}
TMP = "month";
TMP + = (Cday < 11)? "Beginning": ((Cday < 20)? "Ten": ((Cday < 30)? "20": "30"));
if (cday%!= 0 | | | cday = 10) {
TMP + = Numstring.charat ((cDay-1)% 10);
}
return TMP;
}

function Getlunarday (solaryear, Solarmonth, Solarday) {
Solaryear = solaryear<1900? (1900+solaryear): solaryear;
if (Solaryear < 1921 | | solaryear > 2020) {
Return "";
} else {
Solarmonth = (parseint (solarmonth) > 0)? (solarMonth-1): 11;
E2C (Solaryear, Solarmonth, Solarday);
return getcdatestring ();
}
}
Call
var D = new Date ();
var yy = D.getfullyear ();
var mm = D.getmonth () + 1;
var dd = d.getdate ();
var ww = d.getday ();
var ss = parseint (D.gettime ()/1000);
if (yy <) yy = "n" + yy;
function Getcndate () {
Return Getlunarday (yy, MM, DD);
}
$ (document). Ready (function () {
var d = getcndate ();
alert (d);
});
</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.