2008-06-11 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 11 Jun 2008 12:20:57 +0000 (12:20 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 11 Jun 2008 12:20:57 +0000 (12:20 -0000)
* DateTimeConverter.cs : use MM for month instead of mm.
  Fixed bug #396649, patch by Andy Hume.

* DateTimeConverterTest.cs : test for bug #396649 by Andy Hume.

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

mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/DateTimeConverter.cs
mcs/class/System/Test/System.ComponentModel/ChangeLog
mcs/class/System/Test/System.ComponentModel/DateTimeConverterTests.cs

index d4940ed7c280136dda77f64f33c3732899ca1192..5a482e9be930795345fa2aa0ffb3c6b6a07bb79e 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DateTimeConverter.cs : use MM for month instead of mm.
+         Fixed bug #396649, patch by Andy Hume.
+
 2008-06-02  Dick Porter  <dick@ximian.com>
 
        * Win32Exception.cs: Turn W32ErrorMessage into an icall so it can
index 09c40c9fc1e07ae49844e5f2c72b03685fac81de..a0690282c0e763ee579e67884ead55104a0030c9 100644 (file)
@@ -92,7 +92,7 @@ namespace System.ComponentModel
 
                                        if (culture == CultureInfo.InvariantCulture) {
                                                if (datetime.Equals (datetime.Date)) {
-                                                       return datetime.ToString ("yyyy-mm-dd", culture);
+                                                       return datetime.ToString ("yyyy-MM-dd", culture);
                                                }
                                                return datetime.ToString (culture);
                                        } else {
index 552ac324ca5b22397c0fc97eff2d929704ab6513..16c6554afd322d78141e4c1310aa6aea0624ca28 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DateTimeConverterTest.cs : test for bug #396649 by Andy Hume.
+
 2008-05-30  Ivan N. Zlatev  <contact@i-nz.net>
 
        * TypeDescriptorTests.cs: Fix the attributes test on the 1.1 profile.
index 44dcbfbc95390594b9fba4ec4d48493326217f4b..8c62fe3b8d6d10169336a8165478f50bb0d2dd48 100644 (file)
@@ -155,6 +155,31 @@ namespace MonoTests.System.ComponentModel
                        Assert.AreEqual (date.ToString (info.ShortDatePattern + " " + 
                                info.ShortTimePattern, culture), converter.ConvertToString (
                                null, culture, date));
+
+                       CultureInfo ciUS = new CultureInfo("en-US");
+                       CultureInfo ciGB = new CultureInfo("en-GB");
+                       CultureInfo ciDE = new CultureInfo("de-DE");
+                       //
+                       date = new DateTime(2008, 12, 31, 23, 59, 58, 5);
+                       DoTestToString("12/31/2008 11:59 PM", date, ciUS);
+                       DoTestToString("31/12/2008 23:59", date, ciGB);
+                       DoTestToString("31.12.2008 23:59", date, ciDE);
+                       DoTestToString("12/31/2008 23:59:58", date, CultureInfo.InvariantCulture);
+                       Assert.AreEqual("12/31/2008 23:59:58", converter.ConvertToInvariantString(date), "Invariant");
+                       //
+                       date = new DateTime(2008, 12, 31);
+                       DoTestToString("12/31/2008", date, ciUS);
+                       DoTestToString("31/12/2008", date, ciGB);
+                       DoTestToString("31.12.2008", date, ciDE);
+                       DoTestToString("2008-12-31", date, CultureInfo.InvariantCulture);
+                       Assert.AreEqual("2008-12-31", converter.ConvertToInvariantString(date), "Invariant");
+               }
+               private void DoTestToString(String expected, DateTime value, CultureInfo ci)
+               {
+                       String message = ci.Name;
+                       if (message == null || message.Length == 0)
+                               message = "?Invariant";
+                       Assert.AreEqual(expected, converter.ConvertTo(null, ci, value, typeof(String)), message);
                }
 
                [Test]