[Libreoffice-commits] core.git: svl/qa svl/source

Eike Rathke erack at redhat.com
Tue Aug 2 21:52:47 UTC 2016


 svl/qa/unit/svl.cxx             |    4 ++--
 svl/source/numbers/zforscan.cxx |   12 ++++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 88134dcba680418496f7a1c70a47fde0159ce390
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Aug 2 23:46:22 2016 +0200

    break the Excel rule for YMD and DMY, tdf#101147 follow-up
    
    Clearly in {HH YYYY-MM-DD} the MM should not be minute. Also not in
    {HH DD.MM.YY}. Don't follow every bullshit. Period.
    
    It is debatable how to treat MDY, {HH:MM DD/YY} should be different from
    {HH MM/DD/YY}, Excel ironically takes both as minute, even in an en-US locale.
    
    Change-Id: I13d39a36294e3c40cc0e9bf72026804b299bb264

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 6af6566..f4c033d 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1132,8 +1132,8 @@ void Test::testUserDefinedNumberFormats()
         checkPreviewString(aFormatter, sCode, -12.0, eLang, sExpected);
     }
     {  // tdf#995339: detect SSMM as second minute
-        sCode = "SS:MM:HH DD/MM/YY"; // Month not detected by Excel, so we do not neither to keep compatibility
-        sExpected = "54:23:03 02/23/00";
+        sCode = "SS:MM:HH DD/MM/YY"; // Month not detected by Excel, but we do not follow that.
+        sExpected = "54:23:03 02/01/00";
         checkPreviewString(aFormatter, sCode, M_PI, eLang, sExpected);
     }
     {  // tdf#99996: better algorithm for fraction representation
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 8de7ac7..a59617d 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -1156,9 +1156,12 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
                    Minute if one of:
                    * preceded by time keyword H (ignoring separators)
                    * followed by time keyword S (ignoring separators)
-                   * H or S was detected
+                   * H or S was detected and this is the first M following
                    * preceded by '[' amount bracket
                    Else month.
+                   That are the Excel rules. BUT, we break it because certainly
+                   in something like {HH YYYY-MM-DD} the MM is NOT meant to be
+                   minute, so not if MM is between YY and DD or DD and YY.
                 */
                 nIndexPre = PreviousKeyword(i);
                 nIndexNex = NextKeyword(i);
@@ -1166,7 +1169,12 @@ sal_Int32 ImpSvNumberformatScan::ScanType()
                     nIndexPre == NF_KEY_HH  ||      // HH
                     nIndexNex == NF_KEY_S   ||      // S
                     nIndexNex == NF_KEY_SS  ||      // SS
-                    bIsTimeDetected         ||      // tdf#101147
+                    (bIsTimeDetected &&
+                     !(((nIndexPre == NF_KEY_YY || nIndexPre == NF_KEY_YYYY) &&
+                        (nIndexNex == NF_KEY_D  || nIndexNex == NF_KEY_DD)) ||
+                       ((nIndexPre == NF_KEY_D  || nIndexPre == NF_KEY_DD) &&
+                        (nIndexNex == NF_KEY_YY || nIndexNex == NF_KEY_YYYY)))
+                    )                       ||      // tdf#101147
                     PreviousChar(i) == '['  )       // [M
                 {
                     eNewType = css::util::NumberFormat::TIME;


More information about the Libreoffice-commits mailing list