From fcd0361d6be8d088be12e500f0120afd7995d1ac Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 20 Jul 2017 18:32:57 +0200 Subject: 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 Tested-by: Eike Rathke --- include/tools/date.hxx | 6 ++++-- include/tools/datetime.hxx | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/tools/date.hxx b/include/tools/date.hxx index 3e038beb308b..071b3c3b765c 100644 --- a/include/tools/date.hxx +++ b/include/tools/date.hxx @@ -125,6 +125,10 @@ public: */ void AddMonths( sal_Int32 nAddMonths ); + /** Add days skipping year 0 and truncating at limits. + */ + void AddDays( sal_Int32 nAddDays ); + /** Obtain the day of the week for the date. Internally normalizes a copy of values. @@ -216,8 +220,6 @@ public: { mnDate = rDate.mnDate; return *this; } Date& operator =( const css::util::Date& rUDate ) { setDateFromDMY( rUDate.Day, rUDate.Month, rUDate.Year); return *this; } - Date& operator +=( sal_Int32 nDays ); - Date& operator -=( sal_Int32 nDays ); Date& operator ++(); Date& operator --(); diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx index 7e2756ff730b..8d224dd73633 100644 --- a/include/tools/datetime.hxx +++ b/include/tools/datetime.hxx @@ -81,9 +81,9 @@ public: void ConvertToLocalTime() { *this += Time::GetUTCOffset(); } DateTime& operator +=( sal_Int32 nDays ) - { Date::operator+=( nDays ); return *this; } + { AddDays( nDays ); return *this; } DateTime& operator -=( sal_Int32 nDays ) - { Date::operator-=( nDays ); return *this; } + { AddDays( -nDays ); return *this; } DateTime& operator +=( double fTimeInDays ); DateTime& operator -=( double fTimeInDays ) { return operator+=( -fTimeInDays ); } -- cgit