7#include "Stroika/Foundation/Math/Common.h"
9namespace Stroika::Foundation::Time {
18 return RealtimeClock::now ();
23 DISABLE_COMPILER_MSC_WARNING_START (4996);
24 DISABLE_COMPILER_GCC_WARNING_START (
"GCC diagnostic ignored \"-Wdeprecated-declarations\"");
25 DISABLE_COMPILER_CLANG_WARNING_START (
"clang diagnostic ignored \"-Wdeprecated-declarations\"");
26 [[deprecated (
"Since Stroika v3.0d5 use kInfinity")]]
constexpr DurationSeconds kInfinite =
27 DurationSeconds{numeric_limits<DurationSeconds::rep>::infinity ()};
28 using DurationSecondsType [[deprecated (
"Since Stroika v3.0d5 - use DurationSeconds or TimePointSeconds")]] = double;
30 template <
typename Clock,
typename Duration>
31 [[deprecated (
"Since Stroika v3.0d5 - use TimePointSeconds")]]
inline DurationSecondsType
32 time_point2DurationSeconds (
const time_point<Clock, Duration>& tp)
34 return TimePointSeconds{tp}.time_since_epoch ().count ();
36 template <
typename Clock,
typename Duration>
37 [[deprecated (
"Since Stroika v3.0d5 - use TimePointSeconds")]] time_point<Clock, Duration> DurationSeconds2time_point (DurationSecondsType t)
42 DISABLE_COMPILER_MSC_WARNING_END (4996);
43 DISABLE_COMPILER_GCC_WARNING_END (
"GCC diagnostic ignored \"-Wdeprecated-declarations\"");
44 DISABLE_COMPILER_CLANG_WARNING_END (
"clang diagnostic ignored \"-Wdeprecated-declarations\"");
55 inline auto Default<Time::DurationSeconds>::GetNext (value_type i) -> value_type
58 return DurationSeconds{nextafter (i.count (), numeric_limits<DurationSeconds::rep>::max ())};
60 inline auto Default<Time::DurationSeconds>::GetPrevious (value_type i) -> value_type
63 return DurationSeconds{nextafter (i.count (), numeric_limits<DurationSeconds::rep>::min ())};
65 constexpr auto Default<Time::DurationSeconds>::Difference (Common::ArgByValueType<value_type> lhs, Common::ArgByValueType<value_type> rhs) -> SignedDifferenceType
75 inline auto Default<Time::TimePointSeconds>::GetNext (value_type i) -> value_type
79 TimePointSeconds::duration{nextafter (i.time_since_epoch ().count (), numeric_limits<TimePointSeconds::duration::rep>::max ())}};
81 inline auto Default<Time::TimePointSeconds>::GetPrevious (value_type i) -> value_type
85 TimePointSeconds::duration{nextafter (i.time_since_epoch ().count (), numeric_limits<TimePointSeconds::duration::rep>::min ())}};
87 constexpr auto Default<Time::TimePointSeconds>::Difference (Common::ArgByValueType<value_type> lhs, Common::ArgByValueType<value_type> rhs) -> SignedDifferenceType
97 inline auto Default<chrono::time_point<Time::DisplayedRealtimeClock, Time::DurationSeconds>>::GetNext (value_type i) -> value_type
100 return value_type{value_type::duration{nextafter (i.time_since_epoch ().count (), numeric_limits<value_type::duration::rep>::max ())}};
102 inline auto Default<chrono::time_point<Time::DisplayedRealtimeClock, Time::DurationSeconds>>::GetPrevious (value_type i) -> value_type
104 using namespace Time;
105 return value_type{value_type::duration{nextafter (i.time_since_epoch ().count (), numeric_limits<value_type::duration::rep>::min ())}};
107 constexpr auto Default<chrono::time_point<Time::DisplayedRealtimeClock, Time::DurationSeconds>>::Difference (
108 Common::ArgByValueType<value_type> lhs, Common::ArgByValueType<value_type> rhs) -> SignedDifferenceType
time_point< RealtimeClock, DurationSeconds > TimePointSeconds
TimePointSeconds is a simpler approach to chrono::time_point, which doesn't require using templates e...
chrono::duration< double > DurationSeconds
chrono::duration<double> - a time span (length of time) measured in seconds, but high precision.
TimePointSeconds GetTickCount() noexcept
get the current (monotonically increasing) time - from RealtimeClock