2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Time.hpp
|
2023-03-21 10:05:45 +00:00
|
|
|
Date: 2021-6-10
|
2021-06-27 21:25:29 +00:00
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2023-03-21 10:05:45 +00:00
|
|
|
#include "_Time.hpp"
|
2022-01-24 18:37:06 +00:00
|
|
|
|
2023-07-08 16:28:24 +00:00
|
|
|
#include "StaticClocks.hpp"
|
|
|
|
#include "StaticClocksDirect.hpp"
|
|
|
|
#include "StaticClocksClasses.hpp"
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora::Time
|
|
|
|
{
|
2023-03-21 10:05:45 +00:00
|
|
|
/**
|
|
|
|
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);
|
|
|
|
|
2023-07-08 16:28:24 +00:00
|
|
|
|
2023-06-19 16:26:41 +00:00
|
|
|
|
2023-03-21 10:05:45 +00:00
|
|
|
/**
|
|
|
|
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);
|
|
|
|
|
2023-06-22 18:34:47 +00:00
|
|
|
|
|
|
|
// 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
|
2023-03-21 10:05:45 +00:00
|
|
|
}
|