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

add weeknum

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47581 954022d7-b5bf-4e40-9824-e11837661b57
parent 35e9fd01
...@@ -951,33 +951,33 @@ ...@@ -951,33 +951,33 @@
}) })
test("Test: \"WEEKNUM\"",function(){ test("Test: \"WEEKNUM\"",function(){
/* oParser = new parserFormula("WEEKNUM(DATE(2006,1,1))","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,1,1))","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 1) < dif ); strictEqual( oParser.calculate().getValue(), 1);
oParser = new parserFormula("WEEKNUM(DATE(2006,1,1),17)","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,1,1),17)","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 1) < dif ); strictEqual( oParser.calculate().getValue(), 1);
oParser = new parserFormula("WEEKNUM(DATE(2006,1,1),1)","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,1,1),1)","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 1) < dif ); strictEqual( oParser.calculate().getValue(), 1);
oParser = new parserFormula("WEEKNUM(DATE(2006,1,1),21)","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,1,1),21)","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 52) < dif ); strictEqual( oParser.calculate().getValue(), 52);
oParser = new parserFormula("WEEKNUM(DATE(2006,2,1),1)","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,2,1),1)","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 5) < dif );//10 strictEqual( oParser.calculate().getValue(), 5);
oParser = new parserFormula("WEEKNUM(DATE(2006,2,1),2)","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,2,1),2)","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 6) < dif );//12 strictEqual( oParser.calculate().getValue(), 6);
oParser = new parserFormula("WEEKNUM(DATE(2006,2,1),11)","A2",ws); oParser = new parserFormula("WEEKNUM(DATE(2006,2,1),11)","A2",ws);
ok(oParser.parse()); ok(oParser.parse());
ok( Math.abs(oParser.calculate().getValue() - 6) < dif );//14*/ strictEqual( oParser.calculate().getValue(), 6);
oParser = new parserFormula("WEEKNUM(DATE(2007,1,1),15)","A2",ws);//понед oParser = new parserFormula("WEEKNUM(DATE(2007,1,1),15)","A2",ws);//понед
ok(oParser.parse()); ok(oParser.parse());
...@@ -1003,33 +1003,37 @@ ...@@ -1003,33 +1003,37 @@
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 1); strictEqual( oParser.calculate().getValue(), 1);
oParser = new parserFormula("WEEKNUM(DATE(2012,1,1),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2012,1,1),11)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 1); strictEqual( oParser.calculate().getValue(), 1);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,4),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2008,1,4),11)","A2",ws);//вск
ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 1);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,10),11)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 2); strictEqual( oParser.calculate().getValue(), 2);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,10),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2008,1,11),11)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 2); strictEqual( oParser.calculate().getValue(), 2);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,11),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2008,1,17),11)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 3); strictEqual( oParser.calculate().getValue(), 3);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,17),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2008,1,18),11)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 3); strictEqual( oParser.calculate().getValue(), 3);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,18),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2008,1,24),11)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 4); strictEqual( oParser.calculate().getValue(), 4);
oParser = new parserFormula("WEEKNUM(DATE(2008,1,24),15)","A2",ws);//вск oParser = new parserFormula("WEEKNUM(DATE(2013,1,1),21)","A2",ws);//вск
ok(oParser.parse()); ok(oParser.parse());
strictEqual( oParser.calculate().getValue(), 4); strictEqual( oParser.calculate().getValue(), 1);
}) })
......
...@@ -917,9 +917,11 @@ cFormulaFunction.DateAndTime = { ...@@ -917,9 +917,11 @@ cFormulaFunction.DateAndTime = {
default: default:
return new cNumber(wk); return new cNumber(wk);
} }
else else{
wk = parseInt(((dt-startOfYear)/c_msPerDay+iso[startOfYear.getDay()]+7)/7);
return new cNumber(wk); return new cNumber(wk);
} }
}
if ( arg0 instanceof cArea || arg0 instanceof cArea3D ){ if ( arg0 instanceof cArea || arg0 instanceof cArea3D ){
arg0 = arg0.cross(arguments[1].first); arg0 = arg0.cross(arguments[1].first);
...@@ -952,41 +954,29 @@ cFormulaFunction.DateAndTime = { ...@@ -952,41 +954,29 @@ cFormulaFunction.DateAndTime = {
switch (arg1.getValue()){ switch (arg1.getValue()){
case 1: /* 1 (Sunday) through 7 (Saturday) */ case 1: /* 1 (Sunday) through 7 (Saturday) */
case 17:/* 1 (Sunday) through 7 (Saturday) */ case 17:/* 1 (Sunday) through 7 (Saturday) */
// weekdayStartDay = [10,4,5,6,7,8,9]; weekdayStartDay = [0,1,2,3,4,5,6];
// type = 0; break;
//weekdayStartDay = [13,7,8,9,10,11,12];
// break;
case 2: /* 1 (Monday) through 7 (Sunday) */ case 2: /* 1 (Monday) through 7 (Sunday) */
case 11:/* 1 (Monday) through 7 (Sunday) */ case 11:/* 1 (Monday) through 7 (Sunday) */
// weekdayStartDay = [6,0,1,2,3,4,5]; weekdayStartDay = [6,0,1,2,3,4,5];
// type = 0; break;
// break;
case 12:/* 1 (Tuesday) through 7 (Monday) */ case 12:/* 1 (Tuesday) through 7 (Monday) */
// weekdayStartDay = [6,7,8,2,3,4,5]; weekdayStartDay = [5,6,0,1,2,3,4];
// type = 0; break;
// break;
case 13:/* 1 (Wednesday) through 7 (Tuesday) */ case 13:/* 1 (Wednesday) through 7 (Tuesday) */
// weekdayStartDay = [6,7,8,9,3,4,5]; weekdayStartDay = [4,5,6,0,1,2,3];
// type = 0; break;
// break;
case 14:/* 1 (Thursday) through 7 (Wednesday) */ case 14:/* 1 (Thursday) through 7 (Wednesday) */
// weekdayStartDay = [6,7,8,9,10,4,5]; weekdayStartDay = [3,4,5,6,0,1,2];
// type = 0; break;
// break;
case 15:/* 1 (Friday) through 7 (Thursday) */ case 15:/* 1 (Friday) through 7 (Thursday) */
// weekdayStartDay = [6,7,8,9,10,11,5]; weekdayStartDay = [2,3,4,5,6,0,1];
// weekdayStartDay = [5,6,7,8,9,10,4];
// weekdayStartDay = [6,7,1,2,3,4,5];
weekdayStartDay = [5,6,7,8,9,10,4];
type = 0;
break; break;
case 16:/* 1 (Saturday) through 7 (Friday) */ case 16:/* 1 (Saturday) through 7 (Friday) */
// weekdayStartDay = [6,7,8,9,10,11,12]; weekdayStartDay = [1,2,3,4,5,6,0];
weekdayStartDay = [6,0,1,2,3,4,5];
type = 0;
break; break;
case 21: case 21:
weekdayStartDay = [6,7,1,2,3,4,5]; weekdayStartDay = [6,7,8,9,10,4,5];
// { 6, 7, 8, 9, 10, 4, 5 } // { 6, 7, 8, 9, 10, 4, 5 }
type = 1; type = 1;
break; break;
......
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