Author: atsushi
Date: 2007-01-25 05:32:13 -0500 (Thu, 25 Jan 2007)
New Revision: 71660

Modified:
   trunk/mcs/class/corlib/System/ChangeLog
   trunk/mcs/class/corlib/System/DateTime.cs
   trunk/mcs/class/corlib/Test/System/ChangeLog
   trunk/mcs/class/corlib/Test/System/DateTimeTest.cs
Log:
2007-01-25  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * DateTime.cs : copy Kind in those members that return DateTime.
          Fixed bug #80614.

        * DateTimeTest.cs : test for copying Kind property.



Modified: trunk/mcs/class/corlib/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System/ChangeLog     2007-01-25 09:59:09 UTC (rev 
71659)
+++ trunk/mcs/class/corlib/System/ChangeLog     2007-01-25 10:32:13 UTC (rev 
71660)
@@ -1,3 +1,8 @@
+2007-01-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * DateTime.cs : copy Kind in those members that return DateTime.
+         Fixed bug #80614.
+
 2007-01-20  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * Array.cs (InternalArray__ICollection_Contains,

Modified: trunk/mcs/class/corlib/System/DateTime.cs
===================================================================
--- trunk/mcs/class/corlib/System/DateTime.cs   2007-01-25 09:59:09 UTC (rev 
71659)
+++ trunk/mcs/class/corlib/System/DateTime.cs   2007-01-25 10:32:13 UTC (rev 
71660)
@@ -336,7 +336,11 @@
                {
                        get     
                        { 
-                               return new DateTime (Year, Month, Day);
+                               DateTime ret = new DateTime (Year, Month, Day);
+#if NET_2_0
+                               ret.kind = kind;
+#endif
+                               return ret;
                        }
                }
         
@@ -499,7 +503,11 @@
 
                public DateTime Add (TimeSpan ts)
                {
-                       return AddTicks (ts.Ticks);
+                       DateTime ret = AddTicks (ts.Ticks);
+#if NET_2_0
+                       ret.kind = kind;
+#endif
+                       return ret;
                }
 
                public DateTime AddDays (double days)
@@ -512,7 +520,11 @@
                        if ((t + ticks.Ticks) > MAX_VALUE_TICKS || (t + 
ticks.Ticks) < 0) {
                                throw new ArgumentOutOfRangeException();
                        }
-                       return new DateTime (t + ticks.Ticks);
+                       DateTime ret = new DateTime (t + ticks.Ticks);
+#if NET_2_0
+                       ret.kind = kind;
+#endif
+                       return ret;
                }
 
                public DateTime AddHours (double hours)
@@ -572,6 +584,9 @@
                                day = maxday;
 
                        temp = new DateTime (year, month, day);
+#if NET_2_0
+                       temp.kind = kind;
+#endif
                        return  temp.Add (this.TimeOfDay);
                }
 
@@ -1559,7 +1574,11 @@
                        TimeSpan newticks;
 
                        newticks = (new TimeSpan (ticks.Ticks)) - ts;
-                       return new DateTime(true,newticks);
+                       DateTime ret = new DateTime(true,newticks);
+#if NET_2_0
+                       ret.kind = kind;
+#endif
+                       return ret;
                }
 
                public long ToFileTime()
@@ -1994,7 +2013,11 @@
 
                public static DateTime operator +(DateTime d, TimeSpan t)
                {
-                       return new DateTime (true, d.ticks + t);
+                       DateTime ret = new DateTime (true, d.ticks + t);
+#if NET_2_0
+                       ret.kind = d.kind;
+#endif
+                       return ret;
                }
 
                public static bool operator ==(DateTime d1, DateTime d2)
@@ -2034,7 +2057,11 @@
 
                public static DateTime operator -(DateTime d,TimeSpan t)
                {
-                       return new DateTime (true, d.ticks - t);
+                       DateTime ret = new DateTime (true, d.ticks - t);
+#if NET_2_0
+                       ret.kind = d.kind;
+#endif
+                       return ret;
                }
 
                bool IConvertible.ToBoolean(IFormatProvider provider)

Modified: trunk/mcs/class/corlib/Test/System/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System/ChangeLog        2007-01-25 09:59:09 UTC 
(rev 71659)
+++ trunk/mcs/class/corlib/Test/System/ChangeLog        2007-01-25 10:32:13 UTC 
(rev 71660)
@@ -1,3 +1,7 @@
+2007-01-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * DateTimeTest.cs : test for copying Kind property.
+
 2007-01-14  Jensen Somers <[EMAIL PROTECTED]>
 
     * ArraySegmentTest.cs: Add a test case for the ArraySegment.Equals

Modified: trunk/mcs/class/corlib/Test/System/DateTimeTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System/DateTimeTest.cs  2007-01-25 09:59:09 UTC 
(rev 71659)
+++ trunk/mcs/class/corlib/Test/System/DateTimeTest.cs  2007-01-25 10:32:13 UTC 
(rev 71660)
@@ -1555,6 +1555,24 @@
        }
 
        [Test]
+       public void InstanceMembersAndKind ()
+       {
+               AssertEquals ("#1", DateTimeKind.Utc, 
DateTime.UtcNow.Date.Kind);
+               AssertEquals ("#2", DateTimeKind.Utc, DateTime.UtcNow.Add 
(TimeSpan.FromMinutes (1)).Kind);
+               AssertEquals ("#3", DateTimeKind.Utc, DateTime.UtcNow.Subtract 
(TimeSpan.FromMinutes (1)).Kind);
+               AssertEquals ("#4-1", DateTimeKind.Utc, DateTime.UtcNow.AddDays 
(1).Kind);
+               AssertEquals ("#4-2", DateTimeKind.Utc, 
DateTime.UtcNow.AddTicks (1).Kind);
+               AssertEquals ("#4-3", DateTimeKind.Utc, 
DateTime.UtcNow.AddHours (1).Kind);
+               AssertEquals ("#4-4", DateTimeKind.Utc, 
DateTime.UtcNow.AddMinutes (1).Kind);
+               AssertEquals ("#4-5", DateTimeKind.Utc, 
DateTime.UtcNow.AddSeconds (1).Kind);
+               AssertEquals ("#4-6", DateTimeKind.Utc, 
DateTime.UtcNow.AddMilliseconds (1).Kind);
+               AssertEquals ("#4-7", DateTimeKind.Utc, 
DateTime.UtcNow.AddMonths (1).Kind);
+               AssertEquals ("#4-8", DateTimeKind.Utc, 
DateTime.UtcNow.AddYears (1).Kind);
+               AssertEquals ("#5-1", DateTimeKind.Utc, (DateTime.UtcNow + 
TimeSpan.FromMinutes (1)).Kind);
+               AssertEquals ("#5-2", DateTimeKind.Utc, (DateTime.UtcNow - 
TimeSpan.FromMinutes (1)).Kind);
+       }
+
+       [Test]
        public void FromBinary ()
        {
                DateTime dt_utc = DateTime.FromBinary (0x4000000000000001);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to