diff options
author | Eike Rathke <erack@redhat.com> | 2017-07-20 18:32:57 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-07-21 12:24:27 +0200 |
commit | fcd0361d6be8d088be12e500f0120afd7995d1ac (patch) | |
tree | 9e18c0310405d68d9151db9073cc8f6926df077d /include | |
parent | 2e486daff35ab16e810bfdafb24b19bcbf2fe8cd (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 'include')
-rw-r--r-- | include/tools/date.hxx | 6 | ||||
-rw-r--r-- | include/tools/datetime.hxx | 4 |
2 files changed, 6 insertions, 4 deletions
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 ); } |