AuroraRuntime/Source/Time/Time.hpp
Reece 19ebdf3761 Preparing for initial WSA network POC rewrite, not porting gen1 code. Linux support is way behind. Will work on it soon.
[*] Minor refactors
[*] Begin refactoring the Processes subsystem
[*] Added empty files ready to move the gross c++ functional callback in the parse subsystem to a dedicated interface w/ utils
[*] Broke out Win32 Process into an NT base variant (Process.NT.cpp) with Win32 overloaded process exit pokes (Process.Win32.cpp)
2022-01-29 12:36:25 +00:00

44 lines
1.0 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Time.hpp
Date: 2021-6-17
Author: Reece
***/
#pragma once
namespace Aurora::Time
{
#if defined(AURORA_PLATFORM_WIN32)
static inline AuSInt ConvertTimestamp(const FILETIME &ft)
{
ULARGE_INTEGER ull;
ull.LowPart = ft.dwLowDateTime;
ull.HighPart = ft.dwHighDateTime;
return ull.QuadPart / 10000ULL - 12'643'553'700'000ULL;
}
#elif defined(AURORA_IS_POSIX_DERIVED)
static inline AuUInt32 ConvertUnixTimespecToMs(const struct timespec &spec)
{
return ConvertUnixToAuroraMS(spec.tv_sec * 1000ULL + spec.tv_nsec / 1000000ULL);
}
static void ms2ts(struct timespec *ts, unsigned long ms)
{
ts->tv_sec = ms / 1000;
ts->tv_nsec = (ms % 1000) * 1000000;
}
static void ms2tsabs(struct timespec *ts, unsigned long ms)
{
ms += ConvertAuroraToUnixMS(CurrentClockMS());
ts->tv_sec = ms / 1000;
ts->tv_nsec = (ms % 1000) * 1000000;
}
#endif
}