[Mono-bugs] [Bug 57786][Maj] New - XmlConvert.ToString(TimeSpan) does not produce the same output as on the .Net Framework

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 28 Apr 2004 13:31:53 -0400 (EDT)


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 simon@sdean.org.

http://bugzilla.ximian.com/show_bug.cgi?id=57786

--- shadow/57786	2004-04-28 13:31:53.000000000 -0400
+++ shadow/57786.tmp.7546	2004-04-28 13:31:53.000000000 -0400
@@ -0,0 +1,101 @@
+Bug#: 57786
+Product: Mono: Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Fedora Core 1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: simon@sdean.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: XmlConvert.ToString(TimeSpan) does not produce the same output as on the .Net Framework
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+
+XmlConvert.ToString(TimeSpan) on mono produces incorrect results.  
+
+E.g. Roundtripping the TimeSpan 18h00 (18 hundred hours) through 
+XmlConvert.ToString(TimeSpan) and then XmlConvert.ToTimeSpan(String) does 
+not produce the original TimeSpan of 18h00.  Instead it produces the 
+TimeSpan "0" (zero hours).  
+
+XmlConvert.ToString(new TimeSpan(18, 0, 0)) on .Net returns the 
+string "PT18H".  On mono it returns "P".  
+
+Steps to reproduce the problem:
+1. Console.WriteLine(XmlConvert.ToTimeSpan(XmlConvert.ToString(new TimeSpan
+(18, 0, 0))).Equals(new TimeSpan(18, 0, 0)));
+
+Actual Results:
+False
+
+Expected Results:
+True
+
+How often does this happen? 
+Always 
+
+Additional Information:
+
+Here's a test class that illustrates the bug.  The test passes on .Net (on 
+Windows XP) and fails on mono (on Fedora Core 1 - I haven't tested it 
+using mono on either Windows or another Linux distro).  
+
+using System;
+using System.Xml;
+
+namespace XmlConvertTest
+{
+	class XmlConvertTest
+	{
+		private static bool Test()
+		{
+			TimeSpan timeSpan = new TimeSpan(18, 0, 0);
+			Console.WriteLine("Input TimeSpan: {0}", timeSpan);
+
+			string timeSpanString = XmlConvert.ToString
+(timeSpan);
+			Console.WriteLine("XmlConvert Produces:  {0}", 
+timeSpanString);
+
+			TimeSpan timeSpan2 = XmlConvert.ToTimeSpan
+(timeSpanString);
+			Console.WriteLine("Output TimeSpan = {0}", 
+timeSpan2);
+
+			bool passed = timeSpan.Equals(timeSpan2);
+
+			return passed;
+		}
+
+		/// <summary>
+		/// The main entry point for the application.
+		/// </summary>
+		[STAThread]
+		static void Main(string[] args)
+		{
+			bool passed = Test();
+
+			if (passed)
+			{
+				Console.WriteLine("The test passed!");
+			}
+			else
+			{
+				Console.WriteLine("The test failed!");
+			}
+
+			Console.WriteLine();
+			Console.WriteLine("Press ENTER to continue.");
+			Console.ReadLine();
+		}
+	}
+}