From 93ee41756796733c5421f79ebe1d3264871194d7 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Thu, 30 Jan 2020 01:47:50 +0100 Subject: [PATCH] Fix timestamp symbols on Windows (partially) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/asm/symbol.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/asm/symbol.c b/src/asm/symbol.c index 5b8d5160..38b60bfe 100644 --- a/src/asm/symbol.c +++ b/src/asm/symbol.c @@ -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);