[Mono-bugs] [Bug 57061][Maj] New - DateTime.Parse doesn't work anymore

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 15 Apr 2004 10:37:46 -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 rafaelteixeirabr@hotmail.com.

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

--- shadow/57061	2004-04-15 10:37:46.000000000 -0400
+++ shadow/57061.tmp.25914	2004-04-15 10:37:46.000000000 -0400
@@ -0,0 +1,104 @@
+Bug#: 57061
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: RedHat 9
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: rafaelteixeirabr@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: DateTime.Parse doesn't work anymore
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+When parsing a valid date string with en-US culture it gives Format
+Exception, previously it worked.
+
+Steps to reproduce the problem:
+1. compile this code:
+
+//
+// TestDateTimeParsing.cs
+//
+using System;
+using System.Globalization;
+
+public class TestDateTimeParsing
+{
+
+  public static void Main(string[] args)
+  {
+    Console.WriteLine("Data parseada: " +
+ParseDateLiteral("10/23/2003").ToString());
+  }
+
+  static IFormatProvider enUSculture = new CultureInfo("en-US", true);
+
+  private static DateTime ParseDateLiteral(string value)
+  {
+    try {
+      return DateTime.Parse(
+        value,
+        enUSculture,
+        DateTimeStyles.NoCurrentDateDefault |
+        DateTimeStyles.AllowWhiteSpaces);
+    } catch (FormatException ex) {
+      Console.WriteLine(string.Format("Invalid date literal '{0}'", value) 
+        + Environment.NewLine + ex.ToString());
+    } catch (Exception ex) {
+      Console.WriteLine(string.Format("Error parsing date literal '{0}'",
+value) 
+        + Environment.NewLine + ex.ToString());
+    }
+    return new DateTime();
+  }
+}
+
+$ mcs TestDateTimeParsing.cs
+Compilation succeeded
+
+2. run the resulting program 
+
+$ mono --debug TestDateTimeParsing.exe
+
+Actual Results:
+
+Invalid date literal '10/23/2003'
+System.FormatException: Invalid format.
+in [0x00068] (at
+/home/rafael/projetos/mcs/class/corlib/System/DateTime.cs:1082)
+System.DateTime:ParseExact
+(string,string[],System.IFormatProvider,System.Globalization.DateTimeStyles)
+in [0x00008] (at
+/home/rafael/projetos/mcs/class/corlib/System/DateTime.cs:535)
+System.DateTime:Parse
+(string,System.IFormatProvider,System.Globalization.DateTimeStyles)
+in <0x00038> TestDateTimeParsing:ParseDateLiteral (string)
+ 
+Data parseada: 1/1/01 12:00:00 A -2
+
+
+Expected Results:
+
+Data parseada: 10/23/2003 12:00:00
+
+How often does this happen? 
+
+Always. Before it worked, but recent (a month or little more) changes broke it
+
+Additional Information:
+
+ICU 2.6 included in build (as before)
+
+I'll try to dig it a bit more as it is stopping mbas development with a
+regression on parsing DateTime literals
+
+May be related with bugs #47753, #56436, #47720 all still open