diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index c451b17347..8c6178d01d 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -154,6 +154,7 @@ public: if ( date.IsValid() ) { m_combo->SetText(date.Format(m_format)); + SetDate(date); } else // invalid date { @@ -162,8 +163,6 @@ public: m_combo->SetText(wxEmptyString); } - - SetDate(date); } bool ParseDateTime(const wxString& s, wxDateTime* pDt) @@ -230,6 +229,9 @@ private: 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()) ) @@ -314,11 +316,9 @@ private: 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