* 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).
svn path=/trunk/mcs/; revision=78429
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
}
// 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)
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);
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);
+2007-06-01 Atsushi Enomoto <atsushi@ximian.com>
+
+ * 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 <atsushi@ximian.com>
* IdnMapping.cs : new 2.0 class.
using System;
using System.Collections;
+using System.Runtime.InteropServices;
using System.Threading;
namespace System.Globalization
#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";
#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;
}
}
+ [ComVisible (false)]
public string GetShortestDayName (DayOfWeek dayOfWeek)
{
int index = (int) dayOfWeek;
}
[MonoTODO ("NotImplemented")]
+ [ComVisible (false)]
public void SetAllDateTimePatterns (string [] patterns, char format)
{
throw new NotImplementedException ();
-2007-03-14 Eyal Alaluf <eyala@mainsoft.com>
+2007-05-31 Atsushi Enomoto <atsushi@ximian.com>
+
+ * Makefile : missing EXTRA_DISTFILES.
+
+2007-03-14 Eyal Alaluf <eyala@mainsoft.com>
* Mark tests as not working under TargetJvm
* corlib_test.args: Added EventBuilderTest.cs.
-2003-06-01 Pedro Martínez Juliá <yoros@wanadoo.es>
+2003-06-01 Pedro Martinez Julia <yoros@wanadoo.es>
* corlib_test.args: Added SingleFormatterTest.cs
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.
+2007-06-01 Atsushi Enomoto <atsushi@ximian.com>
+
+ * CalendarTest.cs : test for bug #81783 and AddYears() for leap year
+ (similar issue).
+
2007-05-25 Atsushi Enomoto <atsushi@ximian.com>
* IdnMappingTest.cs : new test.