[Mono-bugs] [Bug 51464][Wis] New - System.DateTime.Parse() does not parse a String according to culture info
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 28 Nov 2003 03:31:47 -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 rkumar@novell.com.
http://bugzilla.ximian.com/show_bug.cgi?id=51464
--- shadow/51464 2003-11-28 03:31:47.000000000 -0500
+++ shadow/51464.tmp.4993 2003-11-28 03:31:47.000000000 -0500
@@ -0,0 +1,96 @@
+Bug#: 51464
+Product: Mono/Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: rkumar@novell.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: System.DateTime.Parse() does not parse a String according to culture info
+
+Description of Problem:
+System.DateTime.Parse() method does not parse the date string according to
+the culture info.
+Steps to reproduce the problem:
+1. Compile and run the following code,
+
+using System;
+
+class Test
+
+{
+
+ public static void Main ()
+
+ {
+ // Nov 28, 2003 11:28:15
+ String defDateTime = "11/28/2003 11:28:15";
+
+ System.DateTime dt1 = System.DateTime.Parse(defDateTime);
+
+ Console.WriteLine ("default: {0}", dt1);
+
+
+
+ // use french format
+ string frDateTime = "11/28/2003 11:28:15";
+
+ System.IFormatProvider format = new
+System.Globalization.CultureInfo("fr-FR", true);
+ System.DateTime dt2 = System.DateTime.Parse(frDateTime, format);
+
+ Console.WriteLine ("french: {0}", dt2);
+ }
+
+}
+
+Actual Results:
+default: Friday, 28 November 2003 11:28:15
+french: Friday, 28 November 2003 11:28:15
+
+Expected Results:
+Format for the second date is not correct as month can't have a value of
+28. System.FormatException must be thrown as done by .NET.
+
+How often does this happen?
+Always.
+
+Additional Information:
+
+Problem seems to be with the DateTime.Parse(String,IFormatProvider) method.
+It does not pass on the second argument to
+DateTime.Parse(string,IFormatProvider,DateTimeStyles). Following patch
+fixes the problem,
+
+Index: class/corlib/System/DateTime.cs
+===================================================================
+RCS file: /mono/mcs/class/corlib/System/DateTime.cs,v
+retrieving revision 1.48
+diff -u -u -r1.48 DateTime.cs
+--- class/corlib/System/DateTime.cs 14 Nov 2003 04:54:46 -0000 1.48
++++ class/corlib/System/DateTime.cs 28 Nov 2003 09:30:23 -0000
+@@ -526,7 +526,7 @@
+
+
+ public static DateTime Parse (string s, IFormatProvider fp)
+
+ {
+
+- return Parse (s, null, DateTimeStyles.AllowWhiteSpaces);
+
++ return Parse (s, fp, DateTimeStyles.AllowWhiteSpaces);
+
+ }
+
+
+
+ public static DateTime Parse (string s, IFormatProvider fp,
+DateTimeStyles styles)