[Mono-bugs] [Bug 56436][Nor] New - DateFormat.ParseExact() doesn't work as expected

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 3 Apr 2004 15:43:13 -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 mail@martin-probst.com.

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

--- shadow/56436	2004-04-03 15:43:13.000000000 -0500
+++ shadow/56436.tmp.18664	2004-04-03 15:43:13.000000000 -0500
@@ -0,0 +1,50 @@
+Bug#: 56436
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: gentoo
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mail@martin-probst.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Summary: DateFormat.ParseExact() doesn't work as expected
+
+Description of Problem:
+I'm trying to parse a string into a DateTime. For example an Apache 
+access_log with timestamps like:
+"28/Mar/2004:19:12:37 +0200"
+with this pattern "dd\"/\"MMM\"/\"yyyy:HH:mm:ss zz\"00\"". This works 
+perfectly under .NET in Windows but fails under mono.
+The source looks like this:
+c = new CultureInfo("en-US");
+string s = "28/Mar/2004:19:12:37 +0200";
+expectedFormats = {"dd\"/\"MMM\"/\"yyyy:HH:mm:ss zz\"00\""};
+DateTime mydate = DateTime.ParseExact(date, expectedFormats, c, 
+DateTimeStyles.AllowWhiteSpaces);
+
+It fails with 
+Could not parse: 28/Mar/2004:19:12:37 +0200
+in <0x0013d> System.DateTime:ParseExact (string,string[],System.
+IFormatProvider,System.Globalization.DateTimeStyles)
+in <0x00098> UnixTime.DateFormat:ToDateTime (string)
+in <0x000bc> UnixTime.LogEventParser:Generator_NewLines (object,string)
+
+Steps to reproduce the problem:
+1. compile the above sourcecode
+2. run it
+3. watch it fail
+
+Actual Results:
+The above exception.
+
+Expected Results:
+A parsed DateTime object.
+
+How often does this happen? 
+Always