Browse Source

2006-07-25 Atsushi Enomoto <[email protected]>

	* XmlConvert.cs : TimeSpan conversion for TimeSpan.MinValue was
	  failing.

	* XmlConvertTest.cs :
	  Added TimeSpan conversion test for min/max values.


svn path=/trunk/mcs/; revision=62944
Atsushi Eno 19 years ago
parent
commit
2e8e4e6a2f

+ 5 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2006-07-25  Atsushi Enomoto <[email protected]>
+
+	* XmlConvert.cs : TimeSpan conversion for TimeSpan.MinValue was
+	  failing.
+
 2006-07-19  Atsushi Enomoto <[email protected]>
 
 	* XmlReader.cs : In Create(), support validation flags for DTD.

+ 4 - 2
mcs/class/System.XML/System.Xml/XmlConvert.cs

@@ -637,8 +637,10 @@ namespace System.Xml {
 			if (error)
 				throw new ArgumentException ("Invalid format string for duration schema datatype.");
 			TimeSpan ts = new TimeSpan (days, hours, minutes, seconds);
-			ts = ts.Add (TimeSpan.FromTicks (ticks));
-			return minusValue ? -ts : ts;
+			if (minusValue)
+				return TimeSpan.FromTicks (- (ts.Ticks + ticks));
+			else
+				return TimeSpan.FromTicks (ts.Ticks + ticks);
 		}
 
 		[CLSCompliant (false)]

+ 5 - 0
mcs/class/System.XML/Test/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2006-07-25  Atsushi Enomoto <[email protected]>
+
+	* XmlConvertTest.cs :
+	  Added TimeSpan conversion test for min/max values.
+
 2006-06-26  Atsushi Enomoto <[email protected]>
 
 	* XmlReaderCommonTests.cs : added test for bug #78706.

+ 9 - 1
mcs/class/System.XML/Test/System.Xml/XmlConvertTests.cs

@@ -353,7 +353,7 @@ namespace MonoTests.System.Xml
 		}
 
 		[Test]
-		public void ToTimeSpan ()//not done
+		public void ToTimeSpan ()
 		{
 			AssertEquals ("#1", new TimeSpan (0, 0, 0, 0, 1),
 				XmlConvert.ToTimeSpan ("PT0.001S"));
@@ -371,6 +371,14 @@ namespace MonoTests.System.Xml
 			AssertEquals ("#6",
 				TimeSpan.FromTicks (TimeSpan.TicksPerSecond + 1),
 				XmlConvert.ToTimeSpan ("PT1.0000001S"));
+
+			AssertEquals ("#7",
+				TimeSpan.MinValue,
+				XmlConvert.ToTimeSpan ("-P10675199DT2H48M5.4775808S"));
+
+			AssertEquals ("#8",
+				TimeSpan.MaxValue,
+				XmlConvert.ToTimeSpan ("P10675199DT2H48M5.4775807S"));
 		}
 		
 		[Test]