From c746953f9b8b255a7eda48b112ae906f9f95cc44 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Aug 2021 19:08:43 +0100 Subject: [PATCH] Use wxUILocale for date formatting in wxDataViewDateRenderer Use the appropriate format for the dates by using the UI, rather than C, locale, similarly to wxGrid. --- include/wx/dvrenderers.h | 2 ++ src/common/datavcmn.cpp | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/wx/dvrenderers.h b/include/wx/dvrenderers.h index 85fcea0023..3b6857e971 100644 --- a/include/wx/dvrenderers.h +++ b/include/wx/dvrenderers.h @@ -527,6 +527,8 @@ public: virtual wxSize GetSize() const wxOVERRIDE; private: + wxString FormatDate() const; + wxDateTime m_date; }; #else // !wxUSE_DATEPICKCTRL diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 2c6fbe11d1..3824218eae 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -28,6 +28,8 @@ #include "wx/choice.h" #include "wx/imaglist.h" #include "wx/renderer.h" +#include "wx/uilocale.h" + #if wxUSE_ACCESSIBILITY #include "wx/access.h" #endif // wxUSE_ACCESSIBILITY @@ -1986,23 +1988,28 @@ bool wxDataViewDateRenderer::GetValue(wxVariant& value) const return true; } +wxString wxDataViewDateRenderer::FormatDate() const +{ + return m_date.Format(wxGetUIDateFormat()); +} + #if wxUSE_ACCESSIBILITY wxString wxDataViewDateRenderer::GetAccessibleDescription() const { - return m_date.FormatDate(); + return FormatDate(); } #endif // wxUSE_ACCESSIBILITY bool wxDataViewDateRenderer::Render(wxRect cell, wxDC* dc, int state) { - wxString tmp = m_date.FormatDate(); + wxString tmp = FormatDate(); RenderText( tmp, 0, cell, dc, state ); return true; } wxSize wxDataViewDateRenderer::GetSize() const { - return GetTextExtent(m_date.FormatDate()); + return GetTextExtent(FormatDate()); } #endif // (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL