AuroraRuntime/Include/Aurora/Time/Time.hpp

51 lines
1.4 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Time.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
namespace Aurora::Time
{
static inline AuString ConvertMSToTimescaleEN(AuUInt32 ms)
{
const auto msDiv1000 = ms / 1000; // seconds
const auto msDiv1000Mod60 = msDiv1000 % 60; // remaining seconds relative to next whole minute
const auto msDiv1000Div60 = msDiv1000 / 60; // total minutes
if (ms < 1000)
{
return std::to_string(ms) + "ms";
}
else if (ms >= 1000)
{
auto s = msDiv1000;
auto remMs = ms % 1000;
return std::to_string(s) + "." + std::to_string(remMs) + "s";
}
else if (ms > (1000 * 60))
{
auto m = msDiv1000Div60;
auto remS = msDiv1000Mod60;
return std::to_string(m) + "m " + std::to_string(remS) + "s";
}
else if (ms > (1000 * 60 * 60))
{
auto h = msDiv1000Div60 / 60;
auto remM = msDiv1000Div60 % 60;
auto remS = msDiv1000Mod60;
return std::to_string(h) + "h " + std::to_string(remM) + "m" + std::to_string(remS) + "s";
}
else
{
return std::to_string(ms); // ?
}
}
}
#include "Clock.hpp"
#include "Timer.hpp"
#include "TimerHighRes.hpp"
#include "DebugBenchmark.hpp"