New class tools::Duration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Commit
https://git.libreoffice.org/core/+/eac63ab120a181a1dff6317ee3d223327080e992%5E!/
introduced class tools::Duration (sal_Int32 days plus tools:Time) with
include/tools/duration.hxx that integrates with class DateTime to
calculate DateTime+Duration. Furthermore it can convert from
"TimeInDays" double values and corrects slight binary floating point
inaccuracies off by a nanosecond and handles Add() and Mult()
operations.

Code that still abuses tools::Time for (limited in capacity, i.e.
sal_uInt16 hours, ~7 years) durations should be considered to be
rewritten using tools::Duration, also code that subtracts two DateTime
values to obtain a double for duration should be converted to a proper
tools::Duration to diminish floating point inaccuracy. The same for code
that subtracts two double values that are known to originate from
DateTime values.

Once done, we could change

    friend double   operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 );

to

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

(you can also use that temporarily to find code places to change).

Happy conversion..

  Eike

-- 
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux