Author: atsushi
Date: 2007-06-01 12:40:20 -0400 (Fri, 01 Jun 2007)
New Revision: 78429

Modified:
   trunk/mcs/class/corlib/System.Globalization/Calendar.cs
   trunk/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs
   trunk/mcs/class/corlib/System.Globalization/ChangeLog
   trunk/mcs/class/corlib/System.Globalization/DateTimeFormatInfo.cs
   trunk/mcs/class/corlib/Test/ChangeLog
   trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs
   trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog
Log:
2007-06-01  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * Calendar.cs DateTimeFormatInfo.cs : 2.0 API fixes.
        * CalendricalCalculations.cs : fixed AddMonth() and AddYears() to
          consider that the max days in the target month (for AddYears()
          leap year month could matter). Fixed bug #81783.

        * CalendarTest.cs : test for bug #81783 and AddYears() for leap year
          (similar issue).



Modified: trunk/mcs/class/corlib/System.Globalization/Calendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/Calendar.cs     2007-06-01 
16:35:39 UTC (rev 78428)
+++ trunk/mcs/class/corlib/System.Globalization/Calendar.cs     2007-06-01 
16:40:20 UTC (rev 78429)
@@ -30,11 +30,15 @@
 
 using System;
 using System.IO;
+using System.Runtime.InteropServices;
 
 /// <remarks>
 /// The class serves as a base class for calendar classes.
 /// </remarks>
 [Serializable]
+#if NET_2_0
+[ComVisible (true)]
+#endif
 public abstract class Calendar
 #if NET_2_0
        : ICloneable
@@ -152,19 +156,36 @@
        }
 
        // LAMESPEC: huh, why not Calendar but Object?
+       [ComVisible (false)]
        public virtual object Clone ()
        {
                Calendar c = (Calendar) MemberwiseClone ();
                c.m_isReadOnly = false;
                return c;
        }
+
+       [MonoTODO]
+       [ComVisible (false)]
+       public virtual int GetLeapMonth (int year)
+       {
+               throw new NotImplementedException ();
+       }
+
+       [MonoTODO]
+       [ComVisible (false)]
+       public virtual int GetLeapMonth (int year, int era)
+       {
+               throw new NotImplementedException ();
+       }
 #endif
 
 #if NET_2_0
+       [ComVisible (false)]
        public bool IsReadOnly {
                get { return m_isReadOnly; }
        }
 
