From 3665652285f29021f4a12cc493fe8791b6afc126 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 5 Jan 2016 15:42:27 +0100 Subject: 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 Reviewed-by: Markus Mohrhard --- sc/source/core/tool/interpr2.cxx | 7 +++++-- 1 file 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()); -- cgit v1.2.3