Skip to content

Commit

Permalink
Use wxUILocale for date formatting in wxDataViewDateRenderer
Browse files Browse the repository at this point in the history
Use the appropriate format for the dates by using the UI, rather than C,
locale, similarly to wxGrid.
  • Loading branch information
vadz committed Aug 14, 2021
1 parent 622463f commit 3116c2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/wx/dvrenderers.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ class WXDLLIMPEXP_CORE wxDataViewDateRenderer: public wxDataViewCustomRenderer
virtual wxSize GetSize() const wxOVERRIDE;

private:
wxString FormatDate() const;

wxDateTime m_date;
};
#else // !wxUSE_DATEPICKCTRL
Expand Down
13 changes: 10 additions & 3 deletions src/common/datavcmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3116c2a

Please sign in to comment.