New class tools::Duration

Eike Rathke erack at redhat.com
Wed Jun 21 11:25:30 UTC 2023


Hi,

On Monday, 2023-06-19 18:41:48 +0200, Eike Rathke wrote:
> On Monday, 2023-06-19 14:25:16 +0200, Eike Rathke wrote:
> >     friend tools::Duration operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );
> > (you can also use that temporarily to find code places to change).
> 
> Having tried that, it tends to get cumbersome [...]

So what I came up with is

    static  double  Sub( const DateTime& rDateTime1, const DateTime& rDateTime2 );

and changed all relevant places to use DateTime::Sub() instead of
operator-(), which were less than I initially thought there would be.

Next step will change operator-() to

    friend tools::Duration operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );

so if one needs a duration to be remembered use that, and otherwise if
the floating point "time in days" value is to be processed use
DateTime::Sub().

  Eike

-- 
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20230621/a55270f4/attachment.sig>


More information about the LibreOffice mailing list