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
+2 -1
View File
@@ -14,4 +14,5 @@ add_subdirectory(asset)
add_subdirectory(log)
add_subdirectory(input)
add_subdirectory(network)
add_subdirectory(system)
add_subdirectory(system)
add_subdirectory(time)
+2 -2
View File
@@ -28,7 +28,7 @@ bool_t networkLinuxIsConnected() {
// Check if any non loopback interfaces have running flag set.
bool_t connected = false;
for(ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
if (!ifa->ifa_name || !ifa->ifa_flags) continue;
if(!ifa->ifa_name || !ifa->ifa_flags) continue;
// Skip loopback (localhost)
if(ifa->ifa_flags & IFF_LOOPBACK) continue;
@@ -64,7 +64,7 @@ networkinfo_t networkLinuxGetInfo() {
// Find the first non-loopback interface with an IP address
for(ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
if (!ifa->ifa_name || !ifa->ifa_flags) continue;
if(!ifa->ifa_name || !ifa->ifa_flags) continue;
// Skip loopback (localhost)
if(ifa->ifa_flags & IFF_LOOPBACK) continue;
+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