[Libreoffice-commits] core.git: basic/source connectivity/source editeng/source extensions/source forms/source include/tools sc/source sd/source sfx2/source svl/source svtools/source svx/source sw/source tools/source unotools/source xmlsecurity/source

Noel Grandin noel at peralex.com
Tue Jan 13 07:24:34 PST 2015


 basic/source/runtime/methods.cxx                       |    4 -
 connectivity/source/drivers/calc/CTable.cxx            |    3 -
 connectivity/source/drivers/file/FDateFunctions.cxx    |   11 +----
 editeng/source/items/flditem.cxx                       |    2 
 editeng/source/uno/unofield.cxx                        |    2 
 extensions/source/propctrlr/standardcontrol.cxx        |    6 --
 forms/source/xforms/datatypes.cxx                      |    9 +---
 include/tools/date.hxx                                 |    2 
 include/tools/datetime.hxx                             |    7 +++
 include/tools/time.hxx                                 |    2 
 sc/source/filter/oox/revisionfragment.cxx              |    4 -
 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx |    4 -
 sc/source/filter/xml/XMLConverter.cxx                  |   22 ----------
 sc/source/filter/xml/XMLConverter.hxx                  |    2 
 sc/source/filter/xml/xmlexprt.cxx                      |    7 ---
 sc/source/filter/xml/xmlimprt.cxx                      |    8 ---
 sc/source/ui/docshell/docsh8.cxx                       |    3 -
 sc/source/ui/miscdlgs/sharedocdlg.cxx                  |    4 -
 sc/source/ui/unoobj/fielduno.cxx                       |    2 
 sd/source/ui/annotations/annotationmanager.cxx         |    2 
 sfx2/source/appl/sfxpicklist.cxx                       |    5 --
 sfx2/source/dialog/dinfdlg.cxx                         |   28 +++++-------
 sfx2/source/dialog/versdlg.cxx                         |   10 ----
 sfx2/source/doc/SfxDocumentMetaData.cxx                |    3 -
 sfx2/source/doc/objcont.cxx                            |   10 ----
 sfx2/source/view/viewprn.cxx                           |    4 -
 svl/source/numbers/numfmuno.cxx                        |    3 -
 svtools/source/contnr/contentenumeration.cxx           |    3 -
 svtools/source/svhtml/parhtml.cxx                      |    6 --
 svx/source/fmcomp/gridcell.cxx                         |    2 
 sw/source/core/doc/doccomp.cxx                         |    5 --
 sw/source/core/doc/docglbl.cxx                         |    6 --
 sw/source/core/fields/docufld.cxx                      |   37 +++--------------
 sw/source/core/fields/flddat.cxx                       |   11 -----
 sw/source/core/unocore/unoredline.cxx                  |   19 +-------
 sw/source/filter/ww8/wrtww8.cxx                        |   12 +----
 sw/source/filter/ww8/ww8par.cxx                        |    5 --
 tools/source/datetime/datetime.cxx                     |    6 ++
 tools/source/datetime/tdate.cxx                        |    5 ++
 tools/source/datetime/ttime.cxx                        |    5 ++
 unotools/source/ucbhelper/ucbhelper.cxx                |    4 -
 xmlsecurity/source/dialogs/resourcemanager.cxx         |    4 -
 xmlsecurity/source/helper/xmlsignaturehelper.cxx       |   12 +----
 43 files changed, 97 insertions(+), 214 deletions(-)

New commits:
commit c32a5a3b8e2e3a49ac9f1fd3f2872b00612676b7
Author: Noel Grandin <noel at peralex.com>
Date:   Sun Jan 11 13:35:38 2015 +0200

    simplify Date/Time/DateTime conversion code
    
    add constructors to Date/DateTime/Time,
    that take the css::util counterparts,
    to simplify code converting between these type
    
    Change-Id: I4b03da02c63f65b6ec18cb4d6ecc3859bdef1ff7
    Reviewed-on: https://gerrit.libreoffice.org/13855
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 113f94d..2817815 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -3224,8 +3224,8 @@ RTLFUNC(FileDateTime)
                 try
                 {
                     util::DateTime aUnoDT = xSFI->getDateTimeModified( aPath );
-                    aTime = tools::Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.NanoSeconds );
-                    aDate = Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year );
+                    aTime = tools::Time( aUnoDT );
+                    aDate = Date( aUnoDT );
                 }
                 catch(const Exception & )
                 {
diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx
index 3e51949..fbf7e94 100644
--- a/connectivity/source/drivers/calc/CTable.cxx
+++ b/connectivity/source/drivers/calc/CTable.cxx
@@ -350,8 +350,7 @@ static void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& x
                 {
                     ::Date aDate( rNullDate );
                     aDate += (long)::rtl::math::approxFloor( xCell->getValue() );
-                    ::com::sun::star::util::Date aDateStruct( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
-                    rValue = aDateStruct;
+                    rValue = aDate.GetUNODate();
                 }
                 else
                     rValue.setNull();
diff --git a/connectivity/source/drivers/file/FDateFunctions.cxx b/connectivity/source/drivers/file/FDateFunctions.cxx
index 8e7e5f2..1b475af 100644
--- a/connectivity/source/drivers/file/FDateFunctions.cxx
+++ b/connectivity/source/drivers/file/FDateFunctions.cxx
@@ -254,7 +254,7 @@ ORowSetValue OOp_CurDate::operate(const ::std::vector<ORowSetValue>& lhs) const
         return ORowSetValue();
 
     Date aCurDate( Date::SYSTEM );
-    return ::com::sun::star::util::Date(aCurDate.GetDay(),aCurDate.GetMonth(),aCurDate.GetYear());
+    return aCurDate.GetUNODate();;
 }
 
 ORowSetValue OOp_CurTime::operate(const ::std::vector<ORowSetValue>& lhs) const
@@ -263,9 +263,7 @@ ORowSetValue OOp_CurTime::operate(const ::std::vector<ORowSetValue>& lhs) const
         return ORowSetValue();
 
     tools::Time aCurTime( tools::Time::SYSTEM );
-    return ::com::sun::star::util::Time(aCurTime.GetNanoSec(),
-            aCurTime.GetSec(), aCurTime.GetMin(), aCurTime.GetHour(),
-            false);
+    return aCurTime.GetUNOTime();;
 }
 
 ORowSetValue OOp_Now::operate(const ::std::vector<ORowSetValue>& lhs) const
