diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-30 09:05:57 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-30 11:33:12 +0100 |
commit | 3f56234ecb4b8b07becfdcbbc3d7facbd95e6f60 (patch) | |
tree | 5ef704087c17de9b317e6f146a02d484f6f44d63 /connectivity/source/drivers/firebird/ResultSet.cxx | |
parent | 73720f9a8330495b5dc130d761c577faa1a00ed1 (diff) |
Implement set[Date|Time]. (firebird-sdbc)
Change-Id: Ibf3bc34f316c0a299afc2e015ff4c49ad57099a5
Diffstat (limited to 'connectivity/source/drivers/firebird/ResultSet.cxx')
-rw-r--r-- | connectivity/source/drivers/firebird/ResultSet.cxx | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx index a0a4f58290f3..21d4152e75fa 100644 --- a/connectivity/source/drivers/firebird/ResultSet.cxx +++ b/connectivity/source/drivers/firebird/ResultSet.cxx @@ -27,6 +27,7 @@ #include <propertyids.hxx> #include <rtl/string.hxx> #include <rtl/ustrbuf.hxx> +#include <time.h> #include <TConnection.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -479,26 +480,37 @@ OUString SAL_CALL OResultSet::getString(sal_Int32 columnIndex) return safelyRetrieveValue< OUString >(columnIndex); } -Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +Date SAL_CALL OResultSet::getDate(sal_Int32 nIndex) + throw(SQLException, RuntimeException) { - (void) columnIndex; - return Time(); -// return safelyRetrieveValue(columnIndex); + ISC_DATE aISCDate = safelyRetrieveValue< ISC_DATE >(nIndex); + + struct tm aCTime; + isc_decode_sql_date(&aISCDate, &aCTime); + + return Date(aCTime.tm_mday, aCTime.tm_mon, aCTime.tm_year); } -DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +Time SAL_CALL OResultSet::getTime(sal_Int32 nIndex) + throw(SQLException, RuntimeException) { - (void) columnIndex; - return DateTime(); // TODO: implement -// return safelyRetrieveValue(columnIndex); + ISC_TIME aISCTime = safelyRetrieveValue< ISC_TIME >(nIndex); + + struct tm aCTime; + isc_decode_sql_time(&aISCTime, &aCTime); + + // first field is nanoseconds -- not supported in firebird or struct tm. + // last field denotes UTC (true) or unknown (false) + return Time(0, aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, false); } -Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) +DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { (void) columnIndex; - return Date(); // TODO: implement + return DateTime(); // TODO: implement // return safelyRetrieveValue(columnIndex); } + // ------------------------------------------------------------------------- uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) { |