summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-01-17 15:43:07 +0100
committerEike Rathke <erack@redhat.com>2022-01-17 18:54:40 +0100
commit0d6ab8d4ea7226db53d07dc158e176fe962fd8d9 (patch)
tree0d939e79b14cf9404dea43dfa8a855baab36b5c8 /connectivity
parent52b15c66c90b53f0e663acfcf1b9cdb49c3d564d (diff)
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 <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/parse/sqlnode.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index 3c3feed5db21..a5d711d9da16 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);
}