@@ -274,10 +272,7 @@ ORowSetValue OOp_Now::operate(const ::std::vector<ORowSetValue>& lhs) const
         return ORowSetValue();
 
     DateTime aCurTime( DateTime::SYSTEM );
-    return ::com::sun::star::util::DateTime(aCurTime.GetNanoSec(),
-            aCurTime.GetSec(), aCurTime.GetMin(), aCurTime.GetHour(),
-            aCurTime.GetDay(), aCurTime.GetMonth(), aCurTime.GetYear(),
-            false);
+    return aCurTime.GetUNODateTime();
 }
 
 
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index 57f1e2a..57de987 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -81,7 +81,7 @@ SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTe
                     if (nFieldType != text::textfield::Type::TIME)
                     {
                         util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
-                        tools::Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
+                        tools::Time aTime(aDateTime);
 
                         bool bIsFixed = false;
                         xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx
index 7c7cae9..48042ebf 100644
--- a/editeng/source/uno/unofield.cxx
+++ b/editeng/source/uno/unofield.cxx
@@ -212,7 +212,7 @@ static util::DateTime getTime(sal_Int64 const nTime)
 
 inline tools::Time setTime( util::DateTime& rDate )
 {
-    return tools::Time( rDate.Hours, rDate.Minutes, rDate.Seconds, rDate.NanoSeconds  );
+    return tools::Time( rDate  );
 }
 
 
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
index 4e1c600..cb54296 100644
--- a/extensions/source/propctrlr/standardcontrol.cxx
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -87,8 +87,7 @@ namespace pcr
         }
         else
         {
-            ::tools::Time aTime( aUNOTime.Hours, aUNOTime.Minutes, aUNOTime.Seconds, aUNOTime.NanoSeconds );
-            getTypedControlWindow()->SetTime( aTime );
+            getTypedControlWindow()->SetTime( ::tools::Time(aUNOTime) );
         }
     }
 
@@ -151,8 +150,7 @@ namespace pcr
         if ( !getTypedControlWindow()->GetText().isEmpty() )
         {
             ::Date aDate( getTypedControlWindow()->GetDate() );
-            util::Date aUNODate( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
-            aPropValue <<= aUNODate;
+            aPropValue <<= aDate.GetUNODate();
         }
         return aPropValue;
     }
diff --git a/forms/source/xforms/datatypes.cxx b/forms/source/xforms/datatypes.cxx
index 69d58fa..2bc4510 100644
--- a/forms/source/xforms/datatypes.cxx
+++ b/forms/source/xforms/datatypes.cxx
@@ -808,7 +808,7 @@ namespace xforms
         if ( !( aTypedValue >>= aValue ) )
             return false;
 
-        ::tools::Time aToolsTime( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.NanoSeconds );
+        ::tools::Time aToolsTime( aValue );
         // no loss/rounding; IEEE 754 double-precision floating-point
         // has a mantissa of 53 bits; we need at the very most 50 bits:
         // format of aToolsTime.GetTime() is (in decimal) hhmmssnnnnnnnnn
@@ -832,7 +832,7 @@ namespace xforms
     {
         css::util::Time aValue;
         OSL_VERIFY( _rValue >>= aValue );
-        ::tools::Time aToolsTime( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.NanoSeconds );
+        ::tools::Time aToolsTime( aValue );
         _rDoubleValue = aToolsTime.GetTime();
     }
 
