diff options
author | Eike Rathke <erack@redhat.com> | 2023-06-21 14:31:02 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-06-21 21:48:12 +0200 |
commit | 9cf4983e7e6db5c2198c61c30b9c77d089105b3a (patch) | |
tree | bf900c3db7fafa2071900176ae4d68a2a006ca14 /include | |
parent | 8b330bb761e05fcfabd5a30f8784046c93b91431 (diff) |
Change DateTime friend operator-() to return tools::Duration instead of double
Change-Id: Ica69b1a8916c73443d9ec91dd35ed126fcf97151
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153392
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/tools/datetime.hxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx index 21cb65921d27..17d2f89a80b6 100644 --- a/include/tools/datetime.hxx +++ b/include/tools/datetime.hxx @@ -101,9 +101,14 @@ public: { return operator+( rDateTime, -fTimeInDays ); } TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const tools::Time& rTime ); TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const tools::Time& rTime ); - TOOLS_DLLPUBLIC friend double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 ); - /** Same as friend operator-() to be able to disable operator-() to find - places where tools::Duration could be used instead. */ + /** Use operator-() if a duration is to be remembered or processed. */ + TOOLS_DLLPUBLIC friend tools::Duration operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 ); + /** Use Sub() if the floating point "time in days" value is to be + processed. This also takes a shortcut for whole days values (equal + times), and only for times inflicted values uses an intermediary + tools::Duration for conversion. Note that the resulting floating point + value neverthless in many cases is not an exact representation down to + nanoseconds. */ static double Sub( const DateTime& rDateTime1, const DateTime& rDateTime2 ); TOOLS_DLLPUBLIC friend sal_Int64 operator -( const DateTime& rDateTime, const Date& rDate ) { return static_cast<const Date&>(rDateTime) - rDate; } |