Commit bd13c348 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fix: Bug 21089 - Некорректно вычисляется количество рабочих дней в формуле NETWORKDAYS

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50522 954022d7-b5bf-4e40-9824-e11837661b57
parent 6195b203
...@@ -705,7 +705,13 @@ cFormulaFunction.DateAndTime = { ...@@ -705,7 +705,13 @@ cFormulaFunction.DateAndTime = {
var holidays = []; var holidays = [];
if( arg2 ){ if( arg2 ){
if( arg2 instanceof cArea || arg2 instanceof cArea3D ){ if( arg2 instanceof cRef ){
var a = arg2.getValue();
if( a instanceof cNumber && a.getValue() >= 0 ){
holidays.push(a);
}
}
else if( arg2 instanceof cArea || arg2 instanceof cArea3D ){
var arr = arg2.getValue(); var arr = arg2.getValue();
for(var i = 0; i < arr.length; i++){ for(var i = 0; i < arr.length; i++){
if( arr[i] instanceof cNumber && arr[i].getValue() >= 0 ){ if( arr[i] instanceof cNumber && arr[i].getValue() >= 0 ){
...@@ -739,11 +745,11 @@ cFormulaFunction.DateAndTime = { ...@@ -739,11 +745,11 @@ cFormulaFunction.DateAndTime = {
return true; return true;
} }
dif = ( val1 - val0 ) / c_msPerDay; dif = ( val1 - val0 + c_msPerDay ) / c_msPerDay;
for(var i = 0; i < Math.abs(dif); i++ ){ for(var i = 0; i < Math.abs(dif); i++ ){
var date = new Date( val0 ); var date = new Date( val0 );
date.setDate(val0.getDate()+i) ; date.setDate(val0.getDate()+i) ;
if( date.getDay() != 5 && date.getDay() != 6 && includeInHolidays(date) ) if( date.getDay() != 6 && date.getDay() != 0 && includeInHolidays(date) )
count++; count++;
} }
return this.value = new cNumber( (dif<0?-1:1)*count ); return this.value = new cNumber( (dif<0?-1:1)*count );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment