sc: Use DateTime::Sub() instead of operator-()

Change-Id: Ib73eec1c11ced76890b8eacb0079ae336072a4c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153379
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
This commit is contained in:
Eike Rathke
2023-06-21 12:48:51 +02:00
parent ba54ce4c65
commit ea4f477523
4 changed files with 7 additions and 9 deletions
+1 -1
View File
@@ -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. */
+1 -1
View File
@@ -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 >();
}
+3 -2
View File
@@ -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;
+2 -5
View File
@@ -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;