Fix timestamp symbols on Windows (partially)

Windows does not honor `%F` nor `%T` in `strftime`. These are worked around
by writing the full format they serve as a short for.
However, Windows also treats `%z` and `%Z` identically, where SUS instead
requires `%z` to output a ±XXXX offset.
Since the current information is broken (no information), this isn't *breaking*
anything, but at least provides something a human will probably understand.
`__ISO_8601_UTC__` is unaffected because it hardcodes the timezone character,
only `__ISO_8601_LOCAL__` suffers from this.
This commit is contained in:
ISSOtm
2020-01-30 01:47:50 +01:00
parent 44cdcd12c3
commit 93ee417567

View File

@@ -737,7 +737,8 @@ void sym_Init(void)
sym_AddSet("_RS", 0);
if (time(&now) != -1) {
now = time(NULL);
if (now != (time_t)-1) {
const struct tm *time_local = localtime(&now);
strftime(SavedTIME, sizeof(SavedTIME), "\"%H:%M:%S\"",
@@ -745,13 +746,13 @@ void sym_Init(void)
strftime(SavedDATE, sizeof(SavedDATE), "\"%d %B %Y\"",
time_local);
strftime(SavedTIMESTAMP_ISO8601_LOCAL,
sizeof(SavedTIMESTAMP_ISO8601_LOCAL), "\"%FT%T%z\"",
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), "\"%FT%TZ\"",
sizeof(SavedTIMESTAMP_ISO8601_UTC), "\"%Y-%m-%dT%H-%M-%SZ\"",
time_utc);
strftime(SavedDAY, sizeof(SavedDAY), "%d", time_utc);