10#if !defined(HPP_ALIB_TIME_TIME)
14#if !defined (HPP_ALIB_TIME_TICKSCONVERTER)
20using namespace std::chrono;
46 Ticks* creationTime=
nullptr;
54 creationTime=
new Ticks();
68 creationTime=
nullptr;
86 for(
int i= 0 ; i < qtyRepeats ; ++i )
88 systemClock= system_clock::now();
89 steadyClock= steady_clock::now();
91 auto systemCount= systemClock.time_since_epoch().count();
92 auto steadyCount= steadyClock.time_since_epoch().count();
98 if( systemCount < steadyCount )
100 uint64_t diff=
static_cast<uint64_t
>( steadyCount - systemCount );
101 if( lastDiff == 0 || diff < lastDiff )
110 uint64_t diff=
static_cast<uint64_t
>( systemCount - steadyCount );
111 if( lastDiff == 0 || diff > lastDiff )
126#if defined( _WIN32 ) && !defined(ALIB_DOX)
129using filetime_duration = duration<int64_t, std::ratio<1, 10000000> >;
132constexpr duration<int64_t> nt_to_unix_epoch{INT64_C(-11644473600)};
136 const auto asDuration = duration_cast<filetime_duration>(
stamp.time_since_epoch() );
137 const auto withNtEpoch= asDuration - nt_to_unix_epoch;
138 const auto rawCount = withNtEpoch.count();
141 result.dwLowDateTime =
static_cast<DWORD
>(rawCount);
142 result.dwHighDateTime =
static_cast<DWORD
>(rawCount >> 32);
150 ULARGE_INTEGER result;
151 result.HighPart= ft.dwHighDateTime;
152 result.LowPart= ft.dwLowDateTime;
158 const filetime_duration ftDuration {
static_cast<int64_t
>( (
static_cast<uint64_t
>( fileTime.dwHighDateTime) << 32)
159 | fileTime.dwLowDateTime ) };
166 fileTime.dwLowDateTime = ft.LowPart;
167 fileTime.dwHighDateTime = ft.HighPart;
176 FileTimeToSystemTime( &ft, &result );
180 FileTimeToSystemTime( &ft, &utc );
181 SystemTimeToTzSpecificLocalTime( NULL, &utc, &result );
190 SystemTimeToFileTime( &st, &ft );
194 TzSpecificLocalTimeToSystemTime( NULL, &st, &utc);
195 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
ALIB_API void SyncClocks(int qtyRepeats=5)
DateTime::TTimePoint systemClockSyncTime
typename TClock::time_point TTimePoint
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define ALIB_IF_BOXING(...)
#define ALIB_BOXING_BOOTSTRAP_VTABLE_DBG_REGISTER(Identifier)
@ UTC
Denotes UTC (coordinated universal time).
time::Ticks Ticks
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.