Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
6a95a35c
Commit
6a95a35c
authored
Aug 02, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify cWORKDAY function
parent
16eabedf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
94 deletions
+38
-94
cell/model/FormulaObjects/dateandtimeFunctions.js
cell/model/FormulaObjects/dateandtimeFunctions.js
+38
-94
No files found.
cell/model/FormulaObjects/dateandtimeFunctions.js
View file @
6a95a35c
...
...
@@ -1707,121 +1707,65 @@
cWORKDAY
.
prototype
.
argumentsMax
=
3
;
cWORKDAY
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cWORKDAY
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
var
t
=
this
;
var
oArguments
=
this
.
_prepareArguments
([
arg
[
0
],
arg
[
1
]],
arguments
[
1
]);
var
argClone
=
oArguments
.
args
;
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
]);
}
else
if
(
arg0
instanceof
cArray
)
{
arg0
=
arg0
.
getElementRowCol
(
0
,
0
);
}
argClone
[
0
]
=
argClone
[
0
].
tocNumber
();
argClone
[
1
]
=
argClone
[
1
].
tocNumber
();
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
=
arg1
.
getElementRowCol
(
0
,
0
);
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
arg0
=
arg0
.
tocNumber
();
arg1
=
arg1
.
tocNumber
();
if
(
arg0
instanceof
cError
)
{
return
this
.
value
=
arg0
;
}
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
}
var
arg0
=
argClone
[
0
],
arg1
=
argClone
[
1
],
arg2
=
arg
[
2
];
var
val0
=
arg0
.
getValue
(),
holidays
=
[],
i
;
if
(
val0
<
0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
if
(
!
AscCommon
.
bDate1904
)
{
if
(
val0
<
60
)
{
val0
=
new
Date
((
val0
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
);
}
else
if
(
val0
==
60
)
{
val0
=
new
Date
((
val0
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
);
}
else
{
val0
=
new
Date
((
val0
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
);
}
}
else
{
val0
=
new
Date
((
val0
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
);
}
val0
=
getCorrectDate
(
val0
);
if
(
arg2
)
{
if
(
arg2
instanceof
cArea
||
arg2
instanceof
cArea3D
)
{
var
arr
=
arg2
.
getValue
();
for
(
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
instanceof
cNumber
&&
arr
[
i
].
getValue
()
>=
0
)
{
holidays
.
push
(
arr
[
i
]);
}
}
}
else
if
(
arg2
instanceof
cArray
)
{
arg2
.
foreach
(
function
(
elem
,
r
,
c
)
{
if
(
elem
instanceof
cNumber
)
{
holidays
.
push
(
elem
);
}
else
if
(
elem
instanceof
cString
)
{
var
res
=
g_oFormatParser
.
parse
(
elem
.
getValue
());
if
(
res
&&
res
.
bDateTime
&&
res
.
value
>=
0
)
{
holidays
.
push
(
new
cNumber
(
parseInt
(
res
.
value
)));
}
}
})
}
//Holidays
var
holidays
=
getHolidays
(
arg2
);
if
(
holidays
instanceof
cError
)
{
return
this
.
value
=
holidays
;
}
for
(
i
=
0
;
i
<
holidays
.
length
;
i
++
)
{
if
(
!
AscCommon
.
bDate1904
)
{
if
(
holidays
[
i
].
getValue
()
<
60
)
{
holidays
[
i
]
=
new
Date
((
holidays
[
i
].
getValue
()
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
);
}
else
if
(
holidays
[
i
]
==
60
)
{
holidays
[
i
]
=
new
Date
((
holidays
[
i
].
getValue
()
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
);
}
else
{
holidays
[
i
]
=
new
Date
((
holidays
[
i
].
getValue
()
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
);
}
}
else
{
holidays
[
i
]
=
new
Date
((
holidays
[
i
].
getValue
()
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
);
}
}
var
calcDate
=
function
(){
var
dif
=
arg1
.
getValue
(),
count
=
1
,
dif1
=
1
,
val
,
date
=
val0
;
function
notAHolidays
(
date
)
{
for
(
var
i
=
0
;
i
<
holidays
.
length
;
i
++
)
{
if
(
date
.
getTime
()
==
holidays
[
i
].
getTime
())
{
return
false
;
while
(
Math
.
abs
(
dif
)
>
count
)
{
date
=
new
Date
(
val0
.
getTime
()
+
dif1
*
c_msPerDay
);
if
(
date
.
getUTCDay
()
!==
6
&&
date
.
getUTCDay
()
!==
0
&&
_includeInHolidays
(
date
,
holidays
))
{
count
++
;
}
dif
>=
0
?
dif1
++
:
dif1
--
;
//если последняя итерация
if
(
!
(
Math
.
abs
(
dif
)
>
count
)){
//проверяем не оказалось ли следом выходных. если оказались - прибавляем
date
=
new
Date
(
val0
.
getTime
()
+
dif1
*
c_msPerDay
);
if
(
date
.
getUTCDay
()
===
6
){
dif1
+=
2
;
}
}
}
return
true
;
}
var
dif
=
arg1
.
getValue
(),
count
=
1
,
dif1
=
dif
>
0
?
1
:
dif
<
0
?
-
1
:
0
,
val
,
date
=
val0
;
while
(
Math
.
abs
(
dif
)
>
count
)
{
date
=
new
Date
(
val0
.
getTime
()
+
dif1
*
c_msPerDay
);
if
(
date
.
getUTCDay
()
!=
6
&&
date
.
getUTCDay
()
!=
0
&&
notAHolidays
(
date
))
{
count
++
;
}
dif
>=
0
?
dif1
++
:
dif1
--
;
}
date
=
new
Date
(
val0
.
getTime
()
+
dif1
*
c_msPerDay
);
val
=
date
.
getExcelDate
();
val
=
date
.
getExcelDate
();
if
(
val
<
0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
if
(
val
<
0
)
{
return
new
cError
(
cErrorType
.
not_numeric
);
}
return
this
.
setCalcValue
(
new
cNumber
(
val
),
14
);
};
return
t
.
setCalcValue
(
new
cNumber
(
val
)
);
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function
cWORKDAY_INTL
()
{
cBaseFunction
.
call
(
this
,
"
WORKDAY.INTL
"
);
}
cWORKDAY_INTL
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cWORKDAY_INTL
.
prototype
.
constructor
=
cWORKDAY_INTL
;
return
this
.
value
=
calcDate
(
);
}
;
/**
* @constructor
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment