]> git.saurik.com Git - wxWidgets.git/commitdiff
adding check for invalid date
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 12 Jun 2013 18:52:55 +0000 (18:52 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 12 Jun 2013 18:52:55 +0000 (18:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74184 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/datetimectrl_osx.cpp

index 45a49659ffc42dd71fb16685b0c01ff71c499a2a..952ac3e05dd7ca3633130ea56cb12b85783e1d4b 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     Implementation of wxDateTimePickerCtrl for OS X.
 // Author:      Vadim Zeitlin
 // Created:     2011-12-18
-// RCS-ID:      $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
+// RCS-ID:      $Id$
 // Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -28,6 +28,7 @@
 #ifndef WX_PRECOMP
 #endif // WX_PRECOMP
 
+#include "wx/datectrl.h"
 #include "wx/datetimectrl.h"
 
 #include "wx/osx/core/private/datetimectrl.h"
@@ -43,7 +44,19 @@ wxDateTimeWidgetImpl* wxDateTimePickerCtrl::GetDateTimePeer() const
 
 void wxDateTimePickerCtrl::SetValue(const wxDateTime& dt)
 {
-    GetDateTimePeer()->SetDateTime(dt);
+    if ( dt.IsValid() )
+    {
+        GetDateTimePeer()->SetDateTime(dt);
+    }
+    else // invalid date
+    {
+        wxASSERT_MSG( HasFlag(wxDP_ALLOWNONE),
+                     wxT("this control must have a valid date") );
+
+        // TODO setting to an invalid date is not natively supported
+        // so we must implement a UI for that ourselves
+        GetDateTimePeer()->SetDateTime(dt);
+    }
 }
 
 wxDateTime wxDateTimePickerCtrl::GetValue() const