Use locale-specific date format
There is no need to construct format string manually.
This commit is contained in:
@@ -2316,8 +2316,6 @@ wxString wxDateProperty::ValueToString( wxVariant& value,
|
|||||||
format = m_format.c_str();
|
format = m_format.c_str();
|
||||||
|
|
||||||
// Determine default from locale
|
// Determine default from locale
|
||||||
// NB: This is really simple stuff, but can't figure anything
|
|
||||||
// better without proper support in wxLocale
|
|
||||||
if ( !format )
|
if ( !format )
|
||||||
format = ms_defaultDateFormat.c_str();
|
format = ms_defaultDateFormat.c_str();
|
||||||
|
|
||||||
@@ -2326,46 +2324,18 @@ wxString wxDateProperty::ValueToString( wxVariant& value,
|
|||||||
|
|
||||||
wxString wxDateProperty::DetermineDefaultDateFormat( bool showCentury )
|
wxString wxDateProperty::DetermineDefaultDateFormat( bool showCentury )
|
||||||
{
|
{
|
||||||
// This code is basically copied from datectlg.cpp's SetFormat
|
// This code is based on datectlg.cpp's GetLocaleDateFormat()
|
||||||
//
|
#if wxUSE_INTL
|
||||||
wxString format;
|
wxString format = wxLocale::GetOSInfo(wxLOCALE_SHORT_DATE_FMT);
|
||||||
|
if ( showCentury )
|
||||||
wxDateTime dt;
|
format.Replace(wxS("%y"), wxS("%Y"));
|
||||||
dt.ParseFormat(wxS("2003-10-13"), wxS("%Y-%m-%d"));
|
else
|
||||||
wxString str(dt.Format(wxS("%x")));
|
format.Replace(wxS("%Y"), wxS("%y"));
|
||||||
|
|
||||||
const wxChar *p = str.c_str();
|
|
||||||
while ( *p )
|
|
||||||
{
|
|
||||||
int n=wxAtoi(p);
|
|
||||||
if (n == dt.GetDay())
|
|
||||||
{
|
|
||||||
format.Append(wxS("%d"));
|
|
||||||
p += 2;
|
|
||||||
}
|
|
||||||
else if (n == (int)dt.GetMonth()+1)
|
|
||||||
{
|
|
||||||
format.Append(wxS("%m"));
|
|
||||||
p += 2;
|
|
||||||
}
|
|
||||||
else if (n == dt.GetYear())
|
|
||||||
{
|
|
||||||
format.Append(wxS("%Y"));
|
|
||||||
p += 4;
|
|
||||||
}
|
|
||||||
else if (n == (dt.GetYear() % 100))
|
|
||||||
{
|
|
||||||
if (showCentury)
|
|
||||||
format.Append(wxS("%Y"));
|
|
||||||
else
|
|
||||||
format.Append(wxS("%y"));
|
|
||||||
p += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
format.Append(*p++);
|
|
||||||
}
|
|
||||||
|
|
||||||
return format;
|
return format;
|
||||||
|
#else
|
||||||
|
return wxS("%x");
|
||||||
|
#endif // wxUSE_INTL/!wxUSE_INTL
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDateProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
bool wxDateProperty::DoSetAttribute( const wxString& name, wxVariant& value )
|
||||||
|
Reference in New Issue
Block a user