summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-01-05 15:42:27 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-01-18 21:45:06 +0000
commit3665652285f29021f4a12cc493fe8791b6afc126 (patch)
tree0a5c7c95bc05ad8ddee9eb322c4f621719119524
parent86a15daa99f57ddf5ddbdb2d67ed9d69e3bbbf37 (diff)
tdf#96198 accept WEEKNUM with only one parameter, tdf#50950 follow-up
Loading ISOWEEKNUM(date) maps to WEEKNUM(date) so accept the actual ISOWEEKNUM parameter count defined in ODFF. This also ensures forward compatibility with 5.1 where 3e5deb8ccfaf0b73fb6cf394822e560dc036a686 (cherry picked from commit 15494f0f99d1cf6f75e8c2996377b242af247bbf) converts ISOWEEKNUM(date,mode) to real ISOWEEKNUM(date) if mode!=1 as there is no matching WEEKNUM(date,mode) defined. This WEEKNUM here never implemented the ODFF WEEKNUM but a mix of ISOWEEKNUM and something undefined different. Change-Id: Ibd0d4483486a1db28cc600821baae9f13b9dd687 Reviewed-on: https://gerrit.libreoffice.org/21118 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r--sc/source/core/tool/interpr2.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 84a5bff3d6bc..d82bc29eaff9 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -207,9 +207,12 @@ void ScInterpreter::ScGetDayOfWeek()
void ScInterpreter::ScGetWeekOfYear()
{
- if ( MustHaveParamCount( GetByte(), 2 ) )
+ sal_uInt8 nParamCount = GetByte();
+ if ( MustHaveParamCount( nParamCount, 1, 2 ) )
{
- short nFlag = (short) ::rtl::math::approxFloor(GetDouble());
+ // Without mode parameter calculate ISO 8601 week starting on Monday
+ // like ISOWEEKNUM(), which this is loaded from.
+ short nFlag = (nParamCount == 1) ? 0 : (short) ::rtl::math::approxFloor(GetDouble());
Date aDate = *(pFormatter->GetNullDate());
aDate += (long)::rtl::math::approxFloor(GetDouble());