summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/postgresql/pq_tools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/postgresql/pq_tools.cxx')
-rw-r--r--connectivity/source/drivers/postgresql/pq_tools.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index ccce76f018c1..a9be424d9b34 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -107,6 +107,7 @@ namespace pq_sdbc_driver
OUString date2String( const com::sun::star::util::Date & x )
{
+ // TODO FIXME: replace by DBTypeConversion::toDateString
char buffer[64];
sprintf( buffer, "%d-%02d-%02d", x.Year, x.Month, x.Day );
return OUString::createFromAscii( buffer );
@@ -114,6 +115,7 @@ OUString date2String( const com::sun::star::util::Date & x )
com::sun::star::util::Date string2Date( const OUString &date )
{
+ // TODO FIXME: replace by DBTypeConversion::toDate (if it parses the same format)
// Format: Year-Month-Day
com::sun::star::util::Date ret;
@@ -135,15 +137,17 @@ com::sun::star::util::Date string2Date( const OUString &date )
OUString time2String( const com::sun::star::util::Time & x )
{
- char buffer[64];
- sprintf( buffer, "%02d:%02d:%02d.%02d", x.Hours, x.Minutes, x.Seconds, x.HundredthSeconds );
+ // TODO FIXME: replace by DBTypeConversion::toTimeString
+ const size_t buflen = 19;
+ char buffer[buflen];
+ snprintf( buffer, buflen, "%02d:%02d:%02d.%09d", x.Hours, x.Minutes, x.Seconds, x.NanoSeconds );
return OUString::createFromAscii( buffer );
-
}
com::sun::star::util::Time string2Time( const OUString & time )
{
+ // TODO FIXME: replace by DBTypeConversion::toTime
com::sun::star::util::Time ret;
sal_Unicode temp[4];
@@ -163,7 +167,8 @@ com::sun::star::util::Time string2Time( const OUString & time )
if( time.getLength() >9 )
{
- ret.HundredthSeconds = (sal_Int32)rtl_ustr_toInt32( &time.getStr()[9] , 10 );
+ // FIXME does not take into account shorter precision
+ ret.NanoSeconds = (sal_Int32)rtl_ustr_toInt32( &time.getStr()[9] , 10 );
}
return ret;
@@ -173,16 +178,18 @@ com::sun::star::util::Time string2Time( const OUString & time )
OUString dateTime2String( const com::sun::star::util::DateTime & x )
{
+ // TODO FIXME: replace by DBTypeConversion::toDateTimeString
char buffer[128];
- sprintf( buffer, "%d-%02d-%02d %02d:%02d:%02d.%02d",
+ sprintf( buffer, "%d-%02d-%02d %02d:%02d:%02d.%09d",
x.Year, x.Month, x.Day,
- x.Hours, x.Minutes, x.Seconds, x.HundredthSeconds );
+ x.Hours, x.Minutes, x.Seconds, x.NanoSeconds );
return OUString::createFromAscii( buffer );
}
com::sun::star::util::DateTime string2DateTime( const OUString & dateTime )
{
+ // TODO FIXME: replace by DBTypeConversion::toDateTime (if same format)
int space = dateTime.indexOf( ' ' );
com::sun::star::util::DateTime ret;
@@ -197,7 +204,7 @@ com::sun::star::util::DateTime string2DateTime( const OUString & dateTime )
ret.Hours = time.Hours;
ret.Minutes = time.Minutes;
ret.Seconds = time.Seconds;
- ret.HundredthSeconds = time.HundredthSeconds;
+ ret.NanoSeconds = time.NanoSeconds;
}
return ret;
}