Very full display the date of the lunar calendar JS code _ time and date

Source: Internet
Author: User
Tags abs getdate time and date
function Runglnl () {
var today=new Date ();
var d=new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var dddd= (today.getyear () <100?
Today.getyear () +1900:today.getyear () + "year" + (Today.getmonth () +1) + "month" +today.getdate () + "Day";
DDDD = DDDD + "" + d[today.getday ()];
DDDD = dddd+ "" + (Cndateofdatestr (today));
DDDD = dddd+ "" + solarterm (today);
document.write (DDDD);
}
function Daysnumberofdate (DATEGL) {
Return parseint (Date.parse (DATEGL)-date.parse (dategl.getyear () + "/1/1"))/86400000) +1;
}
function Cndateofdate (DATEGL) {
var cndata=new Array (
0x16,0x2a,0xda,0x00,0x83,0x49,0xb6,0x05,0x0e,0x64,0xbb,0x00,0x19,0xb2,0x5b,0x00,
0X87,0X6A,0X57,0X04,0X12,0X75,0X2B,0X00,0X1D,0XB6,0X95,0X00,0X8A,0XAD,0X55,0X02,
0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00,
0X86,0XE4,0XAE,0X05,0X11,0XEA,0X56,0X00,0X1B,0X6D,0X2A,0X00,0X88,0X5A,0XAA,0X04,
0x14,0xad,0x55,0x00,0x81,0xaa,0xd5,0x09,0x0b,0x52,0xea,0x00,0x16,0xa9,0x6d,0x00,
0x84,0xa9,0x5d,0x06,0x0f,0xd4,0xae,0x00,0x1a,0xea,0x4d,0x00,0x87,0xba,0x55,0x04
);
var cnmonth=new Array ();
var cnmonthdays=new Array ();
var cnbeginday;
var leapmonth;
var bytes=new Array ();
var I;
var cnmonthdata;
var Dayscount;
var Cndayscount;
var resultmonth;
var resultday;
var yyyy=dategl.getyear ();
var mm=dategl.getmonth () +1;
var dd=dategl.getdate ();
if (yyyy<100) yyyy+=1900;
if ((yyyy < 1997) | | (yyyy > 2020)) {
return 0;
}
Bytes[0] = cndata[(yyyy-1997) * 4];
BYTES[1] = cndata[(yyyy-1997) * 4 + 1];
BYTES[2] = cndata[(yyyy-1997) * 4 + 2];
BYTES[3] = cndata[(yyyy-1997) * 4 + 3];
if ((Bytes[0] & 0x80)!= 0) {cnmonth[0] = 12;}
else {cnmonth[0] = 11;}
Cnbeginday = (Bytes[0] & 0x7f);
Cnmonthdata = bytes[1];
Cnmonthdata = Cnmonthdata << 8;
Cnmonthdata = Cnmonthdata | BYTES[2];
Leapmonth = bytes[3];
for (i=15;i>=0;i--) {
Cnmonthdays[15-i] = 29;
if (((1 << I) & Cnmonthdata)!= 0) {
cnmonthdays[15-i]++;}
if (cnmonth[15-i] = = Leapmonth) {
Cnmonth[15-i + 1] =-leapmonth;}
else{
if (Cnmonth[15-i] < 0) {cnmonth[15-i + 1] =-cnmonth[15-i] + 1;}
else {cnmonth[15-i + 1] = Cnmonth[15-i] + 1;}
if (cnmonth[15-i + 1] >) {cnmonth[15-i + 1] = 1;}
}
}
Dayscount = Daysnumberofdate (DATEGL)-1;
if (Dayscount <= (cnmonthdays[0]-cnbeginday)) {
if ((yyyy > 1901) && (Cndateofdate (New Date (yyyy-1) + "/12/31")) < 0) {
Resultmonth =-cnmonth[0];}
else {resultmonth = cnmonth[0];}
Resultday = Cnbeginday + dayscount;
}
else{
Cndayscount = cnmonthdays[0]-cnbeginday;
I = 1;
while ((Cndayscount < Dayscount) && (Cndayscount + cnmonthdays[i] < Dayscount)) {
cndayscount+= Cnmonthdays[i];
i++;
}
Resultmonth = Cnmonth[i];
Resultday = Dayscount-cndayscount;
}
if (Resultmonth > 0) {
return resultmonth * + resultday;}
Else{return resultmonth * 100-resultday;}
}
function Cnyearofdate (DATEGL) {
var yyyy=dategl.getyear ();
var mm=dategl.getmonth () +1;
var cnmm=parseint (Math.Abs (Cndateofdate (DATEGL))/100);
if (yyyy<100) yyyy+=1900;
if (cnmm>mm) yyyy--;
yyyy-=1864;
Return Cnera (YYYY) + "year";
}
function Cnmonthofdate (DATEGL) {
var cnmonthstr=new Array ("0", "positive", "two", "three", "four", "five", "six", "seven", "eight", "Nine", "Ten", "11", "Wax");
var Month;
Month = parseint (cndateofdate (DATEGL)/100);
if (Month < 0) {return "leap" + Cnmonthstr[-month] + "Month";}
Else{return Cnmonthstr[month] + "Month";}
}
function Cndayofdate (DATEGL) {
var cndaystr=new Array ("0",
"The Junior", "the Junior", "the Junior", "Hansi", "Duanwu",
"Arrest", "When初七because", "Day", "Yanji", "decade",
"11", "12", "13", "14", "XV",
"16", "17", "18", "19", "20",
"21", "22", "23", "24", "25",
"26", "27", "28", "29", "30");
Var day;
Day = (Math.Abs (cndateofdate (DATEGL))%100;
return Cndaystr[day];
}
function Daysnumberofmonth (DATEGL) {
var mm1=dategl.getyear ();
Mm1<100? MM1+=1900:MM1;
var mm2=mm1;
mm1+= "/" + (Dategl.getmonth () +1);
mm2+= "/" + (Dategl.getmonth () +2);
mm1+= "/1";
mm2+= "/1";
Return parseint (Date.parse (MM2)-date.parse (MM1))/86400000);
}
function Cnera (YYYY) {
var tiangan=new Array ("A", "B", "C", "Ding", "E", "Self", "Geng", "Xin", "Ren", "GUI");
var dizhi=new Array ("Son (Mouse)", "Ugly (ox)", "Yin (Tiger)", "Mao (Rabbit)", "Chen (Dragon)", "(Snake)",
"Afternoon (horse)", "Not (sheep)", "Shen (Monkey)", "Unitary (chicken)", "Xu (dog)", "Hai (pig)");
var dizhi=new Array ("Zi", "ugly", "Yin", "Mao", "Chen", "Si", "Afternoon", "not", "Shen", "unitary", "Xu", "Hai");
return tiangan[yyyy%10]+dizhi[yyyy%12];
}
function Cndateofdatestr (DATEGL) {
if (cnmonthofdate (DATEGL) = "0") return "Please adjust your computer date!";
else return "Lunar calendar:" +cnyearofdate (DATEGL) + "" + cnmonthofdate (DATEGL) + cndayofdate (DATEGL);
}
function Solarterm (DATEGL) {
var solartermstr=new Array (
"Xiaohan", "Dahan", "Spring", "Rain", "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 differenceinmonth=new Array (
1272060,1275495,1281180,1289445,1299225,1310355,
1321560,1333035,1342770,1350855,1356420,1359045,
1358580,1355055,1348695,1340040,1329630,1318455,
1306935,1297380,1286865,1277730,1274550,1271556);
var differenceinyear=31556926;
var begintime=new Date (1901/1/1);
Begintime.settime (947120460000);
For (;D ategl.getyear () <begintime.getyear ();) {
Begintime.settime (Begintime.gettime ()-differenceinyear*1000);
}
For (;D ategl.getyear () >begintime.getyear ();) {
Begintime.settime (Begintime.gettime () +differenceinyear*1000);
}
For (Var m=0;dategl.getmonth () >begintime.getmonth (); m++) {
Begintime.settime (Begintime.gettime () +differenceinmonth[m]*1000);
}
if (Dategl.getdate () >begintime.getdate ()) {
Begintime.settime (Begintime.gettime () +differenceinmonth[m]*1000);
m++;
}
if (Dategl.getdate () >begintime.getdate ()) {
Begintime.settime (Begintime.gettime () +differenceinmonth[m]*1000);
M==23? m=0:m++;
}
var JQ;
if (Dategl.getdate () ==begintime.getdate ()) {
Jq= "Today is <font color= ' #FF9999 ' ><b>" +solartermstr[m] + "</b></font>";
}
else if (Dategl.getdate () ==begintime.getdate ()-1) {
Jq= "Tomorrow is <font color= ' #FF9999 ' ><b>" +solartermstr[m] + "</b></font>";
}
else if (Dategl.getdate () ==begintime.getdate ()-2) {
Jq= "The day After Tomorrow is <font color= ' #FF9999 ' ><b>" +solartermstr[m] + "</b></font>";
}
else{
Jq= ""
if (Dategl.getmonth () ==begintime.getmonth ()) {
jq+= "this month";
}
else{
jq+= "next month";
}
Jq+=begintime.getdate () + "Day" + "<font color= ' #FF9999 ' ><b>" +solartermstr[m]+ "</b></font>";
}
return JQ;
}
function CAL ()
{}
RUNGLNL ();

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.