From 8fa853a3e26b5e6e837e73d94b95b931fda104a9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Aug 2021 19:08:21 +0100 Subject: [PATCH] Add wxGetUIDateFormat() helper function Retrieve thr date format to use, even when wxUSE_INTL==0. --- include/wx/uilocale.h | 14 +++++++++++++- interface/wx/uilocale.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/wx/uilocale.h b/include/wx/uilocale.h index 465baa3ffe..acae223190 100644 --- a/include/wx/uilocale.h +++ b/include/wx/uilocale.h @@ -67,6 +67,18 @@ private: wxDECLARE_NO_COPY_CLASS(wxUILocale); }; -#endif // wxUSE_INTL +inline wxString wxGetUIDateFormat() +{ + return wxUILocale::GetCurrent().GetInfo(wxLOCALE_SHORT_DATE_FMT); +} + +#else // !wxUSE_INTL + +inline wxString wxGetUIDateFormat() +{ + return wxString(wxS("%x")); +} + +#endif // wxUSE_INTL/!wxUSE_INTL #endif // _WX_UILOCALE_H_ diff --git a/interface/wx/uilocale.h b/interface/wx/uilocale.h index d31eaf1b89..de6bcc7550 100644 --- a/interface/wx/uilocale.h +++ b/interface/wx/uilocale.h @@ -104,3 +104,18 @@ public: wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat = wxLOCALE_CAT_DEFAULT) const; }; + +/** + Return the format to use for formatting user-visible dates. + + This is a simple wrapper function normally calling wxUILocale::GetInfo() + with wxLOCALE_SHORT_DATE_FMT argument, but which is also available when @c + wxUSE_INTL==0, i.e. support for internationalization is disabled at + compile-time, in which case it returns @c %x string, i.e. uses the current + C locale formatting rather than UI locale. + + @see wxDateTime::Format() + + @since 3.1.6 + */ +wxString wxGetUIDateFormat();