]> git.saurik.com Git - wxWidgets.git/commitdiff
check that the conversion to wxDateTime was really successful
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 25 Mar 2009 09:20:20 +0000 (09:20 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 25 Mar 2009 09:20:20 +0000 (09:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59825 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/variant.cpp

index 627edfbef604c42ad8cfd7bbae749eebaf28189c..c5de3a4ada3d800f64e1d1893aa276eeac8da560 100644 (file)
@@ -1838,12 +1838,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