+       [ComVisible (false)]
        public static Calendar ReadOnly (Calendar source)
        {
                if (source.m_isReadOnly)

Modified: trunk/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs      
2007-06-01 16:35:39 UTC (rev 78428)
+++ trunk/mcs/class/corlib/System.Globalization/CalendricalCalculations.cs      
2007-06-01 16:40:20 UTC (rev 78429)
@@ -672,6 +672,9 @@
                int day, month, year;
                dmy_from_fixed(out day, out month, out year, rd);
                month += months;
+               int maxday = GetDaysInMonth (year, month);
+               if (day > maxday)
+                       day = maxday;
                rd = fixed_from_dmy(day, month, year);
                System.DateTime t = CCFixed.ToDateTime(rd);
                return t.Add(time.TimeOfDay);
@@ -695,6 +698,9 @@
                int day, month, year;
                dmy_from_fixed(out day, out month, out year, rd);
                year += years;
+               int maxday = GetDaysInMonth (year, month);
+               if (day > maxday)
+                       day = maxday;
                rd = fixed_from_dmy(day, month, year);
                System.DateTime t = CCFixed.ToDateTime(rd);
                return t.Add(time.TimeOfDay);

Modified: trunk/mcs/class/corlib/System.Globalization/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/ChangeLog       2007-06-01 
16:35:39 UTC (rev 78428)
+++ trunk/mcs/class/corlib/System.Globalization/ChangeLog       2007-06-01 
16:40:20 UTC (rev 78429)
@@ -1,3 +1,10 @@
+2007-06-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * Calendar.cs DateTimeFormatInfo.cs : 2.0 API fixes.
+       * CalendricalCalculations.cs : fixed AddMonth() and AddYears() to
+         consider that the max days in the target month (for AddYears()
+         leap year month could matter). Fixed bug #81783.
+
 2007-05-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * IdnMapping.cs : new 2.0 class.

Modified: trunk/mcs/class/corlib/System.Globalization/DateTimeFormatInfo.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/DateTimeFormatInfo.cs   
2007-06-01 16:35:39 UTC (rev 78428)
+++ trunk/mcs/class/corlib/System.Globalization/DateTimeFormatInfo.cs   
2007-06-01 16:40:20 UTC (rev 78429)
@@ -32,6 +32,7 @@
 
 using System;
 using System.Collections;
+using System.Runtime.InteropServices;
 using System.Threading;
 
 namespace System.Globalization
@@ -48,6 +49,9 @@
 #endif
 
        [Serializable]
+#if NET_2_0
+       [ComVisible (true)]
+#endif
        public sealed class DateTimeFormatInfo : ICloneable, IFormatProvider {
                private static readonly string MSG_READONLY = "This instance is 
read only";
                private static readonly string MSG_ARRAYSIZE_MONTH = "An array 
with exactly 13 elements is needed";
@@ -765,22 +769,26 @@
 
 #if NET_2_0
                [MonoTODO ("NotImplemented")]
+               [ComVisible (false)]
                public string [] AbbreviatedMonthGenitiveNames {
                        get { throw new NotImplementedException (); }
                        set { throw new NotImplementedException (); }
                }
 
                [MonoTODO ("NotImplemented")]
+               [ComVisible (false)]
                public string [] MonthGenitiveNames {
                        get { throw new NotImplementedException (); }
                        set { throw new NotImplementedException (); }
                }
 
                [MonoTODO ("NotImplemented")]
-               public string [] NativeCalendarName {
+               [ComVisible (false)]
+               public string NativeCalendarName {
                        get { throw new NotImplementedException (); }
                }
 
+               [ComVisible (false)]
                public string [] ShortestDayNames {
                        get {
                                return shortDayNames;
@@ -801,6 +809,7 @@
                        }
                }
 
+               [ComVisible (false)]
                public string GetShortestDayName (DayOfWeek dayOfWeek)
                {
                        int index = (int) dayOfWeek;
@@ -811,6 +820,7 @@
                }
 
                [MonoTODO ("NotImplemented")]
+               [ComVisible (false)]
                public void SetAllDateTimePatterns (string [] patterns, char 
format)
                {
                        throw new NotImplementedException ();

Modified: trunk/mcs/class/corlib/Test/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/ChangeLog       2007-06-01 16:35:39 UTC (rev 
78428)
+++ trunk/mcs/class/corlib/Test/ChangeLog       2007-06-01 16:40:20 UTC (rev 
78429)
@@ -1,5 +1,9 @@
-2007-03-14    Eyal Alaluf <[EMAIL PROTECTED]>
+2007-05-31  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * Makefile : missing EXTRA_DISTFILES.
+
+2007-03-14     Eyal Alaluf <[EMAIL PROTECTED]>
+
        * Mark tests as not working under TargetJvm
 
 2007-03-05     Eyal Alaluf <[EMAIL PROTECTED]>
@@ -78,7 +82,7 @@
 
        * corlib_test.args: Added EventBuilderTest.cs.  
 
-2003-06-01  Pedro Martínez Juliá  <[EMAIL PROTECTED]>
+2003-06-01  Pedro Martinez Julia  <[EMAIL PROTECTED]>
 
        * corlib_test.args: Added SingleFormatterTest.cs
 

Modified: trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs    
2007-06-01 16:35:39 UTC (rev 78428)
+++ trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs    
2007-06-01 16:40:20 UTC (rev 78429)
@@ -540,6 +540,28 @@
                AssertEquals (29, days);
        }
 
+       [Test] // bug #81783
+       public void GregorianAddMonth ()
+       {
+               GregorianCalendar c = new GregorianCalendar ();
+               DateTime d = new DateTime (2007, 5, 31);
+               DateTime prev = c.AddMonths (d, -1);
+               AssertEquals ("prev", 4, prev.Month);
+               DateTime next = c.AddMonths (d, 1);
+               AssertEquals ("next", 6, next.Month);
+       }
+
+       [Test]
+       public void AddYearOnLeapYear ()
+       {
+               GregorianCalendar c = new GregorianCalendar ();
+               DateTime d = new DateTime (2004, 2, 29);
+               DateTime prev = c.AddYears (d, -1);
+               AssertEquals ("prev", 2, prev.Month);
+               DateTime next = c.AddYears (d, 1);
+               AssertEquals ("next", 2, next.Month);
+       }
+
        /* UK TODO: breaks with current DateTime implementation.
         * I've a newer one that works, but that requires to much changes.
         * for now.

Modified: trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog  2007-06-01 
16:35:39 UTC (rev 78428)
+++ trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog  2007-06-01 
16:40:20 UTC (rev 78429)
@@ -1,3 +1,8 @@
+2007-06-01  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * CalendarTest.cs : test for bug #81783 and AddYears() for leap year
+         (similar issue).
+
 2007-05-25  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * IdnMappingTest.cs : new test.

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

Reply via email to