mirror of
https://github.com/cathery/sys-con.git
synced 2024-12-24 15:13:45 +00:00
Fix time showing up incorrectly in logs
This commit is contained in:
parent
1985319a6a
commit
1ceffd7e10
@ -21,12 +21,13 @@ void WriteToLog(const char *fmt, ...)
|
||||
#else
|
||||
|
||||
time_t unixTime = time(NULL);
|
||||
struct tm *tStruct = localtime((const time_t *)&unixTime);
|
||||
struct tm tStruct;
|
||||
localtime_r(&unixTime, &tStruct);
|
||||
|
||||
FILE *fp = fopen(CONFIG_PATH "log.txt", "a");
|
||||
|
||||
//Print time
|
||||
fprintf(fp, "%04i-%02i-%02i %02i:%02i:%02i: ", (tStruct->tm_year + 1900), tStruct->tm_mon, tStruct->tm_mday, tStruct->tm_hour, tStruct->tm_min, tStruct->tm_sec);
|
||||
fprintf(fp, "%04i-%02i-%02i %02i:%02i:%02i: ", (tStruct.tm_year + 1900), tStruct.tm_mon, tStruct.tm_mday, tStruct.tm_hour, tStruct.tm_min, tStruct.tm_sec);
|
||||
|
||||
//Print the actual text
|
||||
va_list va;
|
||||
|
Loading…
Reference in New Issue
Block a user