[Libreoffice-commits] core.git: 5 commits - connectivity/source include/connectivity
Lionel Elie Mamane
lionel at mamane.lu
Thu Jun 27 00:30:43 PDT 2013
connectivity/source/commontools/dbconversion.cxx | 28 ++++++++++++++++-------
connectivity/source/drivers/jdbc/Timestamp.cxx | 3 +-
include/connectivity/dbconversion.hxx | 2 +
3 files changed, 24 insertions(+), 9 deletions(-)
New commits:
commit 1b0a43142b27286e717f63c90363625a1aeff74c
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jun 27 08:59:58 2013 +0200
new dbtools::DBTypeConversion::toTimeStringS for time in second precision
(no fractional second)
Change-Id: I8bf448783b24fceae9a750f40887d6296999b203
diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx
index 92feaca..81248d5 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -81,6 +81,17 @@ namespace dbtools
return OUString::createFromAscii(s);
}
//------------------------------------------------------------------
+ OUString DBTypeConversion::toTimeStringS(const Time& rTime)
+ {
+ std::ostringstream ostr;
+ using std::setw;
+ ostr.fill('0');
+ ostr << setw(2) << rTime.Hours << ":"
+ << setw(2) << rTime.Minutes << ":"
+ << setw(2) << rTime.Seconds;
+ return OUString::createFromAscii(ostr.str().c_str());
+ }
+ //------------------------------------------------------------------
OUString DBTypeConversion::toTimeString(const Time& rTime)
{
std::ostringstream ostr;
@@ -92,7 +103,6 @@ namespace dbtools
<< setw(9) << rTime.NanoSeconds;
return OUString::createFromAscii(ostr.str().c_str());
}
-
//------------------------------------------------------------------
OUString DBTypeConversion::toDateTimeString(const DateTime& _rDateTime)
{
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
index 5337330..5080001 100644
--- a/connectivity/source/drivers/jdbc/Timestamp.cxx
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -104,7 +104,7 @@ java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_
// Convert parameters
OUString sDateStr;
// java.sql.Time supports only whole seconds...
- sDateStr = ::dbtools::DBTypeConversion::toTimeString(_rOut).copy(0, 8);
+ sDateStr = ::dbtools::DBTypeConversion::toTimeStringS(_rOut);
args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
// Turn off Java-Call for the constructor
diff --git a/include/connectivity/dbconversion.hxx b/include/connectivity/dbconversion.hxx
index 9536c79..4bc0ed7 100644
--- a/include/connectivity/dbconversion.hxx
+++ b/include/connectivity/dbconversion.hxx
@@ -141,6 +141,8 @@ namespace dbtools
// return the date in the format %04d-%02d-%02d
static OUString toDateString(const ::com::sun::star::util::Date& rDate);
+ // return the time in the format %02d:%02d:%02d
+ static OUString toTimeStringS(const ::com::sun::star::util::Time& rTime);
// return the time in the format %02d:%02d:%02d.%09d
static OUString toTimeString(const ::com::sun::star::util::Time& rTime);
// return the DateTime in the format %04d-%02d-%02d %02d:%02d:%02d.%09d
commit 83dc5c075884dfdb71952aa2617cc6f63dcc56ad
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jun 27 08:51:59 2013 +0200
fdo#66216 JDBC no fractional second in time format
fractional second allowed in timestamp. But not in time. Don't ask why.
Change-Id: I5415889ab4cf4835b8b0db7363b7d9eb0a332393
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
index a1d1bcd..5337330 100644
--- a/connectivity/source/drivers/jdbc/Timestamp.cxx
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -103,7 +103,8 @@ java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_
jvalue args[1];
// Convert parameters
OUString sDateStr;
- sDateStr = ::dbtools::DBTypeConversion::toTimeString(_rOut);
+ // java.sql.Time supports only whole seconds...
+ sDateStr = ::dbtools::DBTypeConversion::toTimeString(_rOut).copy(0, 8);
args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
// Turn off Java-Call for the constructor
commit ac146c16c0f4707aa8a26e479902a124e4e1b7e4
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jun 27 08:51:02 2013 +0200
fdo#66216 fix DBTypeConversion::toTime overflow
Change-Id: I0aba2344afde94226cfbac5b3221e827e6774b3a
diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx
index c90c0e7..92feaca 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -354,7 +354,7 @@ namespace dbtools
Time DBTypeConversion::toTime(double dVal)
{
sal_Int32 nDays = (sal_Int32)dVal;
- sal_Int32 nNS = sal_Int32((dVal - (double)nDays) * fNanoSecondsPerDay + 0.5);
+ sal_Int64 nNS = static_cast<sal_Int64>((dVal - (double)nDays) * fNanoSecondsPerDay + 0.5);
sal_Int16 nSign;
if ( nNS < 0 )
@@ -368,7 +368,7 @@ namespace dbtools
Time xRet;
// normalize time
// we have to sal_Int32 here because otherwise we get an overflow
- sal_Int32 nNanoSeconds = nNS;
+ sal_Int64 nNanoSeconds = nNS;
sal_Int32 nSeconds = nNanoSeconds / nanoSecInSec;
sal_Int32 nMinutes = nSeconds / secInMin;
commit b45b566e172938fd82f2be610c6c9dace87d4248
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Thu Jun 27 08:50:37 2013 +0200
fdo#66216 fix DBTypeConversion::toTimeString format
std::ostringstream::width is not sticky
Change-Id: I32d77bec68506b7691a4f86dadb24e62fdc13d42
diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx
index cf45545..c90c0e7 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -28,6 +28,8 @@
#include <com/sun/star/util/Time.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <rtl/ustrbuf.hxx>
+#include <sstream>
+#include <iomanip>
#define MAX_DAYS 3636532
@@ -82,11 +84,12 @@ namespace dbtools
OUString DBTypeConversion::toTimeString(const Time& rTime)
{
std::ostringstream ostr;
+ using std::setw;
ostr.fill('0');
- ostr.width(2);
- ostr << rTime.Hours << ":" << rTime.Minutes << ":" << rTime.Seconds;
- ostr.width(9);
- ostr << "." << rTime.NanoSeconds;
+ ostr << setw(2) << rTime.Hours << ":"
+ << setw(2) << rTime.Minutes << ":"
+ << setw(2) << rTime.Seconds << "."
+ << setw(9) << rTime.NanoSeconds;
return OUString::createFromAscii(ostr.str().c_str());
}
commit 5a2c23ca59ba8e8b11e8397f80c5c6ff855c40b2
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Wed Jun 26 23:17:52 2013 +0200
unused constant
Change-Id: I72a27a05c9e3e49b17817c2566fbd7f02b7835c5
diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx
index 0150cdd..cf45545 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -33,7 +33,6 @@
namespace
{
- const double fMilliSecondsPerDay = 86400000.0;
const sal_Int64 nanoSecInSec = 1000000000;
const sal_Int16 secInMin = 60;
const sal_Int16 minInHour = 60;
More information about the Libreoffice-commits
mailing list