summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-07-20 18:32:57 +0200
committerEike Rathke <erack@redhat.com>2017-07-21 12:24:27 +0200
commitfcd0361d6be8d088be12e500f0120afd7995d1ac (patch)
tree9e18c0310405d68d9151db9073cc8f6926df077d /basic
parent2e486daff35ab16e810bfdafb24b19bcbf2fe8cd (diff)
Eliminate Date::operator+=() and -=() and replace with Date::AddDays()
Clarifies code and gets rid of explicitly casting the operand to sal_Int32. Also in preparation of removing DateTime::operator+=(sal_Int32) that is confusingly similar to DateTime::operator+=(double) and just depends on type. Change-Id: I83422e2940fbb017978db9b5734b4966228af3de Reviewed-on: https://gerrit.libreoffice.org/40248 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx10
-rw-r--r--basic/source/runtime/methods1.cxx4
2 files changed, 7 insertions, 7 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 56fa68c2aa52..f1b5b7d3365e 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1702,7 +1702,7 @@ sal_Int16 implGetDateDay( double aDate )
aDate -= 2.0; // standardize: 1.1.1900 => 0.0
aDate = floor( aDate );
Date aRefDate( 1, 1, 1900 );
- aRefDate += static_cast<sal_Int32>(aDate);
+ aRefDate.AddDays( aDate );
sal_Int16 nRet = (sal_Int16)( aRefDate.GetDay() );
return nRet;
@@ -1711,9 +1711,9 @@ sal_Int16 implGetDateDay( double aDate )
sal_Int16 implGetDateMonth( double aDate )
{
Date aRefDate( 1,1,1900 );
- long nDays = (long)aDate;
+ sal_Int32 nDays = (sal_Int32)aDate;
nDays -= 2; // standardize: 1.1.1900 => 0.0
- aRefDate += nDays;
+ aRefDate.AddDays( nDays );
sal_Int16 nRet = (sal_Int16)( aRefDate.GetMonth() );
return nRet;
}
@@ -4582,7 +4582,7 @@ sal_Int16 implGetDateYear( double aDate )
Date aRefDate( 1,1,1900 );
long nDays = (long) aDate;
nDays -= 2; // standardize: 1.1.1900 => 0.0
- aRefDate += nDays;
+ aRefDate.AddDays( nDays );
sal_Int16 nRet = aRefDate.GetYear();
return nRet;
}
@@ -4672,7 +4672,7 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay,
if (nAddMonths)
aCurDate.AddMonths( nAddMonths);
if (nAddDays)
- aCurDate += nAddDays;
+ aCurDate.AddDays( nAddDays);
}
long nDiffDays = GetDayDiff( aCurDate );
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 1dbfa9db3285..a67de7407a6b 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -3037,9 +3037,9 @@ void SbRtl_Me(StarBASIC *, SbxArray & rPar, bool)
sal_Int16 implGetWeekDay( double aDate, bool bFirstDayParam, sal_Int16 nFirstDay )
{
Date aRefDate( 1,1,1900 );
- long nDays = (long) aDate;
+ sal_Int32 nDays = (sal_Int32) aDate;
nDays -= 2; // normalize: 1.1.1900 => 0
- aRefDate += nDays;
+ aRefDate.AddDays( nDays);
DayOfWeek aDay = aRefDate.GetDayOfWeek();
sal_Int16 nDay;
if ( aDay != SUNDAY )