[Mono-bugs] [Bug 397934] New: DataSet. ReadXML is unable to read time zone information in a xs:dateTime column

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jun 6 08:57:50 EDT 2008


           Summary: DataSet.ReadXML is unable to read time zone information
                    in a xs:dateTime column
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: x86
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: novell at vokabeln.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: Development

Description of Problem:

I created a System.Data.DataTable with a DateTime column and saved it into a
file using DataSet.WriteXML. Using the same code, the files created by .NET and
MONO 1.9.1 differ because, apparently, MONO saves DateTime values in a
different way: 


MONO saves the milliseconds more accurately but seems to be unaware of time
zones. What's worse, however, is that when I create a file with .NET and then
try to read it with MONO I get an "Invalid format" error message: MONO does not
seem to be able to deal with the time zone information "+02:00" saved by .NET. 

Steps to reproduce the problem:

1. Compile the following C# console application into test.exe:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DataSetDateTime
    class test
        static void Main(string[] args)
            if (args.Length < 2)
                Console.WriteLine("please use syntax 'test.exe write
filename.xls' or 'test.exe read filename.xls'");
                if (args[0] == "write")
                if (args[0] == "read")

        private static void CreateFile(string testFile)
            DateTime myDate = DateTime.Parse("06.06.2008
            DataTable testTable = new DataTable("TestTable");
            DataRow testRow = testTable.NewRow();
            testRow["TestColumn"] = myDate;
            DataSet testDataSet = new DataSet("TestDataSet");
            testDataSet.WriteXml(testFile, XmlWriteMode.WriteSchema);

        private static void ReadFile(string testFile)
                DataSet testDataSet = new DataSet();
                testDataSet.ReadXml(testFile, XmlReadMode.ReadSchema);
            catch (Exception ex)

2. Start "Mono Command Prompt" and create two files by prompting

test.exe write filecreatedbynet.xml
mono test.exe write filecreatedbymono.xml

3. Open the xml files (using Editor etc.) and compare the way the datetime
information is written by .NET and MONO

4. Now see what happens when you try to read the files using .NET and MONO:

mono test.exe read filecreatedbynet.xml
mono test.exe read filecreatedbymono.xml
test.exe read filecreatedbynet.xml
test.exe read filecreatedbymono.xml

Actual Results:

Step 3: The files created by .NET and MONO differ because .NET includes a time
zone information such as "+02:00" in the DateTime value whereas MONO does not. 

Step 4: The first command "mono test.exe read filecreatedbynet.xml" produces
the error message "Invalid format."; all the other commands are successful. 

Expected Results:

Step 3: The files created by .NET and MONO should be equal, i.e. MONO should
write time zone information as well. 

Step 4: MONO should be able to read time zone information, i.e. "mono test.exe
read filecreatedbynet.xml" should result in "Success" as well instead of
throwing an exception. 

How often does this happen? 


Additional Information:


Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list