diff options
author | Eike Rathke <erack@redhat.com> | 2018-08-28 13:46:37 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-08-28 16:23:46 +0200 |
commit | 7f3c6efd859050c8f376b6820710e91fa9077ac4 (patch) | |
tree | 7b177de4a02917fcc4558794361fe076efdd5dad /include/tools/time.hxx | |
parent | b57ed76361da672697eccd219b09bd358a967e0d (diff) |
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 <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'include/tools/time.hxx')
-rw-r--r-- | include/tools/time.hxx | 19 |
1 files changed, 19 insertions, 0 deletions
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 |