From 7f3c6efd859050c8f376b6820710e91fa9077ac4 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 28 Aug 2018 13:46:37 +0200 Subject: Move lcl_getHourMinuteSecond() to tools::Time::GetClock() Also add fFractionOfSecond and nFractionDecimals to obtain the remaining fraction of second. In preparation to use this in the number formatter and other places that obtain the wall clock time particles, which likely so far use bad rounding as well. Change-Id: I4fbea4165c560646438b06c340756c97dafa7c78 Reviewed-on: https://gerrit.libreoffice.org/59700 Reviewed-by: Eike Rathke Tested-by: Jenkins --- include/tools/time.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/tools/time.hxx b/include/tools/time.hxx index c6ada22a526d..9c137e5b9196 100644 --- a/include/tools/time.hxx +++ b/include/tools/time.hxx @@ -104,6 +104,25 @@ public: /// 12 hours == 0.5 days double GetTimeInDays() const; + /** Get the wall clock time particles for a (date+)time value. + + Does the necessary rounding and truncating to obtain hour, minute, + second and fraction of second from a double time value (time in days, + 0.5 == 12h) such that individual values are not rounded up, i.e. + x:59:59.999 does not yield x+1:0:0.00 + + A potential date component (fTimeInDays >= 1.0) is discarded. + + @param nFractionDecimals + If > 0 fFractionOfSecond is truncated to that amount of + decimals. + Else fFractionOfSecond returns the full remainder of the + fractional second. + */ + static void GetClock( double fTimeInDays, + sal_uInt16& nHour, sal_uInt16& nMinute, sal_uInt16& nSecond, + double& fFractionOfSecond, int nFractionDecimals ); + bool IsEqualIgnoreNanoSec( const tools::Time& rTime ) const; bool operator ==( const tools::Time& rTime ) const -- cgit