From 56216fd026ea72685d1d87acf6de5d05c2228cfc Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 17 Mar 2020 18:02:35 +0100 Subject: [PATCH] Add an additional check for locales that do not use leading zeros for dates. --- src/openrct2-ui/windows/LoadSave.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 40cdf3dd8b..769fe4e960 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -651,9 +651,20 @@ static void window_loadsave_compute_max_date_width() std::time_t long_time = mktime(&tm); + // Check how how this date is represented (e.g. 2000-02-20, or 00/02/20) std::string date = Platform::FormatShortDate(long_time); maxDateWidth = gfx_get_string_width(date.c_str()); + // Some locales do not use leading zeros for months and days, so let's try October, too. + tm.tm_mon = 10; + tm.tm_yday = 294; + long_time = mktime(&tm); + + // Again, check how how this date is represented (e.g. 2000-10-20, or 00/10/20) + date = Platform::FormatShortDate(long_time); + maxDateWidth = std::max(maxDateWidth, gfx_get_string_width(date.c_str())); + + // Time appears to be universally represented with two digits for minutes, so 12:00 or 00:00 should be representable. std::string time = Platform::FormatTime(long_time); maxTimeWidth = gfx_get_string_width(time.c_str()); }