[Mono-bugs] [Bug 53919][Wis] New - Convert.ChangeType fails to convert TimeSpan objects

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 5 Feb 2004 08:46:21 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by ianm@activestate.com.


--- shadow/53919	2004-02-05 08:46:21.000000000 -0500
+++ shadow/53919.tmp.23941	2004-02-05 08:46:21.000000000 -0500
@@ -0,0 +1,51 @@
+Bug#: 53919
+Product: Mono/Class Libraries
+Version: unspecified
+OS Details: gentoo
+Status: NEW   
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ianm@activestate.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Convert.ChangeType fails to convert TimeSpan objects
+Description of Problem:
+the Convert.ChangeType method throws an exception when trying to convert to
+ TimeSpan object even if the source object is also a TimeSpan
+Steps to reproduce the problem:
+run this code:
+using System;
+using System.Globalization;
+static void TestTimeSpan(){
+ System.TimeSpan tspan = Convert.ToDateTime("2000-12-01") -
+    Convert.ChangeType(tspan, typeof(System.TimeSpan),
+Actual Results:
+Unhandled Exception: System.InvalidCastException: Value is not a
+convertible object: System.TimeSpan to System.TimeSpan
+in <0x008aa> System.Convert:ToType (object,System.Type,System.IFormatProvider)
+in <0x00013> System.Convert:ChangeType
+Expected Results:
+a successful conversion to a new TimeSpan object
+How often does this happen? 
+Additional Information:
+the above code works fine on windows. This only seems to be an issue with
+TimeSpan - although I didn't test other object types exhaustively.