現在のコードのロジックでは、次のようになります
myDate.setDate(myDate.getDate() + plusdays + skipdays)
skipdays
使用を計算するには
var singleDay = 1000 * 60 * 60 * 24,
fromdate = new Date('1 Apr 2012'),
todate = new Date('15 Apr 2012'),
skipdays = (todate - fromdate) / singleDay ;
アップデート
コメントの後に使用できます
function interSectionInDays(include, exclude){
if (!(include.from > exclude.to) && !(include.to < exclude.from)){
var from = Math.max(include.from, exclude.from),
to = Math.min(include.to, exclude.to),
singleDay = 1000 * 60 * 60 * 24;
return (to-from)/singleDay;
}
return 0;
}
このメソッドは、 から日付範囲までの交差日数を計算します。
使用
interSectionInDays( {from: <startdate>, to:<enddate>}, {from:<excludestartdate>, to:<excludeenddate>} );
だからあなたの例では
var fromdate = new Date(myDate),
todate = new Date(fromdate).setDate( fromdate.getDate() + plusdays),
excludestart = new Date('1 Jan 2012'),
excludeend = new Date('5 Apr 2012'),
skipdays = interSectionInDays( {from:fromdate, to:todate}, {from:excludestart, to:excludeend});
myDate.setDate( myDate.getDate() + plusdays + skipdays );
http://jsfiddle.net/gaby/mACmW/のデモ