[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


https://bugzilla.novell.com/show_bug.cgi?id=397934


           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: 

NET: 
<TestColumn>2008-06-06T07:07:00.009+02:00</TestColumn> 
MONO: 
<TestColumn>2008-06-06T07:07:00.0088888</TestColumn> 

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'");
            }
            else
            {
                if (args[0] == "write")
                    CreateFile(args[1]);
                if (args[0] == "read")
                    ReadFile(args[1]);
            }
        }

        private static void CreateFile(string testFile)
        {
            DateTime myDate = DateTime.Parse("06.06.2008
07:07").AddMilliseconds(8.8888);
            DataTable testTable = new DataTable("TestTable");
            testTable.Columns.Add("TestColumn",
Type.GetType("System.DateTime"));
            DataRow testRow = testTable.NewRow();
            testRow["TestColumn"] = myDate;
            testTable.Rows.Add(testRow);
            DataSet testDataSet = new DataSet("TestDataSet");
            testDataSet.Tables.Add(testTable);
            testDataSet.WriteXml(testFile, XmlWriteMode.WriteSchema);
            Console.WriteLine("Success");
        }

        private static void ReadFile(string testFile)
        {
             try 
             {
                DataSet testDataSet = new DataSet();
                testDataSet.ReadXml(testFile, XmlReadMode.ReadSchema);
                Console.WriteLine("Success");
             }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
-----


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? 

Always. 


Additional Information:

None


-- 
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