AuroraRuntime/Include/Aurora/Time/Time.hpp
Jamie Reece Wilson 83fad7c538 [+] AuTime::Clock<T>::GetCurrentTimeNS();
[+] AuTime::Clock<T>::GetFrequency();
where T =
[+] AuTime::ClockWall
[+] AuTime::ClockSteady
[+] AuTime::ClockProcessTime
[+] AuTime::ClockProcessKernelTime
[+] AuTime::ClockProcessUserTime
[+] AuTime::ClockThreadTime
[+] AuTime::ClockThreadKernelTime
[+] AuTime::ClockThreadUserTime
2023-07-08 17:28:24 +01:00

81 lines
2.3 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Time.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#include "_Time.hpp"
#include "StaticClocks.hpp"
#include "StaticClocksDirect.hpp"
#include "StaticClocksClasses.hpp"
namespace Aurora::Time
{
/**
Converts milliseconds from the Aurora epoch to a civil timestamp structure
similar to or of std::tm
*/
AUKN_SYM tm ToCivilTime(AuInt64 time, bool bIsUTC = true);
/**
Converts civil time to milliseconds from the Aurora epoch
*/
AUKN_SYM AuInt64 FromCivilTime(const tm &time, bool bIsUTC = true);
/**
Normalizes a civil data structure with respect to UTC, given the two input parameters 'in' civil and 'shiftFrom' timezone hint
*/
AUKN_SYM tm NormalizeCivilTimezone(const tm &in, ETimezoneShift shiftFrom = ETimezoneShift::eUTC);
/**
Translates the Aurora epoch to the standard unix epoch
*/
AUKN_SYM AuInt64 ConvertAuroraToUnixMS(AuInt64 in);
/**
Translates the Aurora epoch to the standard unix epoch
*/
AUKN_SYM AuInt64 ConvertAuroraToUnixNS(AuInt64 in);
/**
Translates a standard unix epoch to the Aurora epoch
*/
AUKN_SYM AuInt64 ConvertUnixToAuroraMS(AuInt64 in);
/**
Translates a standard unix epoch to the Aurora epoch
*/
AUKN_SYM AuInt64 ConvertUnixToAuroraNS(AuInt64 in);
/**
Converts seconds from the Aurora epoch to time_t
*/
AUKN_SYM time_t SToCTime(AuInt64 time);
/**
Converts nanoseconds from the Aurora epoch to time_t
*/
AUKN_SYM time_t NSToCTime(AuInt64 time);
/**
Converts milliseconds from the Aurora epoch to time_t
*/
AUKN_SYM time_t MSToCTime(AuInt64 time);
AUKN_SYM AuInt64 CTimeToMS(time_t time);
// TODO: Unix style of GetClockTimeNSByEnum/GetClockResNSByEnum?
//
// Interfaces make sense for code that would like to deal with abstract clocks
// Accessing a single by a single query-clock API makes sense for general purpose use (eg: GetWallTimeNS/CurrentClockNS, SteadyClockNS(), ...)
//
// A potential GetClock[Time/Res][NS]ByEnum(EClock::...) feels too bloated, but it is a nice hybrid between the two use cases
}