diff options
author | Eike Rathke <erack@redhat.com> | 2017-07-21 13:32:10 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-07-21 19:26:43 +0200 |
commit | 252aab1b9dc1dbeace3087929a52e1248f043839 (patch) | |
tree | 2890b163a00aaed11c53bfb68c8dbd16325812a7 /tools | |
parent | ec340697d682bd7d0a361c8c701e513329c032bd (diff) |
Eliminate DateTime::operator+=() and -=() with POD types
And make some tools::Time conversion ctors explicit to catch more oddities like
automatic conversion from sal_Int64 that might be unintentional.
Change-Id: If275297d86d6657544c056a712b862523e310e44
Reviewed-on: https://gerrit.libreoffice.org/40275
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/datetime/datetime.cxx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tools/source/datetime/datetime.cxx b/tools/source/datetime/datetime.cxx index b87fcdfe8efe..999c98d4fee8 100644 --- a/tools/source/datetime/datetime.cxx +++ b/tools/source/datetime/datetime.cxx @@ -152,14 +152,14 @@ DateTime& DateTime::operator -=( const tools::Time& rTime ) DateTime operator +( const DateTime& rDateTime, sal_Int32 nDays ) { DateTime aDateTime( rDateTime ); - aDateTime += nDays; + aDateTime.AddDays( nDays ); return aDateTime; } DateTime operator -( const DateTime& rDateTime, sal_Int32 nDays ) { DateTime aDateTime( rDateTime ); - aDateTime -= nDays; + aDateTime.AddDays( -nDays ); return aDateTime; } @@ -177,7 +177,7 @@ DateTime operator -( const DateTime& rDateTime, const tools::Time& rTime ) return aDateTime; } -DateTime& DateTime::operator +=( double fTimeInDays ) +void DateTime::AddTime( double fTimeInDays ) { double fInt, fFrac; if ( fTimeInDays < 0.0 ) @@ -198,13 +198,12 @@ DateTime& DateTime::operator +=( double fTimeInDays ) aTime.MakeTimeFromNS( static_cast<sal_Int64>(fFrac) ); // method handles negative ns operator+=( aTime ); } - return *this; } DateTime operator +( const DateTime& rDateTime, double fTimeInDays ) { DateTime aDateTime( rDateTime ); - aDateTime += fTimeInDays; + aDateTime.AddTime( fTimeInDays ); return aDateTime; } |