diff options
43 files changed, 97 insertions, 214 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 113f94d27de3..281781550d32 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 3e519493abc0..fbf7e9400653 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 8e7e5f21ddfc..1b475af6e06d 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 57f1e2af0427..57de9870c461 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 7c7cae965430..48042ebf8f54 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 4e1c60037db1..cb542967eef0 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 69d58fad40b7..2bc451044768 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 b0f1612f5bed..0fc4109c42f7 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 256bb7258622..295c587d3b91 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 140b69ffb4db..1ece6c4c209a 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 45ad6de90335..fd9195f910d9 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 c6974192467d..a85ec222b7bb 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 4e4fb3143aa3..a3a9986a0563 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 f9891cd4ff43..7baa9ef8521e 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 fa6c9443ac83..5f1f4d585a71 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 4b6f92b86633..6648144ad157 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 f7f7f0f09997..d89701b1f40d 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 87b9bbe89f1c..d934ff77ea27 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 73e21d6f15ad..c5c0f7eee266 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 6a43cb093ede..cbbbc345c59b 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 1c2cf0aac38e..8e8452ea3b49 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 2ebf8a880788..a64c637db3c4 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 35c5d73959d2..36cdebf9ec8b 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 2310e6b78e47..022d96fb04cd 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 00e03330fb44..cd5c294546ea 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 bef2e880a286..0edd5046c15c 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 ea1d0fa92c3d..d53d8a2ec130 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 c47d8bcddf49..b601bf5eb23b 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 ce9ba50e44f1..cfbb59b77232 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 4ed0c8734714..739e6497bdbc 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 5e05f7bccd23..93282c70c3d0 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 aa81d02924e0..017a4f5da4b6 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 fecc1b801d2f..4e0355f14f05 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 96c47b0ac564..2df1dd1afc53 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 beaa60ed47bc..e97b1d94e3ce 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 b724c243da0c..ba34ffe59959 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 d8421d271d20..f3c771fa7c88 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 667eef6efc56..8399415cd802 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 e1e640d87dff..b970d51da5ba 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 d5b83a3ad7de..6f764569d490 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 407adadbdf7a..ec00faf062b0 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 5407d3933ae7..ed2c02c8d9da 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 4ffe2c27d243..9f04c58c0b64 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 ); } |