You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2024/01/17 02:14:14 UTC

(openoffice) branch odf-1.3 updated: Add support for weekday types 11-17 to the WEEKDAY function, as required by ODF 1.3.

This is an automated email from the ASF dual-hosted git repository.

damjan pushed a commit to branch odf-1.3
in repository https://gitbox.apache.org/repos/asf/openoffice.git


The following commit(s) were added to refs/heads/odf-1.3 by this push:
     new b19cfbb97e Add support for weekday types 11-17 to the WEEKDAY function, as required by ODF 1.3.
b19cfbb97e is described below

commit b19cfbb97e8a126fb5034f0ea11b69365cb8e0ae
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Wed Jan 17 04:12:39 2024 +0200

    Add support for weekday types 11-17 to the WEEKDAY function,
    as required by ODF 1.3.
    
    Patch by: me
---
 main/sc/source/core/tool/interpr2.cxx | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/main/sc/source/core/tool/interpr2.cxx b/main/sc/source/core/tool/interpr2.cxx
index 2d8dfcd2d9..0cf58ef3f8 100644
--- a/main/sc/source/core/tool/interpr2.cxx
+++ b/main/sc/source/core/tool/interpr2.cxx
@@ -212,16 +212,37 @@ void ScInterpreter::ScGetDayOfWeek()
         Date aDate = *(pFormatter->GetNullDate());
         aDate += (long)::rtl::math::approxFloor(GetDouble());
         int nVal = (int) aDate.GetDayOfWeek();
+        // Weekday Type    1   2   3   11  12  13  14  15  16  17
+        // ------------------------------------------------------
+        // Sunday          1   7   6   7   6   5   4   3   2   1
+        // Monday          2   1   0   1   7   6   5   4   3   2
+        // Tuesday         3   2   1   2   1   7   6   5   4   3
+        // Wednesday       4   3   2   3   2   1   7   6   5   4
+        // Thursday        5   4   3   4   3   2   1   7   6   5
+        // Friday          6   5   4   5   4   3   2   1   7   6
+        // Saturday        7   6   5   6   5   4   3   2   1   7
         if (nFlag == 1)
         {
             if (nVal == 6)
                 nVal = 1;
             else
                 nVal += 2;
+            PushInt(nVal);
         }
         else if (nFlag == 2)
+        {
             nVal += 1;
-        PushInt( nVal );
+            PushInt(nVal);
+        }
+        else if (nFlag == 3)
+            PushInt(nVal);
+        else if (11 <= nFlag && nFlag <= 17)
+        {
+            nVal = ((nVal + (18 - nFlag)) % 7) + 1;
+            PushInt(nVal);
+        }
+        else
+            PushIllegalArgument();
     }
 }