summaryrefslogtreecommitdiff
path: root/connectivity/source/commontools/DateConversion.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/commontools/DateConversion.cxx')
-rw-r--r--connectivity/source/commontools/DateConversion.cxx58
1 files changed, 55 insertions, 3 deletions
diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx
index 886ba2b723..afd67bac89 100644
--- a/connectivity/source/commontools/DateConversion.cxx
+++ b/connectivity/source/commontools/DateConversion.cxx
@@ -126,9 +126,27 @@ using namespace ::com::sun::star::beans;
case DataType::TIMESTAMP:
{
DateTime aDateTime;
+ bool bOk = false;
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE)
+ {
+ double nValue = 0.0;
+ _rVal >>= nValue;
+ aDateTime = DBTypeConversion::toDateTime(nValue);
+ bOk = true;
+ }
+ else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING)
+ {
+ ::rtl::OUString sValue;
+ _rVal >>= sValue;
+ aDateTime = DBTypeConversion::toDateTime(sValue);
+ bOk = true;
+ }
+ else
+ bOk = _rVal >>= aDateTime;
+ OSL_VERIFY_RES( bOk, "DBTypeConversion::toSQLString: _rVal is not datetime!");
// check if this is really a timestamp or only a date
- if ( _rVal >>= aDateTime )
+ if ( bOk )
{
if (bQuote)
aRet.appendAscii("{TS '");
@@ -142,7 +160,24 @@ using namespace ::com::sun::star::beans;
case DataType::DATE:
{
Date aDate;
- OSL_VERIFY_RES( _rVal >>= aDate, "DBTypeConversion::toSQLString: _rVal is not date!");
+ bool bOk = false;
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE)
+ {
+ double nValue = 0.0;
+ _rVal >>= nValue;
+ aDate = DBTypeConversion::toDate(nValue);
+ bOk = true;
+ }
+ else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING)
+ {
+ ::rtl::OUString sValue;
+ _rVal >>= sValue;
+ aDate = DBTypeConversion::toDate(sValue);
+ bOk = true;
+ }
+ else
+ bOk = _rVal >>= aDate;
+ OSL_VERIFY_RES( bOk, "DBTypeConversion::toSQLString: _rVal is not date!");
if (bQuote)
aRet.appendAscii("{D '");
aRet.append(DBTypeConversion::toDateString(aDate));
@@ -152,7 +187,24 @@ using namespace ::com::sun::star::beans;
case DataType::TIME:
{
Time aTime;
- OSL_VERIFY_RES( _rVal >>= aTime,"DBTypeConversion::toSQLString: _rVal is not time!");
+ bool bOk = false;
+ if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_DOUBLE)
+ {
+ double nValue = 0.0;
+ _rVal >>= nValue;
+ aTime = DBTypeConversion::toTime(nValue);
+ bOk = true;
+ }
+ else if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_STRING)
+ {
+ ::rtl::OUString sValue;
+ _rVal >>= sValue;
+ aTime = DBTypeConversion::toTime(sValue);
+ bOk = true;
+ }
+ else
+ bOk = _rVal >>= aTime;
+ OSL_VERIFY_RES( bOk,"DBTypeConversion::toSQLString: _rVal is not time!");
if (bQuote)
aRet.appendAscii("{T '");
aRet.append(DBTypeConversion::toTimeString(aTime));