[Mono-bugs] [Bug 38661][Nor] New - Wrong format in DataSet DateTime field to XML conversion

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 25 Feb 2003 04:45:30 -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 tam@siulung.com.

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

--- shadow/38661	Tue Feb 25 04:45:30 2003
+++ shadow/38661.tmp.10641	Tue Feb 25 04:45:30 2003
@@ -0,0 +1,68 @@
+Bug#: 38661
+Product: Mono/Class Libraries
+Version: unspecified
+OS: 
+OS Details: Debian Woody
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: Tam@SiuLung.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Wrong format in DataSet DateTime field to XML conversion
+
+Description of Problem:
+When one use DataSet.WriteXml() to "serialize" it to an XML file, the date 
+related fields have wrong output format.
+
+Steps to reproduce the problem:
+1. create a table with a date/time/datetime field and insert some data.
+2. run something like:
+using System;
+using System.Data;
+using ByteFX.Data.MySQLClient;
+
+public class TestB {
+  public static void Main() {
+    string connectionString = "";
+    MySQLConnection myConnection = new MySQLConnection(connectionString);
+    myConnection.Open();
+    DataSet ds = new DataSet("abc");
+    MySQLDataAdapter adpOE = new MySQLDataAdapter();
+    adpOE.SelectCommand = new MySQLCommand("SELECT * FROM PE", 
+myConnection);
+    adpOE.Fill(ds);
+    ds.WriteXml("abc.xml");
+  }
+}
+
+Actual Results:
+<abc>
+  <d>
+    <DTFrom>09/26/2002 14:30:00</DTFrom>
+    <DTTo>09/26/2002 15:30:00</DTTo>
+  </d>
+</abc>
+
+Expected Results:
+<?xml version="1.0" standalone="yes"?>
+<abc>
+  <d>
+    <DTFrom>2002-09-26T14:30:00+08:00</DTFrom>
+    <DTTo>2002-09-26T15:30:00+08:00</DTTo>
+  </d>
+</abc>
+
+How often does this happen? 
+Always.
+
+Additional Information:
+According to W3C XML Schema (http://www.w3.org/TR/xmlschema-2/#dateTime),
+the 4 types of date related fields, i.e. dateTime, date, time and duration 
+all have their strict formatting. Even if System.DateTime.ToString() uses 
+Locale format, we have to follow the format when writing an XML.