This commit is contained in:
Tenari
2026-07-02 08:59:18 -05:00
parent 87c180bda9
commit 71552a57de
5 changed files with 64 additions and 14 deletions
+21
View File
@@ -273,3 +273,24 @@ fn bool osFileWriteOpenFile(Resulti64 handle, String data) {
return true;
}
// Time
fn u64 osTimeMicrosecondsNow() {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
return ((u64)ts.tv_sec * MICROSECONDS_PER_SECOND) + ((u64)ts.tv_nsec / NANOSECONDS_PER_MICROSECOND);
}
fn HumanTime osHumanTimeFromMicroseconds(u64 micros) {
HumanTime result = {0};
time_t secs = (time_t)(micros / 1000000ULL);
struct tm t;
localtime_r(&secs, &t);
result.year = 1900 + t.tm_year;
result.month = t.tm_mon + 1;
result.month_i = t.tm_mon;
result.date = t.tm_mday;
result.hour = t.tm_hour;
result.min = t.tm_min;
result.sec = t.tm_sec;
return result;
}