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
df10a213
Commit
df10a213
authored
Aug 02, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify cNETWORKDAYS function
parent
dd0b7e89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
96 deletions
+35
-96
cell/model/FormulaObjects/dateandtimeFunctions.js
cell/model/FormulaObjects/dateandtimeFunctions.js
+35
-96
No files found.
cell/model/FormulaObjects/dateandtimeFunctions.js
View file @
df10a213
...
...
@@ -1159,121 +1159,61 @@
cNETWORKDAYS
.
prototype
.
argumentsMax
=
3
;
cNETWORKDAYS
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cNETWORKDAYS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
arg0
=
arg0
.
cross
(
arguments
[
1
]);
}
else
if
(
arg0
instanceof
cArray
)
{
arg0
=
arg0
.
getElementRowCol
(
0
,
0
);
}
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
=
arg1
.
getElementRowCol
(
0
,
0
);
}
var
oArguments
=
this
.
_prepareArguments
([
arg
[
0
],
arg
[
1
]],
arguments
[
1
]);
var
argClone
=
oArguments
.
args
;
arg
0
=
arg0
.
tocNumber
();
arg
1
=
arg1
.
tocNumber
();
arg
Clone
[
0
]
=
argClone
[
0
]
.
tocNumber
();
arg
Clone
[
1
]
=
argClone
[
1
]
.
tocNumber
();
if
(
arg0
instanceof
cError
)
{
return
this
.
value
=
arg0
;
}
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
var
argError
;
if
(
argError
=
this
.
_checkErrorArg
(
argClone
))
{
return
this
.
value
=
argError
;
}
var
val0
=
arg0
.
getValue
(),
val1
=
arg1
.
getValue
(),
dif
,
count
=
0
;
var
arg0
=
argClone
[
0
],
arg1
=
argClone
[
1
],
arg2
=
arg
[
2
];
var
val0
=
arg0
.
getValue
(),
val1
=
arg1
.
getValue
();
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
);
}
if
(
val1
<
0
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
if
(
!
AscCommon
.
bDate1904
)
{
if
(
val1
<
60
)
{
val1
=
new
Date
((
val1
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
);
}
else
if
(
val1
==
60
)
{
val1
=
new
Date
((
val1
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
);
}
else
{
val1
=
new
Date
((
val1
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
);
}
}
else
{
val1
=
new
Date
((
val1
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
);
}
var
holidays
=
[],
i
;
val0
=
getCorrectDate
(
val0
);
val1
=
getCorrectDate
(
val1
);
if
(
arg2
)
{
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
();
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
++
)
{
holidays
[
i
]
=
Date
.
prototype
.
getDateFromExcel
(
holidays
[
i
].
getValue
());
}
var
calcDate
=
function
()
{
var
count
=
0
;
var
start
=
val0
;
var
end
=
val1
;
var
dif
=
val1
-
val0
;
if
(
dif
<
0
){
start
=
val1
;
end
=
val0
;
}
function
includeInHolidays
(
date
)
{
for
(
var
i
=
0
;
i
<
holidays
.
length
;
i
++
)
{
if
(
date
.
getTime
()
==
holidays
[
i
].
getTime
())
{
return
false
;
var
difAbs
=
(
end
-
start
);
difAbs
=
(
difAbs
+
(
c_msPerDay
)
)
/
c_msPerDay
;
for
(
var
i
=
0
;
i
<
difAbs
;
i
++
)
{
var
date
=
new
Date
(
start
);
date
.
setUTCDate
(
start
.
getUTCDate
()
+
i
);
if
(
date
.
getUTCDay
()
!==
6
&&
date
.
getUTCDay
()
!==
0
&&
_includeInHolidays
(
date
,
holidays
))
{
count
++
;
}
}
return
true
;
}
var
start
=
val0
;
var
end
=
val1
;
dif
=
val1
-
val0
;
if
(
dif
<
0
){
start
=
val1
;
end
=
val0
;
}
var
difAbs
=
(
end
-
start
);
difAbs
=
(
difAbs
+
(
c_msPerDay
)
)
/
c_msPerDay
;
return
new
cNumber
((
dif
<
0
?
-
1
:
1
)
*
count
);
}
;
for
(
i
=
0
;
i
<
difAbs
;
i
++
)
{
var
date
=
new
Date
(
start
);
date
.
setUTCDate
(
start
.
getUTCDate
()
+
i
);
if
(
date
.
getUTCDay
()
!=
6
&&
date
.
getUTCDay
()
!=
0
&&
includeInHolidays
(
date
))
{
count
++
;
}
}
return
this
.
value
=
new
cNumber
((
dif
<
0
?
-
1
:
1
)
*
count
);
return
this
.
value
=
calcDate
();
};
/**
...
...
@@ -1292,7 +1232,6 @@
cNETWORKDAYS_INTL
.
prototype
.
argumentsMax
=
4
;
cNETWORKDAYS_INTL
.
prototype
.
numFormat
=
AscCommonExcel
.
cNumFormatNone
;
cNETWORKDAYS_INTL
.
prototype
.
Calculate
=
function
(
arg
)
{
var
t
=
this
;
var
tempArgs
=
arg
[
2
]
?
[
arg
[
0
],
arg
[
1
],
arg
[
2
]]
:
[
arg
[
0
],
arg
[
1
]];
var
oArguments
=
this
.
_prepareArguments
(
tempArgs
,
arguments
[
1
]);
var
argClone
=
oArguments
.
args
;
...
...
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