#pragma once
#include <cstdint>
#include <chrono>
#if defined(_WIN32)
#include <Windows.h>
#elif defined(__unix__)
#include <time.h>
#else
#error dasdasd
#endif
struct win_time
{
using rep = int64_t;
using period = std::ratio<1, 10000000>;
using duration = std::chrono::duration<rep, period>;
using time_point = std::chrono::time_point<win_time, duration>;
static time_point now() noexcept;
static constexpr bool is_steady = true;
private:
static constexpr int64_t UNIX_START = 116444736000000000;
};
inline win_time::time_point win_time::now() noexcept
{
#if defined(_WIN32)
FILETIME ft;
GetSystemTimePreciseAsFileTime( &ft );
return time_point( duration( (uint64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime ) );
#elif defined(__unix__)
timespec ts;
clock_gettime( CLOCK_REALTIME, &ts );
return time_point( duration( UNIX_START + (uint64_t)ts.tv_sec * 10'000'000u + ((uint64_t)ts.tv_nsec + 50u) / 100u ) );
#endif
}
What does this do ?
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,069 |
Nodes: | 10 (0 / 10) |
Uptime: | 70:49:33 |
Calls: | 13,725 |
Files: | 186,960 |
D/L today: |
4,338 files (1,090M bytes) |
Messages: | 2,410,344 |