@@ -853,10 +853,7 @@ namespace xforms
     {
         double lcl_normalizeDateTime( const DateTime& _rValue )
         {
-            ::DateTime aToolsValue(
-                ::Date( _rValue.Day, _rValue.Month, _rValue.Year ),
-                ::tools::Time( _rValue.Hours, _rValue.Minutes, _rValue.Seconds, _rValue.NanoSeconds )
-            );
+            ::DateTime aToolsValue(_rValue);
 
             double fValue = 0;
             // days since 1.1.1900 (which is relatively arbitrary but fixed date)
diff --git a/include/tools/date.hxx b/include/tools/date.hxx
index b0f1612..0fc4109 100644
--- a/include/tools/date.hxx
+++ b/include/tools/date.hxx
@@ -21,6 +21,7 @@
 
 #include <tools/toolsdllapi.h>
 #include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
 #include <sal/log.hxx>
 
 enum DayOfWeek { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,
@@ -61,6 +62,7 @@ public:
                         SAL_WARN_IF(_rDate.Year < 0, "tools.datetime", "Negative year in css::util::Date to ::Date conversion");
                         init(_rDate.Day, _rDate.Month, _rDate.Year);
                     }
+                    Date( const ::com::sun::star::util::DateTime& _rDateTime );
 
     void            SetDate( sal_uInt32 nNewDate ) { nDate = nNewDate; }
     sal_uInt32      GetDate() const { return nDate; }
diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx
index 256bb72..295c587 100644
--- a/include/tools/datetime.hxx
+++ b/include/tools/datetime.hxx
@@ -22,6 +22,7 @@
 #include <tools/toolsdllapi.h>
 #include <tools/date.hxx>
 #include <tools/time.hxx>
+#include <com/sun/star/util/DateTime.hpp>
 
 class TOOLS_DLLPUBLIC SAL_WARN_UNUSED DateTime : public Date, public tools::Time
 {
@@ -45,6 +46,12 @@ public:
                     DateTime( const tools::Time& rTime ) : Date(0), Time( rTime ) {}
                     DateTime( const Date& rDate, const tools::Time& rTime ) :
                         Date( rDate ), Time( rTime ) {}
+                    DateTime( const css::util::DateTime& rDateTime );
+
+    css::util::DateTime
+                    GetUNODateTime() const
+                        { return css::util::DateTime(GetNanoSec(), GetSec(), GetMin(), GetHour(),
+                              GetDay(), GetMonth(), GetYear(), false); }
 
     bool            IsBetween( const DateTime& rFrom,
                                const DateTime& rTo ) const;
diff --git a/include/tools/time.hxx b/include/tools/time.hxx
index 140b69f..1ece6c4 100644
--- a/include/tools/time.hxx
+++ b/include/tools/time.hxx
@@ -22,6 +22,7 @@
 #include <tools/toolsdllapi.h>
 #include <tools/solar.h>
 #include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
 
 /**
  @WARNING: This class can serve both as wall clock time and time duration, and
@@ -69,6 +70,7 @@ public:
                     Time( sal_Int64 _nTime ) { Time::nTime = _nTime; }
                     Time( const tools::Time& rTime );
                     Time( const ::com::sun::star::util::Time& rTime );
+                    Time( const ::com::sun::star::util::DateTime& rDateTime );
                     Time( sal_uInt32 nHour, sal_uInt32 nMin,
                           sal_uInt32 nSec = 0, sal_uInt64 nNanoSec = 0 );
 
diff --git a/sc/source/filter/oox/revisionfragment.cxx b/sc/source/filter/oox/revisionfragment.cxx
index 45ad6de..fd9195f 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -300,8 +300,8 @@ void RevisionHeadersFragment::importHeader( const AttributeList& rAttribs )
     {
         util::DateTime aDateTime;
         sax::Converter::parseDateTime(aDateTime, 0, aDateTimeStr);
-        Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
-        tools::Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
+        Date aDate(aDateTime);
+        tools::Time aTime(aDateTime);
         aMetadata.maDateTime.SetDate(aDate.GetDate());
         aMetadata.maDateTime.SetTime(aTime.GetTime());
     }
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index c697419..a85ec22 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -433,8 +433,8 @@ void ScXMLChangeTrackingImportHelper::EndChangeAction()
 
 void ScXMLChangeTrackingImportHelper::ConvertInfo(const ScMyActionInfo& aInfo, OUString& rUser, DateTime& aDateTime)
 {
-    Date aDate(aInfo.aDateTime.Day, aInfo.aDateTime.Month, aInfo.aDateTime.Year);
-    tools::Time aTime(aInfo.aDateTime.Hours, aInfo.aDateTime.Minutes, aInfo.aDateTime.Seconds, aInfo.aDateTime.NanoSeconds);
+    Date aDate(aInfo.aDateTime);
+    tools::Time aTime(aInfo.aDateTime);
     aDateTime.SetDate( aDate.GetDate() );
     aDateTime.SetTime( aTime.GetTime() );
 
diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index 4e4fb31..a3a9986 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -312,30 +312,10 @@ void ScXMLConverter::ParseFormula(OUString& sFormula, const bool bIsFormula)
 
 void ScXMLConverter::ConvertDateTimeToString(const DateTime& aDateTime, OUStringBuffer& sDate)
 {
-    util::DateTime aAPIDateTime;
-    ConvertCoreToAPIDateTime(aDateTime, aAPIDateTime);
+    css::util::DateTime aAPIDateTime = aDateTime.GetUNODateTime();
     ::sax::Converter::convertDateTime(sDate, aAPIDateTime, 0);
 }
 
-void ScXMLConverter::ConvertCoreToAPIDateTime(const DateTime& aDateTime, util::DateTime& rDateTime)
-{
-    rDateTime.Year = aDateTime.GetYear();
-    rDateTime.Month = aDateTime.GetMonth();
-    rDateTime.Day = aDateTime.GetDay();
-    rDateTime.Hours = aDateTime.GetHour();
-    rDateTime.Minutes = aDateTime.GetMin();
-    rDateTime.Seconds = aDateTime.GetSec();
-    rDateTime.NanoSeconds = aDateTime.GetNanoSec();
-}
-
-void ScXMLConverter::ConvertAPIToCoreDateTime(const util::DateTime& aDateTime, DateTime& rDateTime)
-{
-    Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
-    tools::Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
-    DateTime aTempDateTime (aDate, aTime);
-    rDateTime = aTempDateTime;
-}
-
 namespace {
 
 /** Enumerates different types of condition tokens. */
diff --git a/sc/source/filter/xml/XMLConverter.hxx b/sc/source/filter/xml/XMLConverter.hxx
index f9891cd..7baa9ef 100644
--- a/sc/source/filter/xml/XMLConverter.hxx
+++ b/sc/source/filter/xml/XMLConverter.hxx
@@ -96,9 +96,7 @@ public:
                             const bool bIsFormula = true);
 // EXPORT: Core Date Time
     static void         ConvertDateTimeToString(const DateTime& aDateTime, OUStringBuffer& sDate);
-    static void         ConvertCoreToAPIDateTime(const DateTime& aDateTime, com::sun::star::util::DateTime& rDateTime);
 
-    static void         ConvertAPIToCoreDateTime(const com::sun::star::util::DateTime& aDateTime, DateTime& rDateTime);
 };
 
 enum ScXMLConditionToken
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index fa6c944..5f1f4d5 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -4831,13 +4831,10 @@ void ScXMLExport::GetChangeTrackViewSettings(uno::Sequence<beans::PropertyValue>
                 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME].Value <<= pViewSettings->HasDate();
                 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Name = "ShowChangesByDatetimeMode";
                 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_MODE].Value <<= static_cast<sal_Int16>(pViewSettings->GetTheDateMode());
-                util::DateTime aDateTime;
-                ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings->GetTheFirstDateTime(), aDateTime);
                 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Name = "ShowChangesByDatetimeFirstDatetime";
-                pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Value <<= aDateTime;
-                ScXMLConverter::ConvertCoreToAPIDateTime(pViewSettings->GetTheLastDateTime(), aDateTime);
+                pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_FIRST_DATETIME].Value <<= pViewSettings->GetTheFirstDateTime().GetUNODateTime();
                 pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Name = "ShowChangesByDatetimeSecondDatetime";
