[Mono-bugs] [Bug 338064] New: DateTime.Parse should treat Z like AssumeUniversal

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Oct 31 05:37:01 EDT 2007


https://bugzilla.novell.com/show_bug.cgi?id=338064#c1

           Summary: DateTime.Parse should treat Z like AssumeUniversal
           Product: Mono: Class Libraries
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at ximian.com
          Found By: ---


Apparently, MS treats the Z character in a datetime string as indicator that
the date is in UTC and converts it to a local time.

We currently appear to treat it as a local time, and convert it to UTC.

To reproduce, compile and run the following code snippet:

using System;
using System.Globalization;

class Program
{
  static void Main ()
  {
    string format = "yyyy-MM-ddTHH:mm:ss.FFFK";
    CultureInfo ci = CultureInfo.CurrentCulture;

    DateTime date = DateTime.UtcNow;

    string s = date.ToString (format, ci);
    Console.WriteLine ("#1:" + date.Kind + " => " + s);

    DateTime d1 = DateTime.ParseExact (s, format, ci);
    Console.WriteLine ("#2:" + d1.Kind + " => " + d1.ToString (format, ci));

    DateTime d2 = DateTime.Parse (s, ci);
    Console.WriteLine ("#3:" + d2.Kind + " => " + d2.ToString (format, ci));
  }
}

Actual result:

(this depends on your local timezone of course)

#1:Utc => 2007-10-31T09:34:02.578Z
#2:Utc => 2007-10-31T08:34:02.578Z
#3:Local => 2007-10-31T10:34:02.578+01:00

Expected result:

#1:Utc => 2007-10-31T09:30:45.437Z
#2:Local => 2007-10-31T10:30:45.437+01:00
#3:Local => 2007-10-31T10:30:45.437+01:00


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


More information about the mono-bugs mailing list