summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-09-09 13:18:42 +0200
committerEike Rathke <erack@redhat.com>2016-09-16 20:59:35 +0000
commit13ba2592254c861dafa337121902168d83f610bd (patch)
tree2cc51e1e6abd228842f0412cda273ee7b3df35b9
parent5588b4fbf7580d2d2ce1fd4441a997d549767ccb (diff)
tdf#101541 function WORKDAY.INTL not working properly
When holidays are adjacent to weekend days, wrong results occurred. Change-Id: I9ec86e00f1a62ea941ff70617a1b448601aff9cc Reviewed-on: https://gerrit.libreoffice.org/28771 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> (cherry picked from commit 5e9d5eeb8a33fdcc500377d9eace40b5f5a7f750) Reviewed-on: https://gerrit.libreoffice.org/28970 Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sc/source/core/tool/interpr2.cxx22
1 files changed, 13 insertions, 9 deletions
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 773eabae412f..38523e5e7e52 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -538,14 +538,16 @@ void ScInterpreter::ScWorkday_MS()
size_t nRef = 0;
while ( nDays )
{
- while ( nRef < nMax && nSortArray.at( nRef ) < nDate )
- nRef++;
- if ( !( nRef < nMax && nSortArray.at( nRef ) == nDate ) || nRef >= nMax )
- nDays--;
-
do
+ {
++nDate;
+ }
while ( bWeekendMask[ GetDayOfWeek( nDate ) ] ); //jump over weekend day(s)
+
+ while ( nRef < nMax && nSortArray.at( nRef ) < nDate )
+ nRef++;
+ if ( !( nRef < nMax && nSortArray.at( nRef ) == nDate ) || nRef >= nMax )
+ nDays--;
}
}
else
@@ -553,14 +555,16 @@ void ScInterpreter::ScWorkday_MS()
sal_Int16 nRef = nMax - 1;
while ( nDays )
{
+ do
+ {
+ --nDate;
+ }
+ while ( bWeekendMask[ GetDayOfWeek( nDate ) ] ); //jump over weekend day(s)
+
while ( nRef >= 0 && nSortArray.at( nRef ) > nDate )
nRef--;
if ( !( nRef >= 0 && nSortArray.at( nRef ) == nDate ) || nRef < 0 )
nDays++;
-
- do
- --nDate;
- while ( bWeekendMask[ GetDayOfWeek( nDate ) ] ); //jump over weekend day(s)
}
}
PushDouble( ( double ) ( nDate - nNullDate ) );