-                pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Value <<= aDateTime;
+                pChangeProps[SC_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME].Value <<= pViewSettings->GetTheLastDateTime().GetUNODateTime();
                 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Name = "ShowChangesByAuthor";
                 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR].Value <<= pViewSettings->HasAuthor();
                 pChangeProps[SC_SHOW_CHANGES_BY_AUTHOR_NAME].Name = "ShowChangesByAuthorName";
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 4b6f92b..6648144 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2478,9 +2478,7 @@ void ScXMLImport::SetChangeTrackingViewSettings(const com::sun::star::uno::Seque
                     util::DateTime aDateTime;
                     if (rChangeProps[i].Value >>= aDateTime)
                     {
-                        DateTime aCoreDateTime( DateTime::EMPTY );
-                        ScXMLConverter::ConvertAPIToCoreDateTime(aDateTime, aCoreDateTime);
-                        pViewSettings->SetTheFirstDateTime(aCoreDateTime);
+                        pViewSettings->SetTheFirstDateTime(::DateTime(aDateTime));
                     }
                 }
                 else if (sName == "ShowChangesByDatetimeSecondDatetime")
@@ -2488,9 +2486,7 @@ void ScXMLImport::SetChangeTrackingViewSettings(const com::sun::star::uno::Seque
                     util::DateTime aDateTime;
                     if (rChangeProps[i].Value >>= aDateTime)
                     {
-                        DateTime aCoreDateTime( DateTime::EMPTY );
-                        ScXMLConverter::ConvertAPIToCoreDateTime(aDateTime, aCoreDateTime);
-                        pViewSettings->SetTheLastDateTime(aCoreDateTime);
+                        pViewSettings->SetTheLastDateTime(::DateTime(aDateTime));
                     }
                 }
                 else if (sName == "ShowChangesByAuthor")
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index f7f7f0f..d89701b 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -1014,8 +1014,7 @@ sal_uLong ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncodi
                             {
                                 Date aDate = *(pNumFmt->GetNullDate());     // tools date
                                 aDate += (long)fVal;                        //! approxfloor?
-                                util::Date aUnoDate( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
-                                xRowUpdate->updateDate( nCol+1, aUnoDate );
+                                xRowUpdate->updateDate( nCol+1, aDate.GetUNODate() );
                             }
                         }
                         break;
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.cxx b/sc/source/ui/miscdlgs/sharedocdlg.cxx
index 87b9bbe..d934ff7 100644
--- a/sc/source/ui/miscdlgs/sharedocdlg.cxx
+++ b/sc/source/ui/miscdlgs/sharedocdlg.cxx
@@ -228,9 +228,7 @@ void ScShareDocumentDlg::UpdateView()
         uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
 
         util::DateTime uDT(xDocProps->getModificationDate());
-        Date d(uDT.Day, uDT.Month, uDT.Year);
-        tools::Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-        DateTime aDateTime(d,t);
+        DateTime aDateTime(uDT);
 
         aString += formatTime(aDateTime, *ScGlobal::pLocaleData);
         aString += " ";
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 73e21d6..c5c0f7e 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -944,7 +944,7 @@ void ScEditFieldObj::setPropertyValueDateTime(const OUString& rName, const uno::
                 else if (rName == SC_UNONAME_DATETIME)
                 {
                     maDateTime = rVal.get<util::DateTime>();
-                    tools::Time aTime(maDateTime.Hours, maDateTime.Minutes, maDateTime.Seconds, maDateTime.NanoSeconds);
+                    tools::Time aTime(maDateTime);
                     p->SetFixTime(aTime);
                 }
                 else if (rName == SC_UNONAME_NUMFMT)
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 6a43cb0..cbbbc34 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -160,7 +160,7 @@ OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotatio
         else if (aDate.IsValidAndGregorian() )
             sRet = rLocalData.getDate(aDate);
 
-        ::tools::Time aTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds );
+        ::tools::Time aTime( aDateTime );
         if(aTime.GetTime() != 0)
             sRet = sRet + " "  + rLocalData.getTime( aTime,false );
     }
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 1c2cf0a..8e8452e 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -395,10 +395,7 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint )
                 if (xDocProps.is()) {
                     xDocProps->setAuthor( SvtUserOptions().GetFullName() );
                     ::DateTime now( ::DateTime::SYSTEM );
-                    xDocProps->setCreationDate( util::DateTime(
-                        now.GetNanoSec(), now.GetSec(), now.GetMin(),
-                        now.GetHour(), now.GetDay(), now.GetMonth(),
-                        now.GetYear(), false) );
+                    xDocProps->setCreationDate( now.GetUNODateTime() );
                 }
 
                 if ( bAllowModif )
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 2ebf8a8..a64c637 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -175,8 +175,8 @@ OUString CreateSizeText( sal_Int64 nSize )
 OUString ConvertDateTime_Impl( const OUString& rName,
     const util::DateTime& uDT, const LocaleDataWrapper& rWrapper )
 {
-    Date aD(uDT.Day, uDT.Month, uDT.Year);
-    tools::Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
+     Date aD(uDT);
+     tools::Time aT(uDT);
      const OUString pDelim ( ", " );
      OUString aStr( rWrapper.getDate( aD ) );
      aStr += pDelim;
@@ -358,9 +358,7 @@ void SfxDocumentInfoItem::resetUserData(const OUString & i_rAuthor)
 {
     setAuthor(i_rAuthor);
     DateTime now( DateTime::SYSTEM );
-    setCreationDate( util::DateTime(
-        now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(),
-        now.GetDay(), now.GetMonth(), now.GetYear(), false) );
+    setCreationDate( now.GetUNODateTime() );
     setModifiedBy(OUString());
     setPrintedBy(OUString());
     setModificationDate(util::DateTime());
@@ -802,9 +800,7 @@ IMPL_LINK_NOARG(SfxDocumentPage, DeleteHdl)
         aName = SvtUserOptions().GetFullName();
     const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
     DateTime now( DateTime::SYSTEM );
-    util::DateTime uDT(
-        now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(),
-        now.GetDay(), now.GetMonth(), now.GetYear(), false);
+    util::DateTime uDT( now.GetUNODateTime() );
     m_pCreateValFt->SetText( ConvertDateTime_Impl( aName, uDT, rLocaleWrapper ) );
     OUString aEmpty;
     m_pChangeValFt->SetText( aEmpty );
@@ -1814,13 +1810,13 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
     }
     else if ( rAny >>= aTmpDate )
     {
-        pNewLine->m_aDateField.SetDate( Date( aTmpDate.Day, aTmpDate.Month, aTmpDate.Year ) );
+        pNewLine->m_aDateField.SetDate( Date( aTmpDate ) );
         nType = CUSTOM_TYPE_DATE;
     }
     else if ( rAny >>= aTmpDateTime )
     {
-        pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) );
-        pNewLine->m_aTimeField.SetTime( tools::Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.NanoSeconds ) );
+        pNewLine->m_aDateField.SetDate( Date( aTmpDateTime ) );
+        pNewLine->m_aTimeField.SetTime( tools::Time( aTmpDateTime ) );
         pNewLine->m_aTimeField.m_isUTC = aTmpDateTime.IsUTC;
         nType = CUSTOM_TYPE_DATETIME;
     }
