返回首页

js获得一个阴历日期的具体例子。

时间:2018-08-27 17:35
   复制代码代码如下所示:

无功calendardata =新阵(100);
VaR MADD =新阵(12);
无功tgstring =甲乙丙丁戊己克癸酸等;
无功dzstring =巽根本原因不是下午沈海有序;
无功numstring =yiersansiwuliuqibajiushi ;
无功monstring =ersansiwuliuqibajiushi冬季蜡;
无功weekstring =123456天;
VaR SX =鼠牛虎兔龙蛇马羊猴鸡犬猪;
无功cyear,cmonth,cday,日期;
calendardata新=阵列(0xa4b,0x5164b,0x6a5,0x6d4,0x415b5,0x2b6,0x957,0x2092f,0x497,0x60c96,0xd4a,0xea5,0x50da9,0x5ad,0x2b6,0x3126e,0x92e,0x7192d,0xc95,0xd4a,0x61b4a,0xb55,0x56a,0x4155b,0x25d,0x92d,0x2192b,0xa95,0x71695,0x6ca 0xb55,0x50ab5,0x4da,0xa5b,0x30a57,0x52b,0x8152a,0xe95,0x6aa,0x615aa,0xab5,0x4b6,0x414ae,0xa57,0x526,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,0x5ac,0xab6,0x5126d,0x92e,0xc96,0x41a95,0xd4a,0xda5,0x20b55,0x56a,0x7155b,0x25d,0x92d,0x5192b,0xa95,0xb4a,0x416aa,0xad5,0x90a.b5,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;

函数中的getbit(m,n){
返回(m×n)1;
}
功能E2C(){
日期=(arguments.length!= 3)新日期():新日期(参数{ 0 },参数{ 1 },参数{ 2 });
总、m、n、k;
无功终端= false;
var tmp = thedate.getyear();
如果(TMP<1900){
TMP=1900;
}
总=(TMP - 1921)* 365 + math.floor((TMP - 1921)/ 4)+ thedate.getmonth MADD {()} + thedate.getdate()- 38;

如果(日期。getYear)(日期。获得当前的月份)% 4 = = 0(> 1){
总+;
}
对于(m=0;;m + +){
K =(calendardata {米} < 0xfff)11:12;
对于(n = k;n = 0;n){
如果(总< = 29 +中的getbit(calendardata {米},N)){
终端= true;打破;
}
总=总29中的getbit(calendardata {米},N);
}
如果(终端)打破;
}
cyear = 1921 + M;
cmonth = k n + 1;
cday =总;
如果(k=12){
如果(cmonth = = math.floor(calendardata {米} / 0x10000)+ 1){
cmonth = 1 cmonth;
}
如果(cmonth > math.floor(calendardata {米} / 0x10000)+ 1){
cmonth --;
}
}
}

功能getcdatestring(){
var;
TMP = tgstring.charat((cyear - 4)% 10);
TMP = dzstring.charat((cyear - 4)% 12);
(TMP;
TMP = sx.charat((cyear - 4)% 12);

如果(cmonth<1){

TMP = monstring.charat(- cmonth - 1);
{人}
TMP = monstring.charat(cmonth - 1);
}
四月;
TMP =(cday<11)的第一:((cday<20)十:((cday<30)二十三十));
如果(cday % 10!= 0 | | { cday = = 10)
TMP = numstring.charat((cday - 1)% 10);
}
返回TMP;
}

功能getlunarday(solaryear,solarmonth,solarday){
/ / solaryear = solaryear<1900(1900 + solaryear):solaryear;
如果(solaryear 2020){
返回;
{人}
solarmonth =(parseInt(solarmonth)> 0)(solarmonth - 1):11;
E2C(solaryear,solarmonth,solarday);
返回getcdatestring();
}
}
调用
新日期();
VaR YY = d.getfullyear();
VaR d.getmonth毫米=()+ 1;
var = d.getdate(DD);
VaR WW d.getday();
VaR SS = parseInt()/ D.getTime(1000);
如果(YY 100)YY =19+ YY;
功能getcndate(){
返回getlunarday(YY、MM、DD);
}
$(文档)Ready(函数(){)
var a getcndate();
警报(d);
});

------分隔线----------------------------
推荐内容