2024-03-25 05:34:59 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "win.h"
|
|
|
|
#endif
|
|
|
|
|
2024-04-18 21:20:44 +00:00
|
|
|
struct Time {
|
|
|
|
u32 sec;
|
|
|
|
u32 nsec;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Time TimeNow()
|
2024-03-25 05:34:59 +00:00
|
|
|
{
|
|
|
|
struct timespec ts;
|
2024-04-18 21:20:44 +00:00
|
|
|
// Need to check for failiure
|
2024-03-25 05:34:59 +00:00
|
|
|
timespec_get(&ts, TIME_UTC);
|
2024-04-18 21:20:44 +00:00
|
|
|
return (struct Time) { ts.tv_sec, ts.tv_nsec };
|
2024-03-25 05:34:59 +00:00
|
|
|
}
|
|
|
|
|
2024-04-16 22:14:53 +00:00
|
|
|
double TimeNowDouble()
|
2024-03-25 05:34:59 +00:00
|
|
|
{
|
2024-04-16 22:14:53 +00:00
|
|
|
struct timespec ts;
|
|
|
|
timespec_get(&ts, TIME_UTC);
|
|
|
|
|
|
|
|
return ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
|
2024-03-25 05:34:59 +00:00
|
|
|
}
|