@@ -1834,9 +1830,8 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
     else if ( rAny >>= aTmpDateTimeTZ )
     {
         util::DateTime const& rDT(aTmpDateTimeTZ.DateTimeInTZ);
-        pNewLine->m_aDateField.SetDate( Date( rDT.Day, rDT.Month, rDT.Year ) );
-        pNewLine->m_aTimeField.SetTime( tools::Time( rDT.Hours, rDT.Minutes,
-                    rDT.Seconds, rDT.NanoSeconds ) );
+        pNewLine->m_aDateField.SetDate( Date( rDT ) );
+        pNewLine->m_aTimeField.SetTime( tools::Time( rDT ) );
         pNewLine->m_aTimeField.m_isUTC = rDT.IsUTC;
         pNewLine->m_aDateField.m_TZ = aTmpDateTimeTZ.Timezone;
         nType = CUSTOM_TYPE_DATETIME;
@@ -2240,9 +2235,8 @@ CmisDateTime::CmisDateTime( vcl::Window* pParent, const util::DateTime& aDateTim
     get( m_aTimeField, "time");
     m_aDateField->Show( true );
     m_aTimeField->Show( true );
-    m_aDateField->SetDate( Date( aDateTime.Day, aDateTime.Month, aDateTime.Year ) );
-    m_aTimeField->SetTime( tools::Time( aDateTime.Hours, aDateTime.Minutes,
-                           aDateTime.Seconds, aDateTime.NanoSeconds ) );
+    m_aDateField->SetDate( Date( aDateTime ) );
+    m_aTimeField->SetTime( tools::Time( aDateTime ) );
 }
 
 CmisYesNo::CmisYesNo( vcl::Window* pParent, bool bValue )
diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx
index 35c5d73..36cdebf 100644
--- a/sfx2/source/dialog/versdlg.cxx
+++ b/sfx2/source/dialog/versdlg.cxx
@@ -94,10 +94,7 @@ SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < util::RevisionTa
         pInfo->aComment = rInfo[n].Comment;
         pInfo->aAuthor = rInfo[n].Author;
 
-        Date aDate ( rInfo[n].TimeStamp.Day,   rInfo[n].TimeStamp.Month,   rInfo[n].TimeStamp.Year );
-        tools::Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.NanoSeconds );
-
-        pInfo->aCreationDate = DateTime( aDate, aTime );
+        pInfo->aCreationDate = DateTime( rInfo[n].TimeStamp );
         aTableList.push_back( pInfo );
     }
 }
@@ -111,10 +108,7 @@ SfxVersionTableDtor::SfxVersionTableDtor( const uno::Sequence < document::CmisVe
         pInfo->aComment = rInfo[n].Comment;
         pInfo->aAuthor = rInfo[n].Author;
 
-        Date aDate ( rInfo[n].TimeStamp.Day,   rInfo[n].TimeStamp.Month,   rInfo[n].TimeStamp.Year );
-        tools::Time aTime ( rInfo[n].TimeStamp.Hours, rInfo[n].TimeStamp.Minutes, rInfo[n].TimeStamp.Seconds, rInfo[n].TimeStamp.NanoSeconds );
-
-        pInfo->aCreationDate = DateTime( aDate, aTime );
+        pInfo->aCreationDate = DateTime( rInfo[n].TimeStamp );
         aTableList.push_back( pInfo );
     }
 }
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 2310e6b..022d96f 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -1827,8 +1827,7 @@ SfxDocumentMetaData::resetUserData(const OUString & the_value)
     bool bModified( false );
     bModified |= setMetaText("meta:initial-creator", the_value);
     ::DateTime now( ::DateTime::SYSTEM );
-    css::util::DateTime uDT(now.GetNanoSec(), now.GetSec(), now.GetMin(),
-        now.GetHour(), now.GetDay(), now.GetMonth(), now.GetYear(), false);
+    css::util::DateTime uDT(now.GetUNODateTime());
     bModified |= setMetaText("meta:creation-date", dateTimeToText(uDT));
     bModified |= setMetaText("dc:creator", OUString());
     bModified |= setMetaText("meta:printed-by", OUString());
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 00e0333..cd5c294 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -203,10 +203,7 @@ void SfxObjectShell::UpdateDocInfoForSave()
         {
             // update ModificationAuthor, revision and editing time
             ::DateTime now( ::DateTime::SYSTEM );
-            xDocProps->setModificationDate( util::DateTime(
-                now.GetNanoSec(), now.GetSec(), now.GetMin(),
-                now.GetHour(), now.GetDay(), now.GetMonth(),
-                now.GetYear(), false) );
+            xDocProps->setModificationDate( now.GetUNODateTime() );
             xDocProps->setModifiedBy( aUserName );
             UpdateTime_Impl( xDocProps );
         }
@@ -541,10 +538,7 @@ void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, const OUS
                 xDocProps->setTemplateName( rTemplateName );
 
                 ::DateTime now( ::DateTime::SYSTEM );
-                xDocProps->setTemplateDate( util::DateTime(
-                    now.GetNanoSec(), now.GetSec(), now.GetMin(),
-                    now.GetHour(), now.GetDay(), now.GetMonth(),
-                    now.GetYear(), false) );
+                xDocProps->setTemplateDate( now.GetUNODateTime() );
 
                 SetQueryLoadTemplate( true );
             }
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index bef2e88..0edd504 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -314,9 +314,7 @@ void SfxPrinterController::jobStarted()
             : OUString() );
         ::DateTime now( ::DateTime::SYSTEM );
 
