2007-11-01 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Thu, 1 Nov 2007 10:16:02 +0000 (10:16 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Thu, 1 Nov 2007 10:16:02 +0000 (10:16 -0000)
* DateTime.cs : in roundtrip mode, 'Z' should turn the tick value to
  utc time and should not result in different ticks.
  Fixed bug #338064.

* DateTimeTest.cs : fixed bug #338064.

svn path=/trunk/mcs/; revision=88631

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/DateTime.cs
mcs/class/corlib/Test/System/ChangeLog
mcs/class/corlib/Test/System/DateTimeTest.cs

index bf0eaa7760f41f01995d971eb3f129795db9642e..dcbee61d890a15ed797c3b7833db8eb27b2ec696 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DateTime.cs : in roundtrip mode, 'Z' should turn the tick value to
+         utc time and should not result in different ticks.
+         Fixed bug #338064.
+
 2007-10-30  Miguel de Icaza  <miguel@novell.com>
 
        * UInt32.cs (Parse): Use Jeff Stedfast's parsing code which is
index 0f96e57ea605634561557aae7381bc947b72016d..2c721e67fb8b298d87ddc64f8263ceea94bac982 100644 (file)
@@ -1547,6 +1547,7 @@ namespace System
                                case 'K':
                                        if (s [valuePos] == 'Z') {
                                                valuePos++;
+                                               useutc = true;
                                                explicit_kind = DateTimeKind.Utc;
                                        }
                                        else if (s [valuePos] == '+' || s [valuePos] == '-') {
index e9fe14d47f9093fc0adabe87026b19099286cb53..50a51cd5646e767d1dd85ab5802c87ec84397e9c 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DateTimeTest.cs : fixed bug #338064.
+
 2007-10-27  Zoltan Varga  <vargaz@gmail.com>
 
        * TypeTest.cs (InvokeMember_VarArgs): Enable this test.
index dfd6620cfd5d4c579749754aeab282772ad25cfc..69fff5f91e939fb173bbe38300698dfa49401bd4 100644 (file)
@@ -2114,6 +2114,20 @@ namespace MonoTests.System
                        Assert.AreEqual ("2000-01-01T00:00:00.0000000+09:00".Length, DateTime.SpecifyKind (
                                new DateTime (2000, 1, 1), DateTimeKind.Local).ToString ("o").Length, "#3");
                }
+
+               [Test]
+               [Category ("NotDotNet")]
+               public void RundtripKindPattern ()
+               {
+                       // only 2.0 supports 'K'
+                       string format = "yyyy-MM-ddTHH:mm:ss.FFFK";
+                       CultureInfo ci = CultureInfo.CurrentCulture;
+                       DateTime dt = DateTime.UtcNow;
+                       string s = dt.ToString (format);//"2007-11-01T10:03:48.39Z";
+                       DateTime d1 = DateTime.ParseExact (s, format, ci);
+                       Assert.AreEqual (dt.Ticks, d1.Ticks, "#1");
+                       Assert.AreEqual (DateTimeKind.Utc, d1.Kind, "#2");
+               }
 #endif
        }
 }