if ( date.IsValid() )
{
m_combo->SetText(date.Format(m_format));
+ SetDate(date);
}
else // invalid date
{
m_combo->SetText(wxEmptyString);
}
-
- SetDate(date);
}
bool ParseDateTime(const wxString& s, wxDateTime* pDt)
m_combo->SetText(GetStringValueFor(dt));
+ if ( !dt.IsValid() && HasDPFlag(wxDP_ALLOWNONE) )
+ return;
+
// notify that we had to change the date after validation
if ( (dt.IsValid() && (!dtOld.IsValid() || dt != dtOld)) ||
(!dt.IsValid() && dtOld.IsValid()) )
virtual void SetStringValue(const wxString& s)
{
wxDateTime dt;
- if ( ParseDateTime(s, &dt) )
+ if ( !s.empty() && ParseDateTime(s, &dt) )
SetDate(dt);
- else if ( HasDPFlag(wxDP_ALLOWNONE) )
- SetDate(wxInvalidDateTime);
- //else: !wxDP_ALLOWNONE, keep the old value
+ //else: keep the old value
}
virtual wxString GetStringValue() const