Fixes for Windows

This commit is contained in:
MysterD 2022-02-20 23:38:42 -08:00
parent 0954efff58
commit 7013443003
2 changed files with 8 additions and 0 deletions

View File

@ -7,9 +7,13 @@
static void _debuglog_print_timestamp(void) { static void _debuglog_print_timestamp(void) {
time_t ltime = time(NULL); time_t ltime = time(NULL);
#if defined(_WIN32)
char* str = asctime(localtime(&ltime));
#else
struct tm ltime2 = { 0 }; struct tm ltime2 = { 0 };
localtime_r(&ltime, &ltime2); localtime_r(&ltime, &ltime2);
char* str = asctime(&ltime2); char* str = asctime(&ltime2);
#endif
printf("%.*s", (int)strlen(str) - 1, str); printf("%.*s", (int)strlen(str) - 1, str);
} }

View File

@ -26,9 +26,13 @@ void logfile_close(enum LogFileType logFileType);
static void _logfile_print_timestamp(enum LogFileType logFileType) { static void _logfile_print_timestamp(enum LogFileType logFileType) {
FILE* f = gLogFiles[logFileType].file; FILE* f = gLogFiles[logFileType].file;
time_t ltime = time(NULL); time_t ltime = time(NULL);
#if defined(_WIN32)
char* str = asctime(localtime(&ltime));
#else
struct tm ltime2 = { 0 }; struct tm ltime2 = { 0 };
localtime_r(&ltime, &ltime2); localtime_r(&ltime, &ltime2);
char* str = asctime(&ltime2); char* str = asctime(&ltime2);
#endif
fprintf(f, "%.*s", (int)strlen(str) - 1, str); fprintf(f, "%.*s", (int)strlen(str) - 1, str);
} }