Kaydet (Commit) e0a22d47 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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/47266Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
üst a3488acb
/* -*- 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);
}
......
/* -*- 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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment