Commit 72b98dfc authored by GoshaZotov's avatar GoshaZotov

add test for WORKDAY.INTL

parent 5fe46556
...@@ -2594,6 +2594,54 @@ $( function () { ...@@ -2594,6 +2594,54 @@ $( function () {
} ); } );
test( "Test: \"WORKDAY.INTL\"", function () {
oParser = new parserFormula( "WORKDAY.INTL(DATE(2012,1,1),30,0)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#NUM!" );
oParser = new parserFormula( "WORKDAY.INTL(DATE(2012,1,1),90,11)", "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 41013 );
oParser = new parserFormula( 'TEXT(WORKDAY.INTL(DATE(2012,1,1),30,17),"m/dd/yyyy")', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "2/05/2012" );
oParser = new parserFormula( 'WORKDAY.INTL(151,8,"0000000")', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 159 );
oParser = new parserFormula( 'WORKDAY.INTL(151,8,"0000000")', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 159 );
oParser = new parserFormula( 'WORKDAY.INTL(159,8,"0011100")', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 171 );
oParser = new parserFormula( 'WORKDAY.INTL(151,-18,"0000000")', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 133 );
oParser = new parserFormula( 'WORKDAY.INTL(151,8,"1111111")', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
oParser = new parserFormula( 'WORKDAY.INTL(DATE(2006,1,1),20,1,{"1/2/2006","1/16/2006"})', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 38748 );
oParser = new parserFormula( 'WORKDAY.INTL(DATE(2006,1,1),20,{"1/2/2006","1/16/2006"})', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#NUM!" );
oParser = new parserFormula( 'WORKDAY.INTL(DATE(2006,1,1),-20,1,{"1/2/2006",,"1/16/2006"})', "A2", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 38691 );
} );
test( "Test: \"TIMEVALUE\"", function () { test( "Test: \"TIMEVALUE\"", function () {
oParser = new parserFormula( "timevalue(\"10:02:34\")", "A2", ws ); oParser = new parserFormula( "timevalue(\"10:02:34\")", "A2", ws );
ok( oParser.parse() ); ok( oParser.parse() );
......
...@@ -1760,7 +1760,7 @@ ...@@ -1760,7 +1760,7 @@
return new cError(cErrorType.not_numeric); return new cError(cErrorType.not_numeric);
} }
return t.setCalcValue(new cNumber(val)); return t.setCalcValue(new cNumber(val), 14);
}; };
...@@ -1783,6 +1783,7 @@ ...@@ -1783,6 +1783,7 @@
cWORKDAY_INTL.prototype.argumentsMax = 4; cWORKDAY_INTL.prototype.argumentsMax = 4;
cWORKDAY_INTL.prototype.numFormat = AscCommonExcel.cNumFormatNone; cWORKDAY_INTL.prototype.numFormat = AscCommonExcel.cNumFormatNone;
cWORKDAY_INTL.prototype.Calculate = function (arg) { cWORKDAY_INTL.prototype.Calculate = function (arg) {
//TODO проблема с формулами следующего типа - WORKDAY.INTL(8,60,"0000000")
var t = this; var t = this;
var tempArgs = arg[2] ? [arg[0], arg[1], arg[2]] : [arg[0], arg[1]]; var tempArgs = arg[2] ? [arg[0], arg[1], arg[2]] : [arg[0], arg[1]];
var oArguments = this._prepareArguments(tempArgs, arguments[1]); var oArguments = this._prepareArguments(tempArgs, arguments[1]);
...@@ -1805,6 +1806,9 @@ ...@@ -1805,6 +1806,9 @@
val0 = getCorrectDate(val0); val0 = getCorrectDate(val0);
//Weekend //Weekend
if(arg2 && "1111111" === arg2.getValue()){
return this.value = new cError(cErrorType.wrong_value_type);
}
var weekends = getWeekends(arg2); var weekends = getWeekends(arg2);
if (weekends instanceof cError) { if (weekends instanceof cError) {
return this.value = weekends; return this.value = weekends;
...@@ -1831,7 +1835,7 @@ ...@@ -1831,7 +1835,7 @@
date = new Date(val0.getTime() + dif1 * c_msPerDay); date = new Date(val0.getTime() + dif1 * c_msPerDay);
for(var i = 0; i < 7; i++){ for(var i = 0; i < 7; i++){
if(weekends[date.getUTCDay()]){ if(weekends[date.getUTCDay()]){
dif1++; dif >= 0 ? dif1++ : dif1--;
date = new Date(val0.getTime() + (dif1) * c_msPerDay); date = new Date(val0.getTime() + (dif1) * c_msPerDay);
}else{ }else{
break; break;
...@@ -1846,7 +1850,7 @@ ...@@ -1846,7 +1850,7 @@
return new cError(cErrorType.not_numeric); return new cError(cErrorType.not_numeric);
} }
return t.setCalcValue(new cNumber(val)); return t.setCalcValue(new cNumber(val), 14);
}; };
return this.value = calcDate(); return this.value = calcDate();
......
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