diff options
author | Eike Rathke <erack@redhat.com> | 2023-06-23 12:42:29 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2023-06-23 18:32:17 +0200 |
commit | c968d8989004301b49d67a093a6eb8a629533837 (patch) | |
tree | 8db7e3cac3323908697f1ef445911f3056443b2e /include/tools | |
parent | 759d414748bda99f29b04806f72d479e320c2f9f (diff) |
Introduce tools::Duration individual time values ctor
Change-Id: I516d3727cbcf6667b32dc963febbf4b753ef6a91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153497
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'include/tools')
-rw-r--r-- | include/tools/duration.hxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/tools/duration.hxx b/include/tools/duration.hxx index a027cd671cd1..ea33953751b8 100644 --- a/include/tools/duration.hxx +++ b/include/tools/duration.hxx @@ -39,6 +39,14 @@ public: unless one is 0. */ Duration(sal_Int32 nDays, const Time& rTime); + /** Individual time values can be out-of-range, all will be normalized. + Additionally, the resulting time overall hour value is not restricted + to sal_uInt16 like it is with Time, as values >=24 flow over into days. + For a negative duration only a negative nDays can be given, thus a + negative duration of less than one day is not possible. */ + Duration(sal_Int32 nDays, sal_uInt32 nHours, sal_uInt32 nMinutes, sal_uInt32 nSeconds, + sal_uInt64 nNanoseconds); + bool IsNegative() const { return mnDays < 0 || maTime.GetTime() < 0; } sal_Int32 GetDays() const { return mnDays; } const Time& GetTime() const { return maTime; } @@ -60,6 +68,10 @@ private: /** Internal days and Time values. */ Duration(sal_Int32 nDays, sal_Int64 nTime); + /** Prerequisite: mnDays is already set. */ + void Normalize(sal_uInt64 nHours, sal_uInt64 nMinutes, sal_uInt64 nSeconds, + sal_uInt64 nNanoseconds, bool bNegative); + /** Prerequisite: mnDays is already correctly set and absolute value of nanoseconds less than one day. */ void ApplyTime(sal_Int64 nNS); |