mirror of
https://github.com/jorio/Pomme.git
synced 2024-09-27 12:55:59 +00:00
43 lines
976 B
C++
43 lines
976 B
C++
#include "Pomme.h"
|
|
#include "PommeTime.h"
|
|
#include "PommeTypes.h"
|
|
#include "PommeDebug.h"
|
|
|
|
#include <chrono>
|
|
#include <iostream>
|
|
#include <ctime>
|
|
#include <iomanip>
|
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> bootTP;
|
|
|
|
// timestamp (from unix epoch) of the mac epoch, Jan 1, 1904, 00:00:00
|
|
constexpr int JANUARY_1_1904 = -2'082'844'800;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Time Manager
|
|
|
|
void Pomme::Time::Init()
|
|
{
|
|
bootTP = std::chrono::high_resolution_clock::now();
|
|
}
|
|
|
|
void GetDateTime(unsigned long* secs)
|
|
{
|
|
*secs = (unsigned long) (std::time(nullptr) + JANUARY_1_1904);
|
|
}
|
|
|
|
void Microseconds(UnsignedWide* usecs)
|
|
{
|
|
auto now = std::chrono::high_resolution_clock::now();
|
|
auto usecs1 = std::chrono::duration_cast<std::chrono::microseconds>(now - bootTP);
|
|
auto usecs2 = usecs1.count();
|
|
usecs->lo = usecs2 & 0xFFFFFFFFL;
|
|
usecs->hi = (usecs2 >> 32) & 0xFFFFFFFFL;
|
|
}
|
|
|
|
UInt32 TickCount()
|
|
{
|
|
TODO();
|
|
return 0;
|
|
}
|