mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
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:
@@ -737,7 +737,8 @@ void sym_Init(void)
|
|||||||
|
|
||||||
sym_AddSet("_RS", 0);
|
sym_AddSet("_RS", 0);
|
||||||
|
|
||||||
if (time(&now) != -1) {
|
now = time(NULL);
|
||||||
|
if (now != (time_t)-1) {
|
||||||
const struct tm *time_local = localtime(&now);
|
const struct tm *time_local = localtime(&now);
|
||||||
|
|
||||||
strftime(SavedTIME, sizeof(SavedTIME), "\"%H:%M:%S\"",
|
strftime(SavedTIME, sizeof(SavedTIME), "\"%H:%M:%S\"",
|
||||||
@@ -745,13 +746,13 @@ void sym_Init(void)
|
|||||||
strftime(SavedDATE, sizeof(SavedDATE), "\"%d %B %Y\"",
|
strftime(SavedDATE, sizeof(SavedDATE), "\"%d %B %Y\"",
|
||||||
time_local);
|
time_local);
|
||||||
strftime(SavedTIMESTAMP_ISO8601_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);
|
time_local);
|
||||||
|
|
||||||
const struct tm *time_utc = gmtime(&now);
|
const struct tm *time_utc = gmtime(&now);
|
||||||
|
|
||||||
strftime(SavedTIMESTAMP_ISO8601_UTC,
|
strftime(SavedTIMESTAMP_ISO8601_UTC,
|
||||||
sizeof(SavedTIMESTAMP_ISO8601_UTC), "\"%FT%TZ\"",
|
sizeof(SavedTIMESTAMP_ISO8601_UTC), "\"%Y-%m-%dT%H-%M-%SZ\"",
|
||||||
time_utc);
|
time_utc);
|
||||||
|
|
||||||
strftime(SavedDAY, sizeof(SavedDAY), "%d", time_utc);
|
strftime(SavedDAY, sizeof(SavedDAY), "%d", time_utc);
|
||||||
|
|||||||
Reference in New Issue
Block a user