From 56b174432d40bc580ffe159f9adc420dc4ffb387 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Sun, 12 Aug 2018 23:03:32 +0200 Subject: [PATCH] Implement platform_get_locale_date_format for Linux Note that this currently, this isn't implemented in the C++ standard library. This means that date_order() will always return no_order, causing this function to always return the default DATE_FORMAT_DAY_MONTH_YEAR, as is the case before this commit too. Once date_order() will be properly implemented in the standard library someday, it will however start returning the right order for the current locale, causing this function to start working as intended. --- distribution/changelog.txt | 1 + src/openrct2/platform/Posix.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index cf60ca9a51..b2bf6f74c4 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -9,6 +9,7 @@ - Feature: [#7868] Placing scenery while holding shift now scales appropriately with zoom levels. - Fix: [#3177] Wrong keys displayed in shortcut menu. - Fix: [#4039] No sprite font glyph for German opening quotation mark. +- Fix: [#5548] platform_get_locale_date_format is not implemented for Linux. - Fix: [#7204] Object source filters do not work for RCT1, AA and LL. - Fix: [#7440] Memory leak. All system memory used. - Fix: [#7462] Guest window goes beyond the map edge on a spiral slide. diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index 489b7ece7f..63ce9ab618 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -27,6 +27,7 @@ # include # include +# include # include # include # include @@ -421,7 +422,22 @@ uint8_t platform_get_locale_temperature_format() uint8_t platform_get_locale_date_format() { - return DATE_FORMAT_DAY_MONTH_YEAR; + const std::time_base::dateorder dateorder = std::use_facet>(std::locale()).date_order(); + + switch (dateorder) + { + case std::time_base::mdy: + return DATE_FORMAT_MONTH_DAY_YEAR; + + case std::time_base::ymd: + return DATE_FORMAT_YEAR_MONTH_DAY; + + case std::time_base::ydm: + return DATE_FORMAT_YEAR_DAY_MONTH; + + default: + return DATE_FORMAT_DAY_MONTH_YEAR; + } } datetime64 platform_get_datetime_now_utc()