diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-01-02 16:54:40 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-01-02 20:09:07 +0100 |
commit | e0a22d47d281f61f51ead6d2831cd53c15036ffe (patch) | |
tree | 8864ee34aadde6b6933fedd6783b7850e3b104fd /connectivity/source/drivers | |
parent | a3488acbeb3b618cf5b6b1a93608c58d0eb9d646 (diff) |
tdf#71007: Pass also fractional seconds to/from Firebird
We know that ISC_TIME is simply in units of
seconds/ISC_TIME_SECONDS_PRECISION.
Change-Id: I2896f53c2d32a773c535e19f55dd1314abd18ec9
Reviewed-on: https://gerrit.libreoffice.org/47266
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'connectivity/source/drivers')
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 9 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/ResultSet.cxx | 12 |
2 files changed, 16 insertions, 5 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 35cd4579be1a..f951537fde28 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -462,6 +462,10 @@ void SAL_CALL OPreparedStatement::setTime( sal_Int32 nIndex, const css::util::Ti ISC_TIME aISCTime; isc_encode_sql_time(&aCTime, &aISCTime); + // Here we "know" that ISC_TIME is simply in units of seconds/ISC_TIME_SECONDS_PRECISION with no + // other funkiness, so we can simply add the fraction of a second. + aISCTime += rTime.NanoSeconds / (1000000000 / ISC_TIME_SECONDS_PRECISION); + setValue< ISC_TIME >(nIndex, aISCTime, SQL_TYPE_TIME); } @@ -478,6 +482,9 @@ void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 nIndex, const DateTime& ISC_TIMESTAMP aISCTimestamp; isc_encode_timestamp(&aCTime, &aISCTimestamp); + // As in previous function + aISCTimestamp.timestamp_time += rTimestamp.NanoSeconds / (1000000000 / ISC_TIME_SECONDS_PRECISION); + setValue< ISC_TIMESTAMP >(nIndex, aISCTimestamp, SQL_TIMESTAMP); } diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx index caf7b540ade5..2d440097151e 100644 --- a/connectivity/source/drivers/firebird/ResultSet.cxx +++ b/connectivity/source/drivers/firebird/ResultSet.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -526,9 +526,12 @@ Time OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*n struct tm aCTime; isc_decode_sql_time(&aISCTime, &aCTime); - // first field is nanoseconds -- not supported in firebird or struct tm. + // First field is nanoseconds. // last field denotes UTC (true) or unknown (false) - return Time(0, aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, false); + // Here we "know" that ISC_TIME is simply in units of seconds/ISC_TIME_SECONDS_PRECISION + // with no other funkiness, so we can get the fractional seconds easily. + return Time((aISCTime % ISC_TIME_SECONDS_PRECISION) * (1000000000 / ISC_TIME_SECONDS_PRECISION), + aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, false); } else { @@ -546,7 +549,8 @@ DateTime OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT struct tm aCTime; isc_decode_timestamp(&aISCTimestamp, &aCTime); - return DateTime(0, //nanoseconds, not supported + // Ditto here, see comment in previous function about ISC_TIME and ISC_TIME_SECONDS_PRECISION. + return DateTime((aISCTimestamp.timestamp_time % ISC_TIME_SECONDS_PRECISION) * (1000000000 / ISC_TIME_SECONDS_PRECISION), //nanoseconds aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, |