Add an additional check for locales that do not use leading zeros for dates.

This commit is contained in:
Aaron van Geffen 2020-03-17 18:02:35 +01:00
parent 484956e006
commit 56216fd026

View file

@ -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());
}