14using namespace std::chrono;
38 Ticks* creationTime=
nullptr;
41 unsigned int initFlag= 0;
50 ALIB_ASSERT_ERROR( initFlag == 0,
"TIME",
"This method must not be invoked twice." )
55 creationTime=
new Ticks();
66 ALIB_ASSERT_ERROR( initFlag == 0x92A3EF61,
"TIME",
"Not initialized when calling shutdown." )
71 creationTime=
nullptr;
90 for(
int i= 0 ; i < qtyRepeats ; ++i )
92 systemClock= system_clock::now();
93 steadyClock= steady_clock::now();
95 auto systemCount= systemClock.time_since_epoch().count();
96 auto steadyCount= steadyClock.time_since_epoch().count();
102 if( systemCount < steadyCount )
104 uint64_t diff=
static_cast<uint64_t
>( steadyCount - systemCount );
105 if( lastDiff == 0 || diff < lastDiff )
114 uint64_t diff=
static_cast<uint64_t
>( systemCount - steadyCount );
115 if( lastDiff == 0 || diff > lastDiff )
130#if defined( _WIN32 ) && !DOXYGEN
133using filetime_duration = duration<int64_t, std::ratio<1, 10000000> >;
136constexpr duration<int64_t> nt_to_unix_epoch{INT64_C(-11644473600)};
140 const auto asDuration = duration_cast<filetime_duration>(
stamp.time_since_epoch() );
141 const auto withNtEpoch= asDuration - nt_to_unix_epoch;
142 const auto rawCount = withNtEpoch.count();
145 result.dwLowDateTime =
static_cast<DWORD
>(rawCount);
146 result.dwHighDateTime =
static_cast<DWORD
>(rawCount >> 32);
154 ULARGE_INTEGER result;
155 result.HighPart= ft.dwHighDateTime;
156 result.LowPart= ft.dwLowDateTime;
162 const filetime_duration ftDuration {
static_cast<int64_t
>( (
static_cast<uint64_t
>( fileTime.dwHighDateTime) << 32)
163 | fileTime.dwLowDateTime ) };
170 fileTime.dwLowDateTime = ft.LowPart;
171 fileTime.dwHighDateTime = ft.HighPart;
180 FileTimeToSystemTime( &ft, &result );
184 FileTimeToSystemTime( &ft, &utc );
185 SystemTimeToTzSpecificLocalTime( NULL, &utc, &result );
194 SystemTimeToFileTime( &st, &ft );
198 TzSpecificLocalTimeToSystemTime( NULL, &st, &utc);
199 SystemTimeToFileTime( &utc, &ft );
ALIB_API ULARGE_INTEGER ToFileTimeLI() const
static ALIB_API DateTime FromFileTime(const FILETIME &fileTime)
static ALIB_API DateTime FromSystemTime(const SYSTEMTIME &systemTime, lang::Timezone timezone=lang::Timezone::Local)
ALIB_API SYSTEMTIME ToSystemTime(lang::Timezone timezone=lang::Timezone::Local) const
ALIB_API FILETIME ToFileTime() const
Ticks::TTimePoint steadyClockSyncTime
Time point of steady clock of last invocation of SyncClocks.
ALIB_API void SyncClocks(int qtyRepeats=5)
DateTime::TTimePoint systemClockSyncTime
Time point of system clock of last invocation of SyncClocks.
typename std::chrono::steady_clock::time_point TTimePoint
#define IF_ALIB_BOXING(...)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER(Identifier)
#define ALIB_ASSERT_ERROR(cond,...)
Timezone
Denotes whether a time value represents local time or UTC.
@ UTC
Denotes UTC (coordinated universal time).
time::Ticks Ticks
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.