-        xDocProps->setPrintDate( util::DateTime(
-            now.GetNanoSec(), now.GetSec(), now.GetMin(), now.GetHour(),
-            now.GetDay(), now.GetMonth(), now.GetYear(), false) );
+        xDocProps->setPrintDate( now.GetUNODateTime() );
 
         SfxGetpApp()->NotifyEvent( SfxEventHint(SFX_EVENT_PRINTDOC, GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ), mpObjectShell ) );
         uno::Sequence < beans::PropertyValue > aOpts;
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx
index ea1d0fa..d53d8a2 100644
--- a/svl/source/numbers/numfmuno.cxx
+++ b/svl/source/numbers/numfmuno.cxx
@@ -1028,8 +1028,7 @@ uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const OUString& a
             Date* pDate = pFormatter->GetNullDate();
             if (pDate)
             {
-                util::Date aUnoDate( pDate->GetDay(), pDate->GetMonth(), pDate->GetYear() );
-                aRet <<= aUnoDate;
+                aRet <<= pDate->GetUNODate();
             }
         }
         else if (aPropertyName == PROPERTYNAME_STDDEC)
diff --git a/svtools/source/contnr/contentenumeration.cxx b/svtools/source/contnr/contentenumeration.cxx
index c47d8bc..b601bf5 100644
--- a/svtools/source/contnr/contentenumeration.cxx
+++ b/svtools/source/contnr/contentenumeration.cxx
@@ -51,8 +51,7 @@ namespace svt
 #define ROW_IS_COMPACTDISC  12
 
 #define CONVERT_DATETIME( aUnoDT, aToolsDT ) \
-    aToolsDT = ::DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \
-                           tools::Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.NanoSeconds ) );
+    aToolsDT = ::DateTime( aUnoDT );
 
     using ::com::sun::star::uno::Reference;
     using ::com::sun::star::uno::Sequence;
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index ce9ba50..cfbb59b 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -2046,11 +2046,7 @@ bool HTMLParser::ParseMetaOptionsImpl(
                 Date aDate( (sal_uLong)aContent.getToken(0, ';').toInt32() );
                 tools::Time aTime( (sal_uLong)aContent.getToken(1, ';').toInt32() );
                 DateTime aDateTime( aDate, aTime );
-                ::util::DateTime uDT(aDateTime.GetNanoSec(),
-                    aDateTime.GetSec(), aDateTime.GetMin(),
-                    aDateTime.GetHour(), aDateTime.GetDay(),
-                    aDateTime.GetMonth(), aDateTime.GetYear(),
-                    false);
+                ::util::DateTime uDT = aDateTime.GetUNODateTime();
                 if ( HTML_META_CREATED==nAction )
                     i_xDocProps->setCreationDate( uDT );
                 else
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 4ed0c87..739e649 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -2355,7 +2355,7 @@ namespace
                     _rField.SetText( sTime );
                 else
                 {
-                    _rField.SetTime( ::tools::Time( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.NanoSeconds ) );
+                    _rField.SetTime( ::tools::Time( aValue ) );
                     sTime = _rField.GetText();
                 }
             }
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 5e05f7b..93282c7 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1616,14 +1616,11 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo )
             util::DateTime uDT( 1 == xDocProps->getEditingCycles()
                                 ? xDocProps->getCreationDate()
                                 : xDocProps->getModificationDate() );
-            Date d(uDT.Day, uDT.Month, uDT.Year);
-            tools::Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-            DateTime aDT(d,t);
 
             if( !aTmp.isEmpty() )
             {
                 nAuthor = rDoc.getIDocumentRedlineAccess().InsertRedlineAuthor( aTmp );
-                aTimeStamp = aDT;
+                aTimeStamp = DateTime(uDT);
             }
         }
     }
diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx
index aa81d02..017a4f5 100644
--- a/sw/source/core/doc/docglbl.cxx
+++ b/sw/source/core/doc/docglbl.cxx
@@ -282,11 +282,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
                     OSL_ENSURE(xDocProps.is(), "Doc has no DocumentProperties");
                     // the GlobalDoc is the template
                     xDocProps->setTemplateName(OUString());
-                    ::util::DateTime uDT(aTmplDate.GetNanoSec(),
-                        aTmplDate.GetSec(), aTmplDate.GetMin(),
-                        aTmplDate.GetHour(), aTmplDate.GetDay(),
-                        aTmplDate.GetMonth(), aTmplDate.GetYear(),
-                        false );
+                    ::util::DateTime uDT = aTmplDate.GetUNODateTime();
                     xDocProps->setTemplateDate(uDT);
                     xDocProps->setTemplateURL(rPath);
                     // Set the new doc's title to the text of the "split para".
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index fecc1b8..4e0355f 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -931,8 +931,8 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
         {
             OUString aName( xDocProps->getAuthor() );
             util::DateTime uDT( xDocProps->getCreationDate() );
-            Date aD(uDT.Day, uDT.Month, uDT.Year);
-            tools::Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
+            Date aD(uDT);
+            tools::Time aT(uDT);
             DateTime aDate(aD,aT);
             if( nSub == DI_CREATE )
                 ;       // das wars schon!!
@@ -940,19 +940,13 @@ OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat,
             {
                 aName = xDocProps->getModifiedBy();
                 uDT = xDocProps->getModificationDate();
-                Date bD(uDT.Day, uDT.Month, uDT.Year);
-                tools::Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-                DateTime bDate(bD,bT);
-                aDate = bDate;
+                aDate = DateTime(uDT);
             }
             else if( nSub == DI_PRINT )
             {
                 aName = xDocProps->getPrintedBy();
                 uDT = xDocProps->getPrintDate();
-                Date bD(uDT.Day, uDT.Month, uDT.Year);
-                tools::Time bT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-                DateTime bDate(bD,bT);
-                aDate = bDate;
+                aDate = DateTime(uDT);
             }
             else
                 break;
@@ -1776,24 +1770,13 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
         }
     case FIELD_PROP_DATE:
         {
-            util::Date aSetDate;
-            aSetDate.Day = aDateTime.GetDay();
-            aSetDate.Month = aDateTime.GetMonth();
-            aSetDate.Year = aDateTime.GetYear();
+            css::util::Date aSetDate = aDateTime.GetUNODate();
             rAny.setValue(&aSetDate, ::cppu::UnoType<util::Date>::get());
         }
         break;
     case FIELD_PROP_DATE_TIME:
         {
-                util::DateTime DateTimeValue;
-                DateTimeValue.NanoSeconds = aDateTime.GetNanoSec();
-                DateTimeValue.Seconds = aDateTime.GetSec();
-                DateTimeValue.Minutes = aDateTime.GetMin();
-                DateTimeValue.Hours = aDateTime.GetHour();
-                DateTimeValue.Day = aDateTime.GetDay();
-                DateTimeValue.Month = aDateTime.GetMonth();
-                DateTimeValue.Year = aDateTime.GetYear();
-                rAny <<= DateTimeValue;
+            rAny <<= aDateTime.GetUNODateTime();
         }
         break;
     default:
@@ -1839,13 +1822,7 @@ bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
         util::DateTime aDateTimeValue;
         if(!(rAny >>= aDateTimeValue))
             return false;
-        aDateTime.SetNanoSec(aDateTimeValue.NanoSeconds);
-        aDateTime.SetSec(aDateTimeValue.Seconds);
-        aDateTime.SetMin(aDateTimeValue.Minutes);
-        aDateTime.SetHour(aDateTimeValue.Hours);
-        aDateTime.SetDay(aDateTimeValue.Day);
-        aDateTime.SetMonth(aDateTimeValue.Month);
-        aDateTime.SetYear(aDateTimeValue.Year);
+        aDateTime = DateTime(aDateTimeValue);
     }
     break;
     default:
diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx
index 96c47b0..2df1dd1 100644
--- a/sw/source/core/fields/flddat.cxx
+++ b/sw/source/core/fields/flddat.cxx
@@ -178,16 +178,7 @@ bool SwDateTimeField::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const
     case FIELD_PROP_DATE_TIME:
         {
             DateTime aDateTime(GetDate(), GetTime());
-
-            util::DateTime DateTimeValue;
-            DateTimeValue.NanoSeconds = aDateTime.GetNanoSec();
-            DateTimeValue.Seconds = aDateTime.GetSec();
-            DateTimeValue.Minutes = aDateTime.GetMin();
-            DateTimeValue.Hours = aDateTime.GetHour();
-            DateTimeValue.Day = aDateTime.GetDay();
-            DateTimeValue.Month = aDateTime.GetMonth();
-            DateTimeValue.Year = aDateTime.GetYear();
-            rVal <<= DateTimeValue;
+            rVal <<= aDateTime.GetUNODateTime();
         }
         break;
     default:
diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx
index beaa60e..e97b1d9 100644
--- a/sw/source/core/unocore/unoredline.cxx
+++ b/sw/source/core/unocore/unoredline.cxx
@@ -190,19 +190,6 @@ SwXRedlinePortion::~SwXRedlinePortion()
 {
 }
 
-static util::DateTime lcl_DateTimeToUno(const DateTime& rDT)
-{
-    util::DateTime aRetDT;
-    aRetDT.Year = rDT.GetYear();
-    aRetDT.Month= rDT.GetMonth();
-    aRetDT.Day      = rDT.GetDay();
-    aRetDT.Hours    = rDT.GetHour();
-    aRetDT.Minutes = rDT.GetMin();
-    aRetDT.Seconds = rDT.GetSec();
-    aRetDT.NanoSeconds = rDT.GetNanoSec();
-    return aRetDT;
-}
-
 static OUString lcl_RedlineTypeToOUString(RedlineType_t eType)
 {
     OUString sRet;
@@ -231,7 +218,7 @@ static uno::Sequence<beans::PropertyValue> lcl_GetSuccessorProperties(const SwRa
         // here we always need element 1
         pValues[0].Value <<= rRedline.GetAuthorString(1);
         pValues[1].Name = UNO_NAME_REDLINE_DATE_TIME;
-        pValues[1].Value <<= lcl_DateTimeToUno(pNext->GetTimeStamp());
+        pValues[1].Value <<= pNext->GetTimeStamp().GetUNODateTime();
         pValues[2].Name = UNO_NAME_REDLINE_COMMENT;
         pValues[2].Value <<= pNext->GetComment();
         pValues[3].Name = UNO_NAME_REDLINE_TYPE;
@@ -299,7 +286,7 @@ uno::Any  SwXRedlinePortion::GetPropertyValue( const OUString& rPropertyName, co
         aRet <<= rRedline.GetAuthorString();
     else if(rPropertyName == UNO_NAME_REDLINE_DATE_TIME)
     {
-        aRet <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
+        aRet <<= rRedline.GetTimeStamp().GetUNODateTime();
     }
     else if(rPropertyName == UNO_NAME_REDLINE_COMMENT)
         aRet <<= rRedline.GetComment();
@@ -339,7 +326,7 @@ uno::Sequence< beans::PropertyValue > SwXRedlinePortion::CreateRedlineProperties
     pRet[nPropIdx].Name = UNO_NAME_REDLINE_AUTHOR;
     pRet[nPropIdx++].Value <<= rRedline.GetAuthorString();
     pRet[nPropIdx].Name = UNO_NAME_REDLINE_DATE_TIME;
-    pRet[nPropIdx++].Value <<= lcl_DateTimeToUno(rRedline.GetTimeStamp());
+    pRet[nPropIdx++].Value <<= rRedline.GetTimeStamp().GetUNODateTime();
     pRet[nPropIdx].Name = UNO_NAME_REDLINE_COMMENT;
     pRet[nPropIdx++].Value <<= rRedline.GetComment();
     pRet[nPropIdx].Name = UNO_NAME_REDLINE_TYPE;
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index b724c24..ba34ffe 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -394,17 +394,11 @@ static void WriteDop( WW8Export& rWrt )
     else
     {
         ::util::DateTime uDT = xDocProps->getCreationDate();
-        Date aD(uDT.Day, uDT.Month, uDT.Year);
-        tools::Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-        rDop.dttmCreated = sw::ms::DateTime2DTTM(DateTime(aD,aT));
+        rDop.dttmCreated = sw::ms::DateTime2DTTM(DateTime(uDT));
         uDT = xDocProps->getModificationDate();
-        Date aD2(uDT.Day, uDT.Month, uDT.Year);
-        tools::Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-        rDop.dttmRevised = sw::ms::DateTime2DTTM(DateTime(aD2,aT2));
+        rDop.dttmRevised = sw::ms::DateTime2DTTM(DateTime(uDT));
         uDT = xDocProps->getPrintDate();
-        Date aD3(uDT.Day, uDT.Month, uDT.Year);
-        tools::Time aT3(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds);
-        rDop.dttmLastPrint = sw::ms::DateTime2DTTM(DateTime(aD3,aT3));
+        rDop.dttmLastPrint = sw::ms::DateTime2DTTM(DateTime(uDT));
     }
 
     // Also, the DocStat fields in headers, footers are not calculated correctly.
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index d8421d2..f3c771f 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1859,10 +1859,7 @@ void SwWW8ImplReader::ImportDop()
     {
         DateTime aLastPrinted(
             msfilter::util::DTTM2DateTime(pWDop->dttmLastPrint));
-       ::util::DateTime uDT(aLastPrinted.GetNanoSec(),
-            aLastPrinted.GetSec(), aLastPrinted.GetMin(),
-            aLastPrinted.GetHour(), aLastPrinted.GetDay(),
-            aLastPrinted.GetMonth(), aLastPrinted.GetYear(), false);
+        ::util::DateTime uDT = aLastPrinted.GetUNODateTime();
         xDocuProps->setPrintDate(uDT);
     }
 
diff --git a/tools/source/datetime/datetime.cxx b/tools/source/datetime/datetime.cxx
index 667eef6..8399415 100644
--- a/tools/source/datetime/datetime.cxx
+++ b/tools/source/datetime/datetime.cxx
@@ -19,6 +19,12 @@
 #include <tools/datetime.hxx>
 #include <rtl/math.hxx>
 
+DateTime::DateTime( const css::util::DateTime& rDateTime )
+  : Date( rDateTime.Day, rDateTime.Month, rDateTime.Year ),
+    Time( rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds, rDateTime.NanoSeconds )
+{
+}
+
 bool DateTime::IsBetween( const DateTime& rFrom, const DateTime& rTo ) const
 {
     if ( (*this >= rFrom) && (*this <= rTo) )
diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index e1e640d..b970d51 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -158,6 +158,11 @@ Date::Date( DateInitSystem )
 #endif
 }
 
+Date::Date( const ::com::sun::star::util::DateTime& rDateTime )
+{
+  init( rDateTime.Day, rDateTime.Month, rDateTime.Year );
+}
+
 void Date::SetDay( sal_uInt16 nNewDay )
 {
     sal_uIntPtr  nMonth  = GetMonth();
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index d5b83a3..6f76456 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -148,6 +148,11 @@ Time::Time( const ::com::sun::star::util::Time &_rTime )
 {
     init(_rTime.Hours, _rTime.Minutes, _rTime.Seconds, _rTime.NanoSeconds);
 }
+Time::Time( const ::com::sun::star::util::DateTime &_rDateTime )
+{
+    init(_rDateTime.Hours, _rDateTime.Minutes, _rDateTime.Seconds, _rDateTime.NanoSeconds);
+}
+
 void tools::Time::init( sal_uInt32 nHour, sal_uInt32 nMin, sal_uInt32 nSec, sal_uInt64 nNanoSec )
 {
     // normalize time
diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx
index 407adad..ec00faf 100644
--- a/unotools/source/ucbhelper/ucbhelper.cxx
+++ b/unotools/source/ucbhelper/ucbhelper.cxx
@@ -120,9 +120,7 @@ OUString getCasePreservingUrl(const INetURLObject& url) {
 }
 
 DateTime convert(css::util::DateTime const & dt) {
-    return DateTime(
-        Date(dt.Day, dt.Month, dt.Year),
-        tools::Time(dt.Hours, dt.Minutes, dt.Seconds, dt.NanoSeconds));
+    return DateTime(dt);
 }
 
 }
diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx
index 5407d39..ed2c02c 100644
--- a/xmlsecurity/source/dialogs/resourcemanager.cxx
+++ b/xmlsecurity/source/dialogs/resourcemanager.cxx
@@ -52,9 +52,7 @@ namespace XmlSec
 
     DateTime GetDateTime( const ::com::sun::star::util::DateTime& _rDT )
     {
-        return DateTime(
-            Date( _rDT.Day, _rDT.Month, _rDT.Year ),
-            tools::Time( _rDT.Hours, _rDT.Minutes, _rDT.Seconds, _rDT.NanoSeconds ) );
+        return DateTime(_rDT);
     }
 
     OUString GetDateTimeString( const ::com::sun::star::util::DateTime& _rDT )
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 4ffe2c2..9f04c58 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -26,6 +26,7 @@
 
 #include <tools/stream.hxx>
 #include <tools/debug.hxx>
+#include <tools/datetime.hxx>
 
 #include <xmloff/attrlist.hxx>
 
@@ -121,16 +122,9 @@ void XMLSignatureHelper::SetX509Certificate(
         ouX509Cert);
 }
 
-void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const Date& rDate, const tools::Time& rTime )
+void XMLSignatureHelper::SetDateTime( sal_Int32 nSecurityId, const ::Date& rDate, const tools::Time& rTime )
 {
-    ::com::sun::star::util::DateTime stDateTime;
-    stDateTime.NanoSeconds = rTime.GetNanoSec();
-    stDateTime.Seconds = (::sal_uInt16)rTime.GetSec();
-    stDateTime.Minutes = (::sal_uInt16)rTime.GetMin();
-    stDateTime.Hours = (::sal_uInt16)rTime.GetHour();
-    stDateTime.Day = (::sal_uInt16)rDate.GetDay();
-    stDateTime.Month = (::sal_uInt16)rDate.GetMonth();
-    stDateTime.Year = (::sal_uInt16)rDate.GetYear();
+    css::util::DateTime stDateTime = ::DateTime(rDate, rTime).GetUNODateTime();
     mpXSecController->setDate( nSecurityId, stDateTime );
 }
 


More information about the Libreoffice-commits mailing list