[Mono-bugs] [Bug 54047][Nor] New - DateTime.Parse does not support alternate date separator characters

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 8 Feb 2004 13:51:55 -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 gert.driesen@pandora.be.

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

--- shadow/54047	2004-02-08 13:51:55.000000000 -0500
+++ shadow/54047.tmp.14525	2004-02-08 13:51:55.000000000 -0500
@@ -0,0 +1,58 @@
+Bug#: 54047
+Product: Mono/Class Libraries
+Version: unspecified
+OS: All
+OS Details: Gentoo 1.4
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gert.driesen@pandora.be               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DateTime.Parse does not support alternate date separator characters
+
+DateTime.Parse is unable to parse a date string containing date separator 
+characters other than the date separator of the culture used to parse the 
+string.
+
+for example, the following code fragment works fine on MS.NET :
+
+DateTime.Parse("01-25-2004", CultureInfo.InvariantInfo);
+
+even though the date separator character for the invariant culture is '/'.
+
+Executing the same code on Mono/Linux causes a FormatException as Mono 
+only accepts the date separator of the passed IFormatProvider (in this 
+case the invariant culture).
+
+see line 899 of DateTime.cs :
+
+if (!_ParseString (s, 0, dfi.DateSeparator, out num_parsed))
+   return false;
+
+I guess Mono should not check if s[0] equals dfi.DateSeparator, but it 
+should check whether s[0] is not a letter, not a digit and not equal to 
+dfi.TimeSeparator. All other characters should be allowed as input date 
+separator.
+
+The attached class contains the following code :
+
+Console.WriteLine(DateTime.Parse("01-25-2004", 
+CultureInfo.InvariantCulture).ToString());
+Console.WriteLine(DateTime.Parse("01#25#2004", 
+CultureInfo.InvariantCulture).ToString());
+
+and outputs the following on MS.NET :
+
+25/01/2004 0:00:00
+25/01/2004 0:00:00
+
+but throws a FormatException on Mono/Linux
+
+Note : this issue does not reproduce on Mono/Windows at this time, because 
+of bug #54046.