Merge pull request #726 from pruiz/xamarin-bug-13708
[mono.git] / mcs / class / corlib / System.Globalization / HebrewCalendar.cs
index f4ab83b2bde1eda25dda0eb34013a0214f2437fa..54f85203ab592156af00626cca2906c136e666c8 100644 (file)
@@ -1,4 +1,4 @@
-// HebrewCalendar.cs
+// System.Globalization.HebrewCalendar.cs
 //
 // (C) Ulrich Kunitz 2002
 //
@@ -30,6 +30,7 @@ namespace System.Globalization {
 
 using System;
 using System.IO;
+using System.Runtime.InteropServices;
 
 /// <summary>
 /// This is the Hebrew calendar.
@@ -43,7 +44,7 @@ using System.IO;
 /// </para>
 /// </remarks>
 [Serializable]
-[MonoTODO ("Fix serialization compatibility with MS.NET")]
+[MonoLimitation ("Serialization format not compatible with.NET")]
 public class HebrewCalendar : Calendar {
        /// <summary>
        /// Constructor.
@@ -51,8 +52,8 @@ public class HebrewCalendar : Calendar {
        public HebrewCalendar() {
                M_AbbrEraNames = new string[] {"A.M."};
                M_EraNames = new string[] {"Anno Mundi"};
-               if (M_TwoDigitYearMax == 99)
-                       M_TwoDigitYearMax = 5790;
+               if (twoDigitYearMax == 99)
+                       twoDigitYearMax = 5790;
        }
 
        /// <summary>
@@ -93,8 +94,6 @@ public class HebrewCalendar : Calendar {
                }
        }
 
-       int twoDigitYearMax = 5790;
-       
        public override int TwoDigitYearMax 
        {
                get {
@@ -501,6 +500,11 @@ public class HebrewCalendar : Calendar {
                return HebrewEra;
        }
 
+       public override int GetLeapMonth (int year, int era)
+       {
+               return IsLeapMonth (year, 7, era) ? 7 : 0;
+       }
+
        /// <summary>
        /// Overridden. Gives the number of the month of the specified
        /// date.
@@ -670,35 +674,38 @@ public class HebrewCalendar : Calendar {
        /// is out of range.
        /// </exception>
        public override DateTime ToDateTime(int year, int month, int day,
-               int hour, int minute, int second, int milliseconds,
+               int hour, int minute, int second, int millisecond,
                int era)
        {
                M_CheckYMDE(year, month, day, ref era);
-               M_CheckHMSM(hour, minute, second, milliseconds);
+               M_CheckHMSM(hour, minute, second, millisecond);
                int ccm = M_CCMonth(month, year);
                int rd = CCHebrewCalendar.fixed_from_dmy(day, ccm, year);
                return CCFixed.ToDateTime(rd,
-                       hour, minute, second, milliseconds);
+                       hour, minute, second, millisecond);
        }
 
        public override int ToFourDigitYear (int year)
        {
-               M_ArgumentInRange ("year", year, 0, 99);
+               M_ArgumentInRange ("year", year, 0, M_MaxYear - 1);
                
                int baseExtra = this.twoDigitYearMax % 100;
                int baseCentury = this.twoDigitYearMax - baseExtra;
                
+               if (year >= 100)
+                       return year;
                if (year <= baseExtra)
                        return baseCentury + year;
                else
                        return baseCentury + year - 100;
        }
-#if NET_2_0
+#if !NET_2_1
        public override CalendarAlgorithmType AlgorithmType {
                get {
                        return CalendarAlgorithmType.LunisolarCalendar;
                }
        }
+#endif
 
        static DateTime Min = new DateTime (1583, 1, 1, 0, 0, 0);
        static DateTime Max = new DateTime (2239, 9, 29, 11, 59, 59);
@@ -714,8 +721,6 @@ public class HebrewCalendar : Calendar {
                        return Max;
                }
        }
-#endif
-
 } // class HebrewCalendar
        
 } // namespace System.Globalization