From 786806e1165bd28e95ca5a947eb4e628f3032b65 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 14 Aug 2018 20:43:19 +0200 Subject: [PATCH 1/3] Use localtime instead of gmtime in file browser. --- src/openrct2/platform/Platform.Posix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 7260cb5109..48b6bc2ade 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -73,14 +73,14 @@ namespace Platform std::string FormatShortDate(std::time_t timestamp) { char date[20]; - std::strftime(date, sizeof(date), "%x", std::gmtime(×tamp)); + std::strftime(date, sizeof(date), "%x", std::localtime(×tamp)); return std::string(date); } std::string FormatTime(std::time_t timestamp) { char time[20]; - std::strftime(time, sizeof(time), "%X", std::gmtime(×tamp)); + std::strftime(time, sizeof(time), "%X", std::localtime(×tamp)); return std::string(time); } From 4a442d0d6ddafddb7ec3df0ab0a78dc39b07d52b Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Tue, 14 Aug 2018 21:08:24 +0200 Subject: [PATCH 2/3] Convert filetime to local time on Windows --- src/openrct2/platform/Windows.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 4c5e73e934..9ce03b12ee 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -331,9 +331,12 @@ time_t platform_file_get_modified_time(const utf8* path) if (result) { + FILETIME localFileTime; + FileTimeToLocalFileTime(&data.ftLastWriteTime, &localFileTime); + ULARGE_INTEGER ull; - ull.LowPart = data.ftLastWriteTime.dwLowDateTime; - ull.HighPart = data.ftLastWriteTime.dwHighDateTime; + ull.LowPart = localFileTime.dwLowDateTime; + ull.HighPart = localFileTime.dwHighDateTime; return ull.QuadPart / 10000000ULL - 11644473600ULL; } else From 7cc5bc87e9c48ee6f1f39778affb92cf4db42819 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 14 Aug 2018 23:29:36 +0200 Subject: [PATCH 3/3] Check result of FileTimeToLocalFileTime; add to changelog. --- distribution/changelog.txt | 1 + src/openrct2/platform/Windows.cpp | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 8f7e1debda..4efa977d70 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -36,6 +36,7 @@ - Fix: [#7804] Russian ride descriptions are cut off. - Fix: [#7872] CJK tooltips are often cut off. - Fix: [#7895] Import of Mega Park and the RCT1 title music do not work on some RCT1 sources. +- Improved: [#7899] Timestamps in the load/save screen are now displayed using local timezone instead of GMT. 0.2.0 (2018-06-10) ------------------------------------------------------------------------ diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 9ce03b12ee..000e3851e6 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -329,20 +329,18 @@ time_t platform_file_get_modified_time(const utf8* path) BOOL result = GetFileAttributesExW(wPath, GetFileExInfoStandard, &data); free(wPath); - if (result) - { - FILETIME localFileTime; - FileTimeToLocalFileTime(&data.ftLastWriteTime, &localFileTime); - - ULARGE_INTEGER ull; - ull.LowPart = localFileTime.dwLowDateTime; - ull.HighPart = localFileTime.dwHighDateTime; - return ull.QuadPart / 10000000ULL - 11644473600ULL; - } - else - { + if (!result) return 0; - } + + FILETIME localFileTime; + result = FileTimeToLocalFileTime(&data.ftLastWriteTime, &localFileTime); + if (!result) + return 0; + + ULARGE_INTEGER ull; + ull.LowPart = localFileTime.dwLowDateTime; + ull.HighPart = localFileTime.dwHighDateTime; + return ull.QuadPart / 10000000ULL - 11644473600ULL; } uint8_t platform_get_locale_currency()