1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-12-25 00:13:52 +00:00

Fix time showing up incorrectly in logs

This commit is contained in:
cathery 2019-12-11 05:59:04 +03:00
parent 1985319a6a
commit 1ceffd7e10

View File

@ -21,12 +21,13 @@ void WriteToLog(const char *fmt, ...)
#else #else
time_t unixTime = time(NULL); 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"); FILE *fp = fopen(CONFIG_PATH "log.txt", "a");
//Print time //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 //Print the actual text
va_list va; va_list va;