diff options
Diffstat (limited to 'src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs')
-rw-r--r-- | src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs b/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs index 5fbf2e0f09..7e63708382 100644 --- a/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs +++ b/src/mscorlib/corefx/System/Globalization/HebrewCalendar.cs @@ -2,8 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Text; +using System.Diagnostics; using System.Diagnostics.Contracts; namespace System.Globalization @@ -65,7 +64,7 @@ namespace System.Globalization [Serializable] [System.Runtime.InteropServices.ComVisible(true)] - public partial class HebrewCalendar : Calendar + public class HebrewCalendar : Calendar { public static readonly int HebrewEra = 1; @@ -317,6 +316,14 @@ namespace System.Globalization } } + public override CalendarAlgorithmType AlgorithmType + { + get + { + return CalendarAlgorithmType.LunisolarCalendar; + } + } + public HebrewCalendar() { } @@ -371,7 +378,7 @@ namespace System.Globalization if (month < 1 || month > monthsInYear) { throw new ArgumentOutOfRangeException( - "month", + nameof(month), String.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, @@ -397,7 +404,7 @@ namespace System.Globalization if (day < 1 || day > daysInMonth) { throw new ArgumentOutOfRangeException( - "day", + nameof(day), String.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, @@ -410,7 +417,7 @@ namespace System.Globalization { if (era != CurrentEra && era != HebrewEra) { - throw new ArgumentOutOfRangeException("era", SR.ArgumentOutOfRange_InvalidEraValue); + throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue); } } @@ -470,7 +477,7 @@ namespace System.Globalization int index = gregorianYear - FirstGregorianTableYear; if (index < 0 || index > TABLESIZE) { - throw new ArgumentOutOfRangeException("gregorianYear"); + throw new ArgumentOutOfRangeException(nameof(gregorianYear)); } index *= 2; @@ -595,7 +602,7 @@ namespace System.Globalization // is true. // NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month] - lunarDate.day); - Contract.Assert(NumDays >= 1, "NumDays >= 1"); + Debug.Assert(NumDays >= 1, "NumDays >= 1"); // If NumDays is 1, then we are done. Otherwise, find the correct Hebrew month // and day. @@ -705,7 +712,7 @@ namespace System.Globalization catch (ArgumentException) { throw new ArgumentOutOfRangeException( - "months", + nameof(months), String.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_AddValue)); @@ -728,7 +735,7 @@ namespace System.Globalization int d = GetDatePart(time.Ticks, DatePartDay); y += years; - CheckHebrewYearValue(y, Calendar.CurrentEra, "years"); + CheckHebrewYearValue(y, Calendar.CurrentEra, nameof(years)); int months = GetMonthsInYear(y, CurrentEra); if (m > months) @@ -771,7 +778,7 @@ namespace System.Globalization internal static int GetHebrewYearType(int year, int era) { - CheckHebrewYearValue(year, era, "year"); + CheckHebrewYearValue(year, era, nameof(year)); // The HebrewTable is indexed by Gregorian year and starts from FirstGregorianYear. // So we need to convert year (Hebrew year value) to Gregorian Year below. return (s_hebrewTable[(year - HebrewYearOf1AD - FirstGregorianTableYear) * 2 + 1]); @@ -819,12 +826,12 @@ namespace System.Globalization int hebrewYearType = GetHebrewYearType(year, era); CheckHebrewMonthValue(year, month, era); - Contract.Assert(hebrewYearType >= 1 && hebrewYearType <= 6, + Debug.Assert(hebrewYearType >= 1 && hebrewYearType <= 6, "hebrewYearType should be from 1 to 6, but now hebrewYearType = " + hebrewYearType + " for hebrew year " + year); int monthDays = s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + month]; if (monthDays == 0) { - throw new ArgumentOutOfRangeException("month", SR.ArgumentOutOfRange_Month); + throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month); } return (monthDays); } @@ -956,7 +963,7 @@ namespace System.Globalization public override bool IsLeapYear(int year, int era) { - CheckHebrewYearValue(year, era, "year"); + CheckHebrewYearValue(year, era, nameof(year)); return (((7 * (long)year + 1) % 19) < 7); } @@ -1047,7 +1054,7 @@ namespace System.Globalization public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era) { - CheckHebrewYearValue(year, era, "year"); + CheckHebrewYearValue(year, era, nameof(year)); CheckHebrewMonthValue(year, month, era); CheckHebrewDayValue(year, month, day, era); DateTime dt = HebrewToGregorian(year, month, day, hour, minute, second, millisecond); @@ -1078,7 +1085,7 @@ namespace System.Globalization } else { - CheckHebrewYearValue(value, HebrewEra, "value"); + CheckHebrewYearValue(value, HebrewEra, nameof(value)); } twoDigitYearMax = value; } @@ -1089,7 +1096,7 @@ namespace System.Globalization { if (year < 0) { - throw new ArgumentOutOfRangeException("year", + throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); @@ -1102,7 +1109,7 @@ namespace System.Globalization if (year > MaxHebrewYear || year < MinHebrewYear) { throw new ArgumentOutOfRangeException( - "year", + nameof(year), String.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, |