Finish using time_utc before initializing time_local

gmtime and localtime may share the same static internal struct tm,
so they cannot both be initialized and then used.
This commit is contained in:
Rangi
2022-01-27 22:32:34 -05:00
parent 20a26599a3
commit 4ed5ba7508

View File

@@ -760,7 +760,6 @@ void sym_Init(time_t now)
now = 0;
}
const struct tm *time_utc = gmtime(&now);
const struct tm *time_local = localtime(&now);
strftime(savedTIME, sizeof(savedTIME), "\"%H:%M:%S\"", time_local);
@@ -769,6 +768,8 @@ void sym_Init(time_t now)
sizeof(savedTIMESTAMP_ISO8601_LOCAL), "\"%Y-%m-%dT%H:%M:%S%z\"",
time_local);
const struct tm *time_utc = gmtime(&now);
strftime(savedTIMESTAMP_ISO8601_UTC,
sizeof(savedTIMESTAMP_ISO8601_UTC), "\"%Y-%m-%dT%H:%M:%SZ\"",
time_utc);