]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/variant.cpp
supporting kill focus for single line text controls
[wxWidgets.git] / src / common / variant.cpp
index 627edfbef604c42ad8cfd7bbae749eebaf28189c..b7c479588dc4dcfef200ac10230782f14f014ce1 100644 (file)
@@ -1271,9 +1271,8 @@ bool wxVariantDataDateTime::Read(wxString& str)
         return true;
     }
 
-    if(! m_value.ParseDateTime(str.c_str()/*FIXME-UTF8*/))
-        return false;
-    return true;
+    wxString::const_iterator end;
+    return m_value.ParseDateTime(str, &end) && end == str.end();
 }
 
 // wxVariant
@@ -1838,12 +1837,25 @@ bool wxVariant::Convert(wxDateTime* value) const
         *value = ((wxVariantDataDateTime*)GetData())->GetValue();
         return true;
     }
+
     // Fallback to string conversion
     wxString val;
-    return Convert(&val) &&
-                (value->ParseDateTime(val.c_str()/*FIXME-UTF8*/) ||
-                 value->ParseDate(val.c_str()/*FIXME-UTF8*/) ||
-                 value->ParseTime(val.c_str()/*FIXME-UTF8*/));
+    if ( !Convert(&val) )
+        return false;
+
+    // Try to parse this as either date and time, only date or only time
+    // checking that the entire string was parsed
+    wxString::const_iterator end;
+    if ( value->ParseDateTime(val, &end) && end == val.end() )
+        return true;
+
+    if ( value->ParseDate(val, &end) && end == val.end() )
+        return true;
+
+    if ( value->ParseTime(val, &end) && end == val.end() )
+        return true;
+
+    return false;
 }
 #endif // wxUSE_DATETIME