include/unotools/calendarwrapper.hxx      |    2 +-
 sc/source/filter/excel/xlroot.cxx         |    2 +-
 sc/source/filter/oox/pivotcachebuffer.cxx |    2 +-
 sc/source/ui/docshell/impex.cxx           |    5 +++--
 sc/source/ui/view/viewfun6.cxx            |    7 ++-----
 5 files changed, 8 insertions(+), 10 deletions(-)

New commits:
commit ea4f47752391cecef670cbefc9dbfc8b51182c49
Author:     Eike Rathke <[email protected]>
AuthorDate: Wed Jun 21 10:48:40 2023 +0200
Commit:     Eike Rathke <[email protected]>
CommitDate: Wed Jun 21 12:48:51 2023 +0200

    sc: Use DateTime::Sub() instead of operator-()
    
    Change-Id: Ib73eec1c11ced76890b8eacb0079ae336072a4c1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153379
    Reviewed-by: Eike Rathke <[email protected]>
    Tested-by: Jenkins

diff --git a/sc/source/filter/excel/xlroot.cxx 
b/sc/source/filter/excel/xlroot.cxx
index 71d308d2f29c..f816339b34d7 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -341,7 +341,7 @@ const DateTime theExcelCutOverDate( Date( 1, 3, 1900 ));
 
 double XclRoot::GetDoubleFromDateTime( const DateTime& rDateTime ) const
 {
-    double fValue = rDateTime - GetNullDate();
+    double fValue = DateTime::Sub( rDateTime, GetNullDate());
     // adjust dates before 1900-03-01 to get correct time values in the range 
[0.0,1.0)
     /* XXX: this is only used when reading BIFF, otherwise we'd have to check
      * for dateCompatibility==true as mentioned below. */
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx 
b/sc/source/filter/oox/pivotcachebuffer.cxx
index 4896f3123e92..cbbacc8a6123 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -253,7 +253,7 @@ OUString PivotCacheItem::getFormattedName(const 
ScDPSaveDimension& rSaveDim, ScD
                 SAL_WARN("sc", "PivotCacheField::getFormattedName - invalid 
date");
                 return OUString();
             }
-            return pObj->GetFormattedString(rSaveDim.GetName(), aDateTime - 
rNullDate);
+            return pObj->GetFormattedString(rSaveDim.GetName(), 
DateTime::Sub(aDateTime, rNullDate));
         }
         case XML_e: return maValue.get< OUString >();
     }
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index c405fb2c45a3..970e75aadd9e 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1426,8 +1426,9 @@ static bool lcl_PutString(
                 pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, 0 
);
                 if ( pCalendar->isValid() )
                 {
-                    double fDiff = DateTime(pDocFormatter->GetNullDate()) -
-                        pCalendar->getEpochStart();
+                    // Whole days diff.
+                    double fDiff = DateTime::Sub( 
DateTime(pDocFormatter->GetNullDate()),
+                            pCalendar->getEpochStart());
                     // #i14974# must use getLocalDateTime to get the same
                     // date values as set above
                     double fDays = pCalendar->getLocalDateTime() + fFrac;
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index 2a68f730b9bf..e8e9dbc554ed 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -334,7 +334,7 @@ void ScViewFunc::InsertCurrentTime(SvNumFormatType nReqFmt, 
const OUString& rUnd
             case SvNumFormatType::DATETIME:
                 {
                     DateTime aActDateTime( DateTime::SYSTEM );
-                    fVal = aActDateTime - DateTime( pFormatter->GetNullDate());
+                    fVal = DateTime::Sub( aActDateTime, DateTime( 
pFormatter->GetNullDate()));
                     if (nCurNumFormatType == SvNumFormatType::DATETIME)
                         nFormat = nCurNumFormat;
                 }
@@ -470,10 +470,7 @@ void ScViewFunc::InsertCurrentTime(SvNumFormatType 
nReqFmt, const OUString& rUnd
                     default:
                         {
                             DateTime aActDateTime( DateTime::SYSTEM );
-                            // Converting the null date to DateTime forces the
-                            // correct operator-() to be used, resulting in a
-                            // fractional date+time instead of only date value.
-                            fVal = aActDateTime - DateTime( 
pFormatter->GetNullDate());
+                            fVal = DateTime::Sub( aActDateTime, DateTime( 
pFormatter->GetNullDate()));
                         }
                 }
                 break;
commit ba54ce4c65b2fcaa549ec3962604c4d5c9bd10fd
Author:     Eike Rathke <[email protected]>
AuthorDate: Wed Jun 21 10:42:51 2023 +0200
Commit:     Eike Rathke <[email protected]>
CommitDate: Wed Jun 21 12:48:37 2023 +0200

    Use DateTime::Sub() instead of operator-()
    
    Commit this central place use early.
    
    Change-Id: Ib2e40ae7fbe9dc219ba0a7ec4e0f12a82d7b37b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153378
    Reviewed-by: Eike Rathke <[email protected]>
    Tested-by: Jenkins

diff --git a/include/unotools/calendarwrapper.hxx 
b/include/unotools/calendarwrapper.hxx
index aa0bb345c95b..ac1125d2fc66 100644
--- a/include/unotools/calendarwrapper.hxx
+++ b/include/unotools/calendarwrapper.hxx
@@ -115,7 +115,7 @@ public:
 
     /// set a local (!) Gregorian DateTime
     void                setGregorianDateTime( const DateTime& rDateTime )
-                                    { setLocalDateTime( rDateTime - 
aEpochStart ); }
+                                    { setLocalDateTime( DateTime::Sub( 
rDateTime, aEpochStart)); }
 
 };
 

Reply via email to