Date 如何在SharePoint列表中添加20天(不包括存储在React状态下的周末或假日)
我在开始日期的基础上增加了20天,不包括存储在state中的周末和假日。我想到了这个:Date 如何在SharePoint列表中添加20天(不包括存储在React状态下的周末或假日),date,sharepoint-online,spfx,Date,Sharepoint Online,Spfx,我在开始日期的基础上增加了20天,不包括存储在state中的周末和假日。我想到了这个: private _calculateExternalDeadLineDate = () => { console.log(this.state.ReceivedDate, 'state.Recieved date'); var weekendDayCount = 0; var fromDate = this.state.ReceivedDate; var newF
private _calculateExternalDeadLineDate = () => {
console.log(this.state.ReceivedDate, 'state.Recieved date');
var weekendDayCount = 0;
var fromDate = this.state.ReceivedDate;
var newFromDate = new Date(fromDate);
var toDateAdd20 = newFromDate.setDate(newFromDate.getDate()+20);
var newToDate = new Date(toDateAdd20);
while(newFromDate < newToDate){
fromDate.setDate(fromDate.getDate() + 1);
if(fromDate.getDay() === 0 || fromDate.getDay() === 6){
++weekendDayCount;
}
}
var newToDateAddedWknds = newToDate.setDate(newToDate.getDate()+weekendDayCount);
var ExternalDeadlineDate = new Date(newToDateAddedWknds);
//The below loop, loops through each day between start and end date. I'm wondering how I would count how many matches of dates between the contents of this loop and the stored array of dates?
//@ts-ignore
var start = new Date(fromDate);
//@ts-ignore
var end = new Date(newToDateAddedWknds);
//@ts-ignore
var loop = new Date(start);
while(loop <= end){ //less than or equal to
var newDate = loop.setDate(loop.getDate() + 1);
loop = new Date(newDate);
if(loop ===)
console.log(loop,'loop');
}
if(ExternalDeadlineDate.getDay() === 0 || ExternalDeadlineDate.getDay() === 6){
console.log(ExternalDeadlineDate.getDay(), 'getDay() is on a weekend');
} else {
console.log('getDay() is not on a weekend');
}
}
任何帮助都会很好
0: Item {Id: 1, Holiday: "2020-01-01T00:00:00Z"}
etc.