properly fix time stuff - thanks masa!

This commit is contained in:
Lightos1
2026-04-20 20:14:29 +02:00
parent c9c5d08919
commit b374117c37

View File

@@ -33,6 +33,7 @@ namespace fileUtils {
namespace { namespace {
u64 bootTimeS;
LockableMutex g_log_mutex; LockableMutex g_log_mutex;
LockableMutex g_csv_mutex; LockableMutex g_csv_mutex;
std::atomic_bool g_has_initialized = false; std::atomic_bool g_has_initialized = false;
@@ -82,12 +83,10 @@ namespace fileUtils {
FILE* file = fopen(FILE_LOG_FILE_PATH, "a"); FILE* file = fopen(FILE_LOG_FILE_PATH, "a");
if (file) { if (file) {
struct timespec now; timespec now = {};
struct tm *timeInfo;
clock_gettime(CLOCK_REALTIME, &now); clock_gettime(CLOCK_REALTIME, &now);
timeInfo = localtime(&now.tv_sec);
fprintf(file, "[%02d:%02d:%02d] ", timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec); fprintf(file, "[%luls] ", now.tv_sec - bootTimeS);
vfprintf(file, format, args); vfprintf(file, format, args);
fprintf(file, "\n"); fprintf(file, "\n");
fclose(file); fclose(file);
@@ -152,6 +151,12 @@ namespace fileUtils {
} }
} }
void SetBootTime() {
timespec bootTime = {};
clock_gettime(CLOCK_REALTIME, &bootTime);
bootTimeS = bootTime.tv_sec;
}
void InitializeAsync() { void InitializeAsync() {
Thread initThread = {0}; Thread initThread = {0};
threadCreate(&initThread, InitializeThreadFunc, NULL, NULL, 0x4000, 0x15, 0); threadCreate(&initThread, InitializeThreadFunc, NULL, NULL, 0x4000, 0x15, 0);
@@ -167,6 +172,7 @@ namespace fileUtils {
__libnx_init_time(); __libnx_init_time();
timeExit(); timeExit();
SetBootTime();
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
rc = fsInitialize(); rc = fsInitialize();