JS judgment holiday instance code

js判断节假日实例代码

        / *************************************** ***************************** Judgment a day is not a working day * @ Date {date} To judge the date (0000- 00-00) ************************************************************ **************** / / / 2017 holiday VAR JRDATE_2017 = ["2017-01-01", "2017-01-02", "2017-01-27", "2017-01-27", "2017-01-28", "2017-01-29", "2017-01-30", "2017-01-31", "2017 -02-01 "," 2017-02-02 "," 2017-04-02 "," 2017-04-04 "," 2017-04-29 "," 2017-04 -30 "," 2017-05-01 "," 2017-05-29 "," 2017-05-30 "," 2017-10-01 "," 2017-10-02 "," 2017-10-03 "," 2017-10-04 "," 2017-10-06 "," 2017-10-07 "," 2017-10-08 "] ; // 2017 year-rounded days VAR TXR_2017 = ["2017-02-04", "2017-04-01", "2017-05-27", "2017-09-30"]; // 2018 holiday var jrdate_2018 = ["2018-01-01", "2018-02-16", "2018-02-17" "2018-02-18", "2018-02-19", "2018-02-20", "2018-04-05", "2018-04-06", " 2018-04-07 "," 2018-04-29 "," 2018-04-30 "," 2018-05-01 "," 2018-06-16 "," 2018-06-17 "," 2018- 06-18 "," 2018-09-22 "," 2018-09-23 "," 2018-09-24 "," 2018-10-01 "," 2018-10-02 "," 2018-10- 03 "," 2018-10-04 "," 2018-10-05 "," 2018-10-07 "]; // 2018 Advance Day VAR TXR_2018 = [" 2018-02 -11 "," 2018-02-24 "," 2018-04-08 "," 2018-09-29 "," 2018-09-30 "]; var Num = 0; function isWorkday (date_String) {// debugger; var date = date_String new Date ():!? new Date (date_String); var is_jr_2017 = $ .inArray (date_String, jrdate_2017); var is_jr_2018 = $ .inArray (date_String, jrdate_2018) ; var IS_TX_2017 = $ .inaRray (date_string, txr_2017); varIS_TX_2018 = $ .inArray (Date_String, TXR_2018); if (is_jr_2017! = - 1 || IS_JR_2018! = - 1) {Return; // "Holiday";} var getday = Date.getDay (); if (getDay == 0 || GetDay == 6) {IF (is_tx_2017! = - 1 || IS_TX_2018! = - 1) {Num ++; Return; // 'Trunk Day';} Return; // 'Rest Day';} else {IF (IS_TX_2017! = - 1 || IS_TX_2018! = - 1) {Num ++; Return; // 'Taught Day';} Num ++; Return; // 'Work Day';} // Num;} // var D_Arr = ]; // Time Date Function getDayinfo (StartDate, Enddate) {var bd = new date (startdate), be = new date (enddate); var bd_time = bd.gettime (), be_time = be.gettime () , TIME_DIFF = BE_TIME - BD_TIME; D_ARR = []; Num = 0; for (var i = 0; i    Fill in time calculation We can play a few days ?!   : Start Time:  <= time_diff; i+=86400000){ 
      var ds = new Date(bd_time+i).Format("yyyy-MM-dd"); 
      isWorkday(ds);
      //d_arr.push(ds) 
  } 
  console.log(num); 
  console.log(d_arr); 
  $("#show").html("呀!这段时间我们一共上"+num+"天班呢。");
}
function getInfo(info){
	
	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();
	getDayInfo(startDate,endDate);
	//console.log(isWorkday(startDate));
}
// 调用
//alert(isWorkday('2016-12-10'));
	
  

PS: The following is to share a piece of code for the JS to judge all holidays, the specific code is as follows :
// javaScript documentcalendar = new date (); month = calendar.getMonth (); Date = Calendar.getdate (); if (((Month = = 0) && (Date == 1)) Document.Write ("New Year"); if ((Month == 1) && (Date == 13)) Document.write; if ((((Month = = 1) && (Date == 14)) Document.write ("Spring Festival / Valentine's Day"); if ((Month == 2) && (Date == 1)) Document.write ("International Seal Day); IF ((MONTH == 2) && (Date == 8)) Document.write ("International Women's Day / China Protects Mother River Day"); if ((Month == 2) && (Date == 12)) Document.write ("Tree Festival"); if ((Month == 3) && (Date == 1)) Document.write; if ((Month == 3) && (Date == 5) )) Document.write; if ((Month == 4) && (Date == 1)) Document.Write ("International Labor Day)); if ((Month == 4) && (Date == 9)) Document.wriTE ("Mother's Day"); IF ((Month == 5) && (Date == 1)) Document.write ("International Children's Day"); if ((Month == 5) && (Date == 26) ) Document.write ("International Anti-Drug Day"); if ((Month == 7) && (Date == 1)) Document.write ("Jianjun Festival"); if ((Month == 7) && (Date == 15)) Document.write ("Japan unconditional surrender date / century wedding day"); if ((Month == 7) && (Date == 16)) Document.write ("Tanabata"); IF (MONTH == 9) && (Date == 20)) Document.write ("World Chef Day"); if ((Month == 9) && (Date == 22)) Document.write ("World Traditional Medicine Day "); if ((Month == 9) && (Date == 24)) Document.write (" United Nations Day / World Development Information Day "); if ((Month == 9) && (Date == 25)) Document.write ("World Osteoporosis Day / Anti-US Drop Memorial / Sanitation Workers' Day"); if ((Month == 9) && (Date == 31)) Document.write ("World Diligence Day / Chinese Male Health Day "); if ((Month == 11) && (Date == 24)) Document.write (" Christmas Eve "); if ((Month == 11) && (Date == 25)) Document.write (" " Christmas ");
Summary
The above is the JS judgment holiday instance code for Xiaobian to everyone, I hope to help everyone. If you have any questions, please leave a message, the small package will reply to everyone. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment