shithub: rgbds

Download patch

ref: 93ee41756796733c5421f79ebe1d3264871194d7
parent: 44cdcd12c386916e4f4b3e9f24eb94189ba4f811
author: ISSOtm <eldredhabert0@gmail.com>
date: Wed Jan 29 20:47:50 EST 2020

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.

--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -737,7 +737,8 @@
 
 	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 @@
 		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);