connectivity/source/parse/sqlnode.cxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 691f47959df0260ccee3a54e8d43df33e8aae9b5
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Mon Jan 17 15:43:07 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jan 17 20:34:50 2022 +0100

    Resolves: tdf#146757 Use correct format index keys instead of wrong hack
    
    The hack worked by accident as long as the internal index
    constants didn't change. Which was the case with
    
        commit f7d0c6b42a0a5ec98876006cd5048589219be741
        CommitDate: Thu Sep 23 20:28:42 2021 +0200
    
            Sort ZF_STANDARD_NEWEXTENDED_DATE_... into ZF_STANDARD_DATE category
    
    convertDateString()
    Standard + 36 == old ZF_STANDARD_DATE + 6 => DATE_SYS_DDMMYYYY
    unchanged
    
    convertDateTimeString()
    Standard + 51 == old ZF_STANDARD_DATETIME + 1 => 
DATETIME_SYS_DDMMYYYY_HHMMSS
    became wrong nothing (no format assigned, empty DATE slot)
    
    convertTimeString()
    Standard + 41 == old ZF_STANDARD_TIME + 1 => TIME_HHMMSS
    became wrong ZF_STANDARD_DATE_SYS_DMMMMYYYY (DATE_SYS_DMMMMYYYY)
    
    So time 08:00 double 0.33333... was converted to string
    "30 December 1899" which then numeric was 0.
    
    Change-Id: I642e0a977d4e167f78537d20624e86721e518c54
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128507
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 0d6ab8d4ea7226db53d07dc158e176fe962fd8d9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128528
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Reviewed-by: Lionel Mamane <lio...@mamane.lu>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/connectivity/source/parse/sqlnode.cxx 
b/connectivity/source/parse/sqlnode.cxx
index 02056253c300..5247457d5b3d 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -217,7 +217,7 @@ OUString OSQLParseNode::convertDateString(const 
SQLParseNodeParameter& rParam, c
     Reference< XNumberFormatTypes >     xTypes(xSupplier->getNumberFormats(), 
UNO_QUERY);
 
     double fDate = 
DBTypeConversion::toDouble(aDate,DBTypeConversion::getNULLDate(xSupplier));
-    sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 36; // XXX hack
+    sal_Int32 nKey = 
xTypes->getFormatIndex(NumberFormatIndex::DATE_SYS_DDMMYYYY, rParam.rLocale);
     return rParam.xFormatter->convertNumberToString(nKey, fDate);
 }
 
@@ -229,7 +229,7 @@ OUString OSQLParseNode::convertDateTimeString(const 
SQLParseNodeParameter& rPara
     Reference< XNumberFormatTypes >  xTypes(xSupplier->getNumberFormats(), 
UNO_QUERY);
 
     double fDateTime = 
DBTypeConversion::toDouble(aDate,DBTypeConversion::getNULLDate(xSupplier));
-    sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 51; // XXX hack
+    sal_Int32 nKey = 
xTypes->getFormatIndex(NumberFormatIndex::DATETIME_SYS_DDMMYYYY_HHMMSS, 
rParam.rLocale);
     return rParam.xFormatter->convertNumberToString(nKey, fDateTime);
 }
 
@@ -242,7 +242,7 @@ OUString OSQLParseNode::convertTimeString(const 
SQLParseNodeParameter& rParam, c
     Reference< XNumberFormatTypes >  xTypes(xSupplier->getNumberFormats(), 
UNO_QUERY);
 
     double fTime = DBTypeConversion::toDouble(aTime);
-    sal_Int32 nKey = xTypes->getStandardIndex(rParam.rLocale) + 41; // XXX hack
+    sal_Int32 nKey = xTypes->getFormatIndex(NumberFormatIndex::TIME_HHMMSS, 
rParam.rLocale);
     return rParam.xFormatter->convertNumberToString(nKey, fTime);
 }
 

Reply via email to