Add epoch

This commit is contained in:
2026-04-28 10:33:23 -05:00
parent 19f2a2c616
commit 73e7d6c7f3
17 changed files with 555 additions and 9 deletions
+9
View File
@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
timelinux.c
)
+29
View File
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "time/timelinux.h"
#include <time.h>
double_t timeGetRealLinux(void) {
struct timespec ts;
if(clock_gettime(CLOCK_REALTIME, &ts) != 0) {
return 0.0;
}
return (
((double)ts.tv_sec) +
((double)ts.tv_nsec / 1000000000.0)
);
}
double_t timeGetRealTimeZoneLinux(void) {
time_t now = time(NULL);
struct tm local_tm;
localtime_r(&now, &local_tm);
return (double_t)(local_tm.tm_gmtoff);
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
/**
* Returns the real current time, in seconds since January 1, 1970.
*
* @return The real current time, in seconds since January 1, 1970.
*/
double_t timeGetRealLinux(void);
/**
* Returns the real time zone offset in seconds from UTC.
*
* @return The real time zone offset in seconds from UTC.
*/
double_t timeGetRealTimeZoneLinux(void);
+15
View File
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "time/timesdl2.h"
#include "time/timelinux.h"
#define timeTickPlatform timeTickSDL2
#define timeGetDeltaPlatform timeGetDeltaSDL2
#define timeGetRealPlatform timeGetRealLinux
#define timeGetRealTimeZonePlatform timeGetRealTimeZoneLinux