summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHugh Bellamy <hughbellars@gmail.com>2019-02-19 21:33:26 +0000
committerJan Kotas <jkotas@microsoft.com>2019-02-19 13:33:26 -0800
commit7a6b440b5503e38e1847af68b3fc59692d9d2770 (patch)
tree1157e09a51ea624aa19ea46ba7f8d6a90494c0cb /src
parent50c44bec9c38f4d347c945d2034eb6a933680e36 (diff)
downloadcoreclr-7a6b440b5503e38e1847af68b3fc59692d9d2770.tar.gz
coreclr-7a6b440b5503e38e1847af68b3fc59692d9d2770.tar.bz2
coreclr-7a6b440b5503e38e1847af68b3fc59692d9d2770.zip
Cleanup Calendars code (#22582)
Diffstat (limited to 'src')
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs683
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs140
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs556
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs585
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs745
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs521
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs289
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs158
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs270
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs184
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs1092
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs411
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs206
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs149
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs166
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs454
17 files changed, 2458 insertions, 4153 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs
index f839581bde..b863cf5a7b 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs
@@ -60,102 +60,44 @@ namespace System.Globalization
private bool _isReadOnly = false;
- // The minimum supported DateTime range for the calendar.
+ public virtual DateTime MinSupportedDateTime => DateTime.MinValue;
- public virtual DateTime MinSupportedDateTime
- {
- get
- {
- return (DateTime.MinValue);
- }
- }
+ public virtual DateTime MaxSupportedDateTime => DateTime.MaxValue;
- // The maximum supported DateTime range for the calendar.
-
- public virtual DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
-
- public virtual CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.Unknown;
- }
- }
+ public virtual CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.Unknown;
protected Calendar()
{
- //Do-nothing constructor.
}
- ///
- // This can not be abstract, otherwise no one can create a subclass of Calendar.
- //
- internal virtual CalendarId ID
- {
- get
- {
- return CalendarId.UNINITIALIZED_VALUE;
- }
- }
+ internal virtual CalendarId ID => CalendarId.UNINITIALIZED_VALUE;
- ///
// Return the Base calendar ID for calendars that didn't have defined data in calendarData
- //
-
- internal virtual CalendarId BaseCalendarID
- {
- get { return ID; }
- }
+ internal virtual CalendarId BaseCalendarID => ID;
- ////////////////////////////////////////////////////////////////////////
- //
- // IsReadOnly
- //
- // Detect if the object is readonly.
- //
- ////////////////////////////////////////////////////////////////////////
- public bool IsReadOnly
- {
- get { return (_isReadOnly); }
- }
+ public bool IsReadOnly => _isReadOnly;
- ////////////////////////////////////////////////////////////////////////
- //
- // Clone
- //
- // Is the implementation of ICloneable.
- //
- ////////////////////////////////////////////////////////////////////////
public virtual object Clone()
{
object o = MemberwiseClone();
((Calendar)o).SetReadOnlyState(false);
- return (o);
+ return o;
}
- ////////////////////////////////////////////////////////////////////////
- //
- // ReadOnly
- //
- // Create a cloned readonly instance or return the input one if it is
- // readonly.
- //
- ////////////////////////////////////////////////////////////////////////
public static Calendar ReadOnly(Calendar calendar)
{
- if (calendar == null) { throw new ArgumentNullException(nameof(calendar)); }
- if (calendar.IsReadOnly) { return (calendar); }
+ if (calendar == null)
+ {
+ throw new ArgumentNullException(nameof(calendar));
+ }
+ if (calendar.IsReadOnly)
+ {
+ return calendar;
+ }
Calendar clonedCalendar = (Calendar)(calendar.MemberwiseClone());
clonedCalendar.SetReadOnlyState(true);
-
- return (clonedCalendar);
+ return clonedCalendar;
}
internal void VerifyWritable()
@@ -171,16 +113,9 @@ namespace System.Globalization
_isReadOnly = readOnly;
}
-
- /*=================================CurrentEraValue==========================
- **Action: This is used to convert CurrentEra(0) to an appropriate era value.
- **Returns:
- **Arguments:
- **Exceptions:
- **Notes:
- ** The value is from calendar.nlp.
- ============================================================================*/
-
+ /// <summary>
+ /// This is used to convert CurrentEra(0) to an appropriate era value.
+ /// </summary>
internal virtual int CurrentEraValue
{
get
@@ -191,23 +126,20 @@ namespace System.Globalization
Debug.Assert(BaseCalendarID != CalendarId.UNINITIALIZED_VALUE, "[Calendar.CurrentEraValue] Expected a real calendar ID");
_currentEraValue = CalendarData.GetCalendarData(BaseCalendarID).iCurrentEra;
}
- return (_currentEraValue);
+
+ return _currentEraValue;
}
}
- // The current era for a calendar.
-
public const int CurrentEra = 0;
- internal int twoDigitYearMax = -1;
+ internal int _twoDigitYearMax = -1;
internal static void CheckAddResult(long ticks, DateTime minValue, DateTime maxValue)
{
if (ticks < minValue.Ticks || ticks > maxValue.Ticks)
{
- throw new ArgumentException(
- string.Format(CultureInfo.InvariantCulture, SR.Format(SR.Argument_ResultCalendarRange,
- minValue, maxValue)));
+ throw new ArgumentException(SR.Format(SR.Argument_ResultCalendarRange, minValue, maxValue));
}
}
@@ -223,93 +155,90 @@ namespace System.Globalization
double tempMillis = (value * scale + (value >= 0 ? 0.5 : -0.5));
if (!((tempMillis > -(double)MaxMillis) && (tempMillis < (double)MaxMillis)))
{
- throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_AddValue);
+ throw new ArgumentOutOfRangeException(nameof(value), value, SR.ArgumentOutOfRange_AddValue);
}
long millis = (long)tempMillis;
long ticks = time.Ticks + millis * TicksPerMillisecond;
CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (new DateTime(ticks));
+ return new DateTime(ticks);
}
- // Returns the DateTime resulting from adding the given number of
- // milliseconds to the specified DateTime. The result is computed by rounding
- // the number of milliseconds given by value to the nearest integer,
- // and adding that interval to the specified DateTime. The value
- // argument is permitted to be negative.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding the given number of
+ /// milliseconds to the specified DateTime. The result is computed by rounding
+ /// the number of milliseconds given by value to the nearest integer,
+ /// and adding that interval to the specified DateTime. The value
+ /// argument is permitted to be negative.
+ /// </summary>
public virtual DateTime AddMilliseconds(DateTime time, double milliseconds)
{
- return (Add(time, milliseconds, 1));
+ return Add(time, milliseconds, 1);
}
-
- // Returns the DateTime resulting from adding a fractional number of
- // days to the specified DateTime. The result is computed by rounding the
- // fractional number of days given by value to the nearest
- // millisecond, and adding that interval to the specified DateTime. The
- // value argument is permitted to be negative.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding a fractional number of
+ /// days to the specified DateTime. The result is computed by rounding the
+ /// fractional number of days given by value to the nearest
+ /// millisecond, and adding that interval to the specified DateTime. The
+ /// value argument is permitted to be negative.
+ /// </summary>
public virtual DateTime AddDays(DateTime time, int days)
{
- return (Add(time, days, MillisPerDay));
+ return Add(time, days, MillisPerDay);
}
- // Returns the DateTime resulting from adding a fractional number of
- // hours to the specified DateTime. The result is computed by rounding the
- // fractional number of hours given by value to the nearest
- // millisecond, and adding that interval to the specified DateTime. The
- // value argument is permitted to be negative.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding a fractional number of
+ /// hours to the specified DateTime. The result is computed by rounding the
+ /// fractional number of hours given by value to the nearest
+ /// millisecond, and adding that interval to the specified DateTime. The
+ /// value argument is permitted to be negative.
+ /// </summary>
public virtual DateTime AddHours(DateTime time, int hours)
{
- return (Add(time, hours, MillisPerHour));
+ return Add(time, hours, MillisPerHour);
}
-
- // Returns the DateTime resulting from adding a fractional number of
- // minutes to the specified DateTime. The result is computed by rounding the
- // fractional number of minutes given by value to the nearest
- // millisecond, and adding that interval to the specified DateTime. The
- // value argument is permitted to be negative.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding a fractional number of
+ /// minutes to the specified DateTime. The result is computed by rounding the
+ /// fractional number of minutes given by value to the nearest
+ /// millisecond, and adding that interval to the specified DateTime. The
+ /// value argument is permitted to be negative.
+ /// </summary>
public virtual DateTime AddMinutes(DateTime time, int minutes)
{
- return (Add(time, minutes, MillisPerMinute));
+ return Add(time, minutes, MillisPerMinute);
}
-
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
- // In more precise terms, considering the specified DateTime to be of the
- // form y / m / d + t, where y is the
- // year, m is the month, d is the day, and t is the
- // time-of-day, the result is y1 / m1 / d1 + t,
- // where y1 and m1 are computed by adding value months
- // to y and m, and d1 is the largest value less than
- // or equal to d that denotes a valid day in month m1 of year
- // y1.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding the given number of
+ /// months to the specified DateTime. The result is computed by incrementing
+ /// (or decrementing) the year and month parts of the specified DateTime by
+ /// value months, and, if required, adjusting the day part of the
+ /// resulting date downwards to the last day of the resulting month in the
+ /// resulting year. The time-of-day part of the result is the same as the
+ /// time-of-day part of the specified DateTime.
+ ///
+ /// In more precise terms, considering the specified DateTime to be of the
+ /// form y / m / d + t, where y is the
+ /// year, m is the month, d is the day, and t is the
+ /// time-of-day, the result is y1 / m1 / d1 + t,
+ /// where y1 and m1 are computed by adding value months
+ /// to y and m, and d1 is the largest value less than
+ /// or equal to d that denotes a valid day in month m1 of year
+ /// y1.
+ /// </summary>
public abstract DateTime AddMonths(DateTime time, int months);
- // Returns the DateTime resulting from adding a number of
- // seconds to the specified DateTime. The result is computed by rounding the
- // fractional number of seconds given by value to the nearest
- // millisecond, and adding that interval to the specified DateTime. The
- // value argument is permitted to be negative.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding a number of
+ /// seconds to the specified DateTime. The result is computed by rounding the
+ /// fractional number of seconds given by value to the nearest
+ /// millisecond, and adding that interval to the specified DateTime. The
+ /// value argument is permitted to be negative.
+ /// </summary>
public virtual DateTime AddSeconds(DateTime time, int seconds)
{
return Add(time, seconds, MillisPerSecond);
@@ -318,105 +247,92 @@ namespace System.Globalization
// Returns the DateTime resulting from adding a number of
// weeks to the specified DateTime. The
// value argument is permitted to be negative.
- //
-
public virtual DateTime AddWeeks(DateTime time, int weeks)
{
- return (AddDays(time, weeks * 7));
+ return AddDays(time, weeks * 7);
}
-
- // Returns the DateTime resulting from adding the given number of
- // years to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year part of the specified DateTime by value
- // years. If the month and day of the specified DateTime is 2/29, and if the
- // resulting year is not a leap year, the month and day of the resulting
- // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
- // parts of the result are the same as those of the specified DateTime.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding the given number of
+ /// years to the specified DateTime. The result is computed by incrementing
+ /// (or decrementing) the year part of the specified DateTime by value
+ /// years. If the month and day of the specified DateTime is 2/29, and if the
+ /// resulting year is not a leap year, the month and day of the resulting
+ /// DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
+ /// parts of the result are the same as those of the specified DateTime.
+ /// </summary>
public abstract DateTime AddYears(DateTime time, int years);
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 31.
- //
-
+ /// <summary>
+ /// Returns the day-of-month part of the specified DateTime. The returned
+ /// value is an integer between 1 and 31.
+ /// </summary>
public abstract int GetDayOfMonth(DateTime time);
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
+ /// <summary>
+ /// Returns the day-of-week part of the specified DateTime. The returned value
+ /// is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
+ /// Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
+ /// Thursday, 5 indicates Friday, and 6 indicates Saturday.
+ /// </summary>
public abstract DayOfWeek GetDayOfWeek(DateTime time);
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and 366.
- //
-
+ /// <summary>
+ /// Returns the day-of-year part of the specified DateTime. The returned value
+ /// is an integer between 1 and 366.
+ /// </summary>
public abstract int GetDayOfYear(DateTime time);
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
-
+ /// <summary>
+ /// Returns the number of days in the month given by the year and
+ /// month arguments.
+ /// </summary>
public virtual int GetDaysInMonth(int year, int month)
{
- return (GetDaysInMonth(year, month, CurrentEra));
+ return GetDaysInMonth(year, month, CurrentEra);
}
- // Returns the number of days in the month given by the year and
- // month arguments for the specified era.
- //
-
+ /// <summary>
+ /// Returns the number of days in the month given by the year and
+ /// month arguments for the specified era.
+ /// </summary>
public abstract int GetDaysInMonth(int year, int month, int era);
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
+ /// <summary>
+ /// Returns the number of days in the year given by the year argument
+ /// for the current era.
+ /// </summary>
public virtual int GetDaysInYear(int year)
{
- return (GetDaysInYear(year, CurrentEra));
+ return GetDaysInYear(year, CurrentEra);
}
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
+ /// <summary>
+ /// Returns the number of days in the year given by the year argument
+ /// for the current era.
+ /// </summary>
public abstract int GetDaysInYear(int year, int era);
- // Returns the era for the specified DateTime value.
-
+ /// <summary>
+ /// Returns the era for the specified DateTime value.
+ /// </summary>
public abstract int GetEra(DateTime time);
- /*=================================Eras==========================
- **Action: Get the list of era values.
- **Returns: The int array of the era names supported in this calendar.
- ** null if era is not used.
- **Arguments: None.
- **Exceptions: None.
- ============================================================================*/
-
-
- public abstract int[] Eras
- {
- get;
- }
-
+ /// <summary>
+ /// Get the list of era values.
+ /// </summary>
+ /// <returns>The int array of the era names supported in this calendar or null if era is not used.</returns>
+ public abstract int[] Eras { get; }
// Returns the hour part of the specified DateTime. The returned value is an
// integer between 0 and 23.
- //
-
public virtual int GetHour(DateTime time)
{
- return ((int)((time.Ticks / TicksPerHour) % 24));
+ return (int)((time.Ticks / TicksPerHour) % 24);
}
// Returns the millisecond part of the specified DateTime. The returned value
// is an integer between 0 and 999.
- //
-
public virtual double GetMilliseconds(DateTime time)
{
return (double)((time.Ticks / TicksPerMillisecond) % 1000);
@@ -424,76 +340,64 @@ namespace System.Globalization
// Returns the minute part of the specified DateTime. The returned value is
// an integer between 0 and 59.
- //
-
public virtual int GetMinute(DateTime time)
{
- return ((int)((time.Ticks / TicksPerMinute) % 60));
+ return (int)((time.Ticks / TicksPerMinute) % 60);
}
// Returns the month part of the specified DateTime. The returned value is an
// integer between 1 and 12.
- //
-
public abstract int GetMonth(DateTime time);
// Returns the number of months in the specified year in the current era.
-
public virtual int GetMonthsInYear(int year)
{
- return (GetMonthsInYear(year, CurrentEra));
+ return GetMonthsInYear(year, CurrentEra);
}
// Returns the number of months in the specified year and era.
-
public abstract int GetMonthsInYear(int year, int era);
// Returns the second part of the specified DateTime. The returned value is
// an integer between 0 and 59.
- //
-
public virtual int GetSecond(DateTime time)
{
- return ((int)((time.Ticks / TicksPerSecond) % 60));
- }
-
- /*=================================GetFirstDayWeekOfYear==========================
- **Action: Get the week of year using the FirstDay rule.
- **Returns: the week of year.
- **Arguments:
- ** time
- ** firstDayOfWeek the first day of week (0=Sunday, 1=Monday, ... 6=Saturday)
- **Notes:
- ** The CalendarWeekRule.FirstDay rule: Week 1 begins on the first day of the year.
- ** Assume f is the specifed firstDayOfWeek,
- ** and n is the day of week for January 1 of the specified year.
- ** Assign offset = n - f;
- ** Case 1: offset = 0
- ** E.g.
- ** f=1
- ** weekday 0 1 2 3 4 5 6 0 1
- ** date 1/1
- ** week# 1 2
- ** then week of year = (GetDayOfYear(time) - 1) / 7 + 1
- **
- ** Case 2: offset < 0
- ** e.g.
- ** n=1 f=3
- ** weekday 0 1 2 3 4 5 6 0
- ** date 1/1
- ** week# 1 2
- ** This means that the first week actually starts 5 days before 1/1.
- ** So week of year = (GetDayOfYear(time) + (7 + offset) - 1) / 7 + 1
- ** Case 3: offset > 0
- ** e.g.
- ** f=0 n=2
- ** weekday 0 1 2 3 4 5 6 0 1 2
- ** date 1/1
- ** week# 1 2
- ** This means that the first week actually starts 2 days before 1/1.
- ** So Week of year = (GetDayOfYear(time) + offset - 1) / 7 + 1
- ============================================================================*/
-
+ return (int)((time.Ticks / TicksPerSecond) % 60);
+ }
+
+ /// <summary>
+ /// Get the week of year using the FirstDay rule.
+ /// </summary>
+ /// <remarks>
+ /// The CalendarWeekRule.FirstDay rule: Week 1 begins on the first day of the year.
+ /// Assume f is the specifed firstDayOfWeek,
+ /// and n is the day of week for January 1 of the specified year.
+ /// Assign offset = n - f;
+ /// Case 1: offset = 0
+ /// E.g.
+ /// f=1
+ /// weekday 0 1 2 3 4 5 6 0 1
+ /// date 1/1
+ /// week# 1 2
+ /// then week of year = (GetDayOfYear(time) - 1) / 7 + 1
+ ///
+ /// Case 2: offset &lt; 0
+ /// e.g.
+ /// n=1 f=3
+ /// weekday 0 1 2 3 4 5 6 0
+ /// date 1/1
+ /// week# 1 2
+ /// This means that the first week actually starts 5 days before 1/1.
+ /// So week of year = (GetDayOfYear(time) + (7 + offset) - 1) / 7 + 1
+ /// Case 3: offset > 0
+ /// e.g.
+ /// f=0 n=2
+ /// weekday 0 1 2 3 4 5 6 0 1 2
+ /// date 1/1
+ /// week# 1 2
+ /// This means that the first week actually starts 2 days before 1/1.
+ /// So Week of year = (GetDayOfYear(time) + offset - 1) / 7 + 1
+ /// </remarks>
internal int GetFirstDayWeekOfYear(DateTime time, int firstDayOfWeek)
{
int dayOfYear = GetDayOfYear(time) - 1; // Make the day of year to be 0-based, so that 1/1 is day 0.
@@ -513,7 +417,7 @@ namespace System.Globalization
int day;
int dayOfYear = GetDayOfYear(time) - 1; // Make the day of year to be 0-based, so that 1/1 is day 0.
- //
+
// Calculate the number of days between the first day of year (1/1) and the first day of the week.
// This value will be a positive value from 0 ~ 6. We call this value as "offset".
//
@@ -535,8 +439,6 @@ namespace System.Globalization
// 1/1 1/2 1/3 1/4 1/5 1/6 1/7 1/8
// +--> First week starts here.
-
-
// Day of week is 0-based.
// Get the day of week for 1/1. This can be derived from the day of week of the target day.
// Note that we can get a negative value. It's ok since we are going to make it a positive value when calculating the offset.
@@ -546,27 +448,21 @@ namespace System.Globalization
offset = (firstDayOfWeek - dayForJan1 + 14) % 7;
if (offset != 0 && offset >= fullDays)
{
- //
// If the offset is greater than the value of fullDays, it means that
// the first week of the year starts on the week where Jan/1 falls on.
- //
offset -= 7;
}
- //
+
// Calculate the day of year for specified time by taking offset into account.
- //
day = dayOfYear - offset;
if (day >= 0)
{
- //
// If the day of year value is greater than zero, get the week of year.
- //
- return (day / 7 + 1);
+ return day / 7 + 1;
}
- //
+
// Otherwise, the specified time falls on the week of previous year.
// Call this method again by passing the last day of previous year.
- //
// the last day of the previous year may "underflow" to no longer be a valid date time for
// this calendar if we just subtract so we need the subclass to provide us with
// that information
@@ -574,7 +470,8 @@ namespace System.Globalization
{
return GetWeekOfYearOfMinSupportedDateTime(firstDayOfWeek, fullDays);
}
- return (GetWeekOfYearFullDays(time.AddDays(-(dayOfYear + 1)), firstDayOfWeek, fullDays));
+
+ return GetWeekOfYearFullDays(time.AddDays(-(dayOfYear + 1)), firstDayOfWeek, fullDays);
}
private int GetWeekOfYearOfMinSupportedDateTime(int firstDayOfWeek, int minimumDaysInFirstWeek)
@@ -605,135 +502,137 @@ namespace System.Globalization
day += 7;
}
- return (day / 7 + 1);
- }
-
- // it would be nice to make this abstract but we can't since that would break previous implementations
- protected virtual int DaysInYearBeforeMinSupportedYear
- {
- get
- {
- return 365;
- }
+ return day / 7 + 1;
}
+ protected virtual int DaysInYearBeforeMinSupportedYear => 365;
- // Returns the week of year for the specified DateTime. The returned value is an
- // integer between 1 and 53.
- //
-
+ /// <summary>
+ /// Returns the week of year for the specified DateTime. The returned value is an
+ /// integer between 1 and 53.
+ /// </summary>
public virtual int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
- if ((int)firstDayOfWeek < 0 || (int)firstDayOfWeek > 6)
+ if (firstDayOfWeek < DayOfWeek.Sunday || firstDayOfWeek > DayOfWeek.Saturday)
{
throw new ArgumentOutOfRangeException(
- nameof(firstDayOfWeek), SR.Format(SR.ArgumentOutOfRange_Range,
- DayOfWeek.Sunday, DayOfWeek.Saturday));
+ nameof(firstDayOfWeek),
+ firstDayOfWeek,
+ SR.Format(SR.ArgumentOutOfRange_Range, DayOfWeek.Sunday, DayOfWeek.Saturday));
}
switch (rule)
{
case CalendarWeekRule.FirstDay:
- return (GetFirstDayWeekOfYear(time, (int)firstDayOfWeek));
+ return GetFirstDayWeekOfYear(time, (int)firstDayOfWeek);
case CalendarWeekRule.FirstFullWeek:
- return (GetWeekOfYearFullDays(time, (int)firstDayOfWeek, 7));
+ return GetWeekOfYearFullDays(time, (int)firstDayOfWeek, 7);
case CalendarWeekRule.FirstFourDayWeek:
- return (GetWeekOfYearFullDays(time, (int)firstDayOfWeek, 4));
- }
- throw new ArgumentOutOfRangeException(
- nameof(rule), SR.Format(SR.ArgumentOutOfRange_Range,
- CalendarWeekRule.FirstDay, CalendarWeekRule.FirstFourDayWeek));
+ return GetWeekOfYearFullDays(time, (int)firstDayOfWeek, 4);
+ default:
+ throw new ArgumentOutOfRangeException(
+ nameof(rule),
+ rule,
+ SR.Format(SR.ArgumentOutOfRange_Range, CalendarWeekRule.FirstDay, CalendarWeekRule.FirstFourDayWeek)); }
}
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between 1 and 9999.
- //
-
+ /// <summary>
+ /// Returns the year part of the specified DateTime. The returned value is an
+ /// integer between 1 and 9999.
+ /// </summary>
public abstract int GetYear(DateTime time);
- // Checks whether a given day in the current era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given day in the current era is a leap day.
+ /// This method returns true if the date is a leap day, or false if not.
+ /// </summary>
public virtual bool IsLeapDay(int year, int month, int day)
{
- return (IsLeapDay(year, month, day, CurrentEra));
+ return IsLeapDay(year, month, day, CurrentEra);
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given day in the specified era is a leap day.
+ /// This method returns true if the date is a leap day, or false if not.
+ /// </summary>
public abstract bool IsLeapDay(int year, int month, int day, int era);
- // Checks whether a given month in the current era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given month in the current era is a leap month.
+ /// This method returns true if month is a leap month, or false if not.
+ /// </summary>
public virtual bool IsLeapMonth(int year, int month)
{
- return (IsLeapMonth(year, month, CurrentEra));
+ return IsLeapMonth(year, month, CurrentEra);
}
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given month in the specified era is a leap month. This method returns true if
+ /// month is a leap month, or false if not.
+ /// </summary>
public abstract bool IsLeapMonth(int year, int month, int era);
- // Returns the leap month in a calendar year of the current era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
+ /// <summary>
+ /// Returns the leap month in a calendar year of the current era.
+ /// This method returns 0 if this calendar does not have leap month,
+ /// or this year is not a leap year.
+ /// </summary>
public virtual int GetLeapMonth(int year)
{
- return (GetLeapMonth(year, CurrentEra));
+ return GetLeapMonth(year, CurrentEra);
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
+ /// <summary>
+ /// Returns the leap month in a calendar year of the specified era.
+ /// This method returns 0 if this calendar does not have leap month,
+ /// or this year is not a leap year.
+ /// </summary>
public virtual int GetLeapMonth(int year, int era)
{
if (!IsLeapYear(year, era))
+ {
return 0;
+ }
int monthsCount = GetMonthsInYear(year, era);
for (int month = 1; month <= monthsCount; month++)
{
if (IsLeapMonth(year, month, era))
+ {
return month;
+ }
}
return 0;
}
- // Checks whether a given year in the current era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given year in the current era is a leap year.
+ /// This method returns true if year is a leap year, or false if not.
+ /// </summary>
public virtual bool IsLeapYear(int year)
{
- return (IsLeapYear(year, CurrentEra));
+ return IsLeapYear(year, CurrentEra);
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given year in the specified era is a leap year.
+ /// This method returns true if year is a leap year, or false if not.
+ /// </summary>
public abstract bool IsLeapYear(int year, int era);
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
-
+ /// <summary>
+ /// Returns the date and time converted to a DateTime value.
+ /// Throws an exception if the n-tuple is invalid.
+ /// </summary>
public virtual DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)
{
- return (ToDateTime(year, month, day, hour, minute, second, millisecond, CurrentEra));
+ return ToDateTime(year, month, day, hour, minute, second, millisecond, CurrentEra);
}
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
-
+ /// <summary>
+ /// Returns the date and time converted to a DateTime value.
+ /// Throws an exception if the n-tuple is invalid.
+ /// </summary>
public abstract DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era);
internal virtual bool TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result)
@@ -757,84 +656,80 @@ namespace System.Globalization
internal virtual bool IsValidMonth(int year, int month, int era)
{
- return (IsValidYear(year, era) && month >= 1 && month <= GetMonthsInYear(year, era));
+ return IsValidYear(year, era) && month >= 1 && month <= GetMonthsInYear(year, era);
}
internal virtual bool IsValidDay(int year, int month, int day, int era)
{
- return (IsValidMonth(year, month, era) && day >= 1 && day <= GetDaysInMonth(year, month, era));
+ return IsValidMonth(year, month, era) && day >= 1 && day <= GetDaysInMonth(year, month, era);
}
-
- // Returns and assigns the maximum value to represent a two digit year. This
- // value is the upper boundary of a 100 year range that allows a two digit year
- // to be properly translated to a four digit year. For example, if 2029 is the
- // upper boundary, then a two digit value of 30 should be interpreted as 1930
- // while a two digit value of 29 should be interpreted as 2029. In this example
- // , the 100 year range would be from 1930-2029. See ToFourDigitYear().
-
+ /// <summary>
+ /// Returns and assigns the maximum value to represent a two digit year.
+ /// This value is the upper boundary of a 100 year range that allows a
+ /// two digit year to be properly translated to a four digit year.
+ /// For example, if 2029 is the upper boundary, then a two digit value of
+ /// 30 should be interpreted as 1930 while a two digit value of 29 should
+ /// be interpreted as 2029. In this example, the 100 year range would be
+ /// from 1930-2029. See ToFourDigitYear().
+ /// </summary>
public virtual int TwoDigitYearMax
{
- get
- {
- return (twoDigitYearMax);
- }
-
+ get => _twoDigitYearMax;
set
{
VerifyWritable();
- twoDigitYearMax = value;
+ _twoDigitYearMax = value;
}
}
- // Converts the year value to the appropriate century by using the
- // TwoDigitYearMax property. For example, if the TwoDigitYearMax value is 2029,
- // then a two digit value of 30 will get converted to 1930 while a two digit
- // value of 29 will get converted to 2029.
-
+ /// <summary>
+ /// Converts the year value to the appropriate century by using the
+ /// TwoDigitYearMax property. For example, if the TwoDigitYearMax value is 2029,
+ /// then a two digit value of 30 will get converted to 1930 while a two digit
+ /// value of 29 will get converted to 2029.
+ /// </summary>
public virtual int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
if (year < 100)
{
- return ((TwoDigitYearMax / 100 - (year > TwoDigitYearMax % 100 ? 1 : 0)) * 100 + year);
+ return (TwoDigitYearMax / 100 - (year > TwoDigitYearMax % 100 ? 1 : 0)) * 100 + year;
}
+
// If the year value is above 100, just return the year value. Don't have to do
// the TwoDigitYearMax comparison.
- return (year);
+ return year;
}
- // Return the tick count corresponding to the given hour, minute, second.
- // Will check the if the parameters are valid.
+ /// <summary>
+ /// Return the tick count corresponding to the given hour, minute, second.
+ /// Will check the if the parameters are valid.
+ /// </summary>
internal static long TimeToTicks(int hour, int minute, int second, int millisecond)
{
- if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60 && second >= 0 && second < 60)
+ if (hour < 0 || hour >= 24 || minute < 0 || minute >= 60 || second < 0 || second >= 60)
{
- if (millisecond < 0 || millisecond >= MillisPerSecond)
- {
- throw new ArgumentOutOfRangeException(
- nameof(millisecond),
- string.Format(
- CultureInfo.InvariantCulture,
- SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)));
- }
- return InternalGlobalizationHelper.TimeToTicks(hour, minute, second) + millisecond * TicksPerMillisecond;
+ throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond);
+ }
+ if (millisecond < 0 || millisecond >= MillisPerSecond)
+ {
+ throw new ArgumentOutOfRangeException(
+ nameof(millisecond),
+ millisecond,
+ SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1));
}
- throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond);
+
+ return InternalGlobalizationHelper.TimeToTicks(hour, minute, second) + millisecond * TicksPerMillisecond;
}
internal static int GetSystemTwoDigitYearSetting(CalendarId CalID, int defaultYearValue)
{
int twoDigitYearMax = CalendarData.GetTwoDigitYearMax(CalID);
- if (twoDigitYearMax < 0)
- {
- twoDigitYearMax = defaultYearValue;
- }
- return (twoDigitYearMax);
+ return twoDigitYearMax >= 0 ? twoDigitYearMax : defaultYearValue;
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs
index 39448e183f..56ce99550f 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs
@@ -2,54 +2,29 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
namespace System.Globalization
{
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1901/02/19 2101/01/28
- ** ChineseLunisolar 1901/01/01 2100/12/29
- */
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1901/02/19 2101/01/28
+ /// ChineseLunisolar 1901/01/01 2100/12/29
+ /// </remarks>
public class ChineseLunisolarCalendar : EastAsianLunisolarCalendar
{
- //
- // The era value for the current era.
- //
-
public const int ChineseEra = 1;
- internal const int MIN_LUNISOLAR_YEAR = 1901;
- internal const int MAX_LUNISOLAR_YEAR = 2100;
+ private const int MinLunisolarYear = 1901;
+ private const int MaxLunisolarYear = 2100;
- internal const int MIN_GREGORIAN_YEAR = 1901;
- internal const int MIN_GREGORIAN_MONTH = 2;
- internal const int MIN_GREGORIAN_DAY = 19;
+ private static readonly DateTime s_minDate = new DateTime(1901, 2, 19);
+ private static readonly DateTime s_maxDate = new DateTime((new DateTime(2101, 1, 28, 23, 59, 59, 999)).Ticks + 9999);
- internal const int MAX_GREGORIAN_YEAR = 2101;
- internal const int MAX_GREGORIAN_MONTH = 1;
- internal const int MAX_GREGORIAN_DAY = 28;
+ public override DateTime MinSupportedDateTime => s_minDate;
- internal static DateTime minDate = new DateTime(MIN_GREGORIAN_YEAR, MIN_GREGORIAN_MONTH, MIN_GREGORIAN_DAY);
- internal static DateTime maxDate = new DateTime((new DateTime(MAX_GREGORIAN_YEAR, MAX_GREGORIAN_MONTH, MAX_GREGORIAN_DAY, 23, 59, 59, 999)).Ticks + 9999);
-
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (minDate);
- }
- }
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (maxDate);
- }
- }
+ public override DateTime MaxSupportedDateTime => s_maxDate;
protected override int DaysInYearBeforeMinSupportedYear
{
@@ -62,11 +37,11 @@ namespace System.Globalization
}
// Data for years 1901-1905 and 1907-2100 matches output of Calendrical Calculations [2] and published calendar tables [3].
- // For 1906, month 4 of the Chinese year starts on 24 Apr 1906 and has 29 days. This is historially accurate
- // but different to the values in [1] and output from [2]. This is due to a change in the astronomical methods used
+ // For 1906, month 4 of the Chinese year starts on 24 Apr 1906 and has 29 days. This is historially accurate
+ // but different to the values in [1] and output from [2]. This is due to a change in the astronomical methods used
// by the Chinese to calculate the calendar from 1913 onwards (see warnings in [1]).
- // [2] Reingold, Edward M, and Nachum Dershowitz. Calendrical Calculations: The Ultimate Edition. Cambridge [etc.: Cambridge University Press, 2018. Print.
- // [3] Wang, Jianmin. Xin Bian Wan Nian Li: (1840-2050) Chong Bian Ben. Beijing: Ke xue pu ji chu ban she, 1990. Print.
+ // [2] Reingold, Edward M, and Nachum Dershowitz. Calendrical Calculations: The Ultimate Edition. Cambridge [etc.: Cambridge University Press, 2018. Print.
+ // [3] Wang, Jianmin. Xin Bian Wan Nian Li: (1840-2050) Chong Bian Ben. Beijing: Ke xue pu ji chu ban she, 1990. Print.
private static readonly int[,] s_yinfo =
{
/*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days
@@ -272,58 +247,24 @@ namespace System.Globalization
2100 */ { 00, 02, 09, 0b1101010100100000 }, /* 30 30 29 30 29 30 29 30 29 29 30 29 354
*/ };
- internal override int MinCalendarYear
- {
- get
- {
- return (MIN_LUNISOLAR_YEAR);
- }
- }
+ internal override int MinCalendarYear => MinLunisolarYear;
- internal override int MaxCalendarYear
- {
- get
- {
- return (MAX_LUNISOLAR_YEAR);
- }
- }
+ internal override int MaxCalendarYear => MaxLunisolarYear;
- internal override DateTime MinDate
- {
- get
- {
- return (minDate);
- }
- }
+ internal override DateTime MinDate => s_minDate;
- internal override DateTime MaxDate
- {
- get
- {
- return (maxDate);
- }
- }
+ internal override DateTime MaxDate => s_maxDate;
- internal override EraInfo[] CalEraInfo
- {
- get
- {
- return (null);
- }
- }
+ internal override EraInfo[] CalEraInfo => null;
internal override int GetYearInfo(int lunarYear, int index)
{
- if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
+ if (lunarYear < MinLunisolarYear || lunarYear > MaxLunisolarYear)
{
- throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR));
+ throw new ArgumentOutOfRangeException("year", lunarYear, SR.Format(SR.ArgumentOutOfRange_Range, MinLunisolarYear, MaxLunisolarYear));
}
- return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
+ return s_yinfo[lunarYear - MinLunisolarYear, index];
}
internal override int GetYear(int year, DateTime time)
@@ -335,16 +276,11 @@ namespace System.Globalization
{
if (era != CurrentEra && era != ChineseEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
-
- if (year < MIN_LUNISOLAR_YEAR || year > MAX_LUNISOLAR_YEAR)
+ if (year < MinLunisolarYear || year > MaxLunisolarYear)
{
- throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR));
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.Format(SR.ArgumentOutOfRange_Range, MinLunisolarYear, MaxLunisolarYear));
}
return year;
@@ -357,32 +293,20 @@ namespace System.Globalization
public override int GetEra(DateTime time)
{
CheckTicksRange(time.Ticks);
- return (ChineseEra);
+ return ChineseEra;
}
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.CHINESELUNISOLAR);
- }
- }
+ internal override CalendarId ID => CalendarId.CHINESELUNISOLAR;
internal override CalendarId BaseCalendarID
{
get
{
//Use CAL_GREGORIAN just to get CurrentEraValue as 1 since we do not have data under the ID CAL_ChineseLunisolar yet
- return (CalendarId.GREGORIAN);
+ return CalendarId.GREGORIAN;
}
}
- public override int[] Eras
- {
- get
- {
- return (new int[] { ChineseEra });
- }
- }
+ public override int[] Eras => new int[] { ChineseEra };
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs
index a29f8a1ee5..58cdedf350 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs
@@ -2,80 +2,62 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
namespace System.Globalization
{
public abstract class EastAsianLunisolarCalendar : Calendar
{
- internal const int LeapMonth = 0;
- internal const int Jan1Month = 1;
- internal const int Jan1Date = 2;
- internal const int nDaysPerMonth = 3;
+ private const int LeapMonth = 0;
+ private const int Jan1Month = 1;
+ private const int Jan1Date = 2;
+ private const int nDaysPerMonth = 3;
// # of days so far in the solar year
- internal static readonly int[] DaysToMonth365 =
- {
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
- };
-
- internal static readonly int[] DaysToMonth366 =
- {
- 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
- };
-
- internal const int DatePartYear = 0;
- internal const int DatePartDayOfYear = 1;
- internal const int DatePartMonth = 2;
- internal const int DatePartDay = 3;
+ private static readonly int[] s_daysToMonth365 = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.LunisolarCalendar;
- }
- }
+ private static readonly int[] s_daysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 };
- // Return the year number in the 60-year cycle.
- //
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.LunisolarCalendar;
+ /// <summary>
+ /// Return the year number in the 60-year cycle.
+ /// </summary>
public virtual int GetSexagenaryYear(DateTime time)
{
CheckTicksRange(time.Ticks);
- int year = 0, month = 0, day = 0;
- TimeToLunar(time, ref year, ref month, ref day);
-
+ TimeToLunar(time, out int year, out int month, out int day);
return ((year - 4) % 60) + 1;
}
- // Return the celestial year from the 60-year cycle.
- // The returned value is from 1 ~ 10.
- //
-
+ /// <summary>
+ /// Return the celestial year from the 60-year cycle.
+ /// The returned value is from 1 ~ 10.
+ /// </summary>
public int GetCelestialStem(int sexagenaryYear)
{
- if ((sexagenaryYear < 1) || (sexagenaryYear > 60))
+ if (sexagenaryYear < 1 || sexagenaryYear > 60)
{
throw new ArgumentOutOfRangeException(
- nameof(sexagenaryYear),
- SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
+ nameof(sexagenaryYear),
+ sexagenaryYear,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
}
return ((sexagenaryYear - 1) % 10) + 1;
}
- // Return the Terrestial Branch from the 60-year cycle.
- // The returned value is from 1 ~ 12.
- //
-
+ /// <summary>
+ /// Return the Terrestial Branch from the 60-year cycle.
+ /// The returned value is from 1 ~ 12.
+ /// </summary>
public int GetTerrestrialBranch(int sexagenaryYear)
{
- if ((sexagenaryYear < 1) || (sexagenaryYear > 60))
+ if (sexagenaryYear < 1 || sexagenaryYear > 60)
{
throw new ArgumentOutOfRangeException(
- nameof(sexagenaryYear),
- SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
+ nameof(sexagenaryYear),
+ sexagenaryYear,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
}
return ((sexagenaryYear - 1) % 12) + 1;
@@ -96,9 +78,8 @@ namespace System.Globalization
internal int MinEraCalendarYear(int era)
{
- EraInfo[] mEraInfo = CalEraInfo;
- //ChineseLunisolarCalendar does not has m_EraInfo it is going to retuen null
- if (mEraInfo == null)
+ EraInfo[] eraInfo = CalEraInfo;
+ if (eraInfo == null)
{
return MinCalendarYear;
}
@@ -107,27 +88,28 @@ namespace System.Globalization
{
era = CurrentEraValue;
}
- //era has to be in the supported range otherwise we will throw exception in CheckEraRange()
+
+ // Era has to be in the supported range otherwise we will throw exception in CheckEraRange()
if (era == GetEra(MinDate))
{
- return (GetYear(MinCalendarYear, MinDate));
+ return GetYear(MinCalendarYear, MinDate);
}
- for (int i = 0; i < mEraInfo.Length; i++)
+ for (int i = 0; i < eraInfo.Length; i++)
{
- if (era == mEraInfo[i].era)
+ if (era == eraInfo[i].era)
{
- return (mEraInfo[i].minEraYear);
+ return eraInfo[i].minEraYear;
}
}
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
internal int MaxEraCalendarYear(int era)
{
- EraInfo[] mEraInfo = CalEraInfo;
- //ChineseLunisolarCalendar does not has m_EraInfo it is going to retuen null
- if (mEraInfo == null)
+ EraInfo[] eraInfo = CalEraInfo;
+ if (eraInfo == null)
{
return MaxCalendarYear;
}
@@ -136,20 +118,22 @@ namespace System.Globalization
{
era = CurrentEraValue;
}
- //era has to be in the supported range otherwise we will throw exception in CheckEraRange()
+
+ // Era has to be in the supported range otherwise we will throw exception in CheckEraRange()
if (era == GetEra(MaxDate))
{
- return (GetYear(MaxCalendarYear, MaxDate));
+ return GetYear(MaxCalendarYear, MaxDate);
}
- for (int i = 0; i < mEraInfo.Length; i++)
+ for (int i = 0; i < eraInfo.Length; i++)
{
- if (era == mEraInfo[i].era)
+ if (era == eraInfo[i].era)
{
- return (mEraInfo[i].maxEraYear);
+ return eraInfo[i].maxEraYear;
}
}
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
internal EastAsianLunisolarCalendar()
@@ -162,6 +146,7 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(
"time",
+ ticks,
string.Format(CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange,
MinSupportedDateTime, MaxSupportedDateTime));
}
@@ -174,9 +159,9 @@ namespace System.Globalization
era = CurrentEraValue;
}
- if ((era < GetEra(MinDate)) || (era > GetEra(MaxDate)))
+ if (era < GetEra(MinDate) || era > GetEra(MaxDate))
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
}
@@ -185,11 +170,12 @@ namespace System.Globalization
CheckEraRange(era);
year = GetGregorianYear(year, era);
- if ((year < MinCalendarYear) || (year > MaxCalendarYear))
+ if (year < MinCalendarYear || year > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- SR.Format(SR.ArgumentOutOfRange_Range, MinEraCalendarYear(era), MaxEraCalendarYear(era)));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinEraCalendarYear(era), MaxEraCalendarYear(era)));
}
return year;
}
@@ -200,51 +186,63 @@ namespace System.Globalization
if (month == 13)
{
- //Reject if there is no leap month this year
+ // Reject if there is no leap month this year
if (GetYearInfo(year, LeapMonth) == 0)
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ {
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
+ }
}
if (month < 1 || month > 13)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
}
+
return year;
}
internal int InternalGetDaysInMonth(int year, int month)
{
- int nDays;
- int mask; // mask for extracting bits
+ int mask = 0x8000;
- mask = 0x8000;
// convert the lunar day into a lunar month/date
mask >>= (month - 1);
if ((GetYearInfo(year, nDaysPerMonth) & mask) == 0)
- nDays = 29;
- else
- nDays = 30;
- return nDays;
- }
+ {
+ return 29;
+ }
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
+ return 30;
+ }
+ /// <summary>
+ /// Returns the number of days in the month given by the year and
+ /// month arguments.
+ /// </summary>
public override int GetDaysInMonth(int year, int month, int era)
{
year = CheckYearMonthRange(year, month, era);
return InternalGetDaysInMonth(year, month);
}
- private static int GregorianIsLeapYear(int y)
+ private static bool GregorianIsLeapYear(int y)
{
- return ((((y) % 4) != 0) ? 0 : ((((y) % 100) != 0) ? 1 : ((((y) % 400) != 0) ? 0 : 1)));
- }
+ if ((y % 4) != 0)
+ {
+ return false;
+ }
+ if ((y % 100) != 0)
+ {
+ return true;
+ }
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
+ return (y % 400) == 0;
+ }
+ /// <summary>
+ /// Returns the date and time converted to a DateTime value.
+ /// Throws an exception if the n-tuple is invalid.
+ /// </summary>
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
year = CheckYearMonthRange(year, month, era);
@@ -252,73 +250,63 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
- int gy = 0; int gm = 0; int gd = 0;
-
- if (LunarToGregorian(year, month, day, ref gy, ref gm, ref gd))
- {
- return new DateTime(gy, gm, gd, hour, minute, second, millisecond);
- }
- else
+ if (!LunarToGregorian(year, month, day, out int gy, out int gm, out int gd))
{
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
- }
+ return new DateTime(gy, gm, gd, hour, minute, second, millisecond);
+ }
- //
- // GregorianToLunar calculates lunar calendar info for the given gregorian year, month, date.
- // The input date should be validated before calling this method.
- //
- internal void GregorianToLunar(int nSYear, int nSMonth, int nSDate, ref int nLYear, ref int nLMonth, ref int nLDate)
+ /// <summary>
+ /// Calculates lunar calendar info for the given gregorian year, month, date.
+ /// The input date should be validated before calling this method.
+ /// </summary>
+ private void GregorianToLunar(int solarYear, int solarMonth, int solarDate, out int lunarYear, out int lunarMonth, out int lunarDate)
{
- // unsigned int nLYear, nLMonth, nLDate; // lunar ymd
- int nSolarDay; // day # in solar year
- int nLunarDay; // day # in lunar year
- int fLeap; // is it a solar leap year?
- int LDpM; // lunar days/month bitfield
- int mask; // mask for extracting bits
- int nDays; // # days this lunar month
- int nJan1Month, nJan1Date;
+ bool isLeapYear = GregorianIsLeapYear(solarYear);
+ int jan1Month;
+ int jan1Date;
- // calc the solar day of year
- fLeap = GregorianIsLeapYear(nSYear);
- nSolarDay = (fLeap == 1) ? DaysToMonth366[nSMonth - 1] : DaysToMonth365[nSMonth - 1];
- nSolarDay += nSDate;
+ // Calculate the day number in the solar year.
+ int solarDay = isLeapYear ? s_daysToMonth366[solarMonth - 1] : s_daysToMonth365[solarMonth - 1];
+ solarDay += solarDate;
- // init lunar year info
- nLunarDay = nSolarDay;
- nLYear = nSYear;
- if (nLYear == (MaxCalendarYear + 1))
+ // Calculate the day number in the lunar year.
+ int lunarDay = solarDay;
+ lunarYear = solarYear;
+ if (lunarYear == (MaxCalendarYear + 1))
{
- nLYear--;
- nLunarDay += ((GregorianIsLeapYear(nLYear) == 1) ? 366 : 365);
- nJan1Month = GetYearInfo(nLYear, Jan1Month);
- nJan1Date = GetYearInfo(nLYear, Jan1Date);
+ lunarYear--;
+ lunarDay += (GregorianIsLeapYear(lunarYear) ? 366 : 365);
+ jan1Month = GetYearInfo(lunarYear, Jan1Month);
+ jan1Date = GetYearInfo(lunarYear, Jan1Date);
}
else
{
- nJan1Month = GetYearInfo(nLYear, Jan1Month);
- nJan1Date = GetYearInfo(nLYear, Jan1Date);
+ jan1Month = GetYearInfo(lunarYear, Jan1Month);
+ jan1Date = GetYearInfo(lunarYear, Jan1Date);
// check if this solar date is actually part of the previous
// lunar year
- if ((nSMonth < nJan1Month) ||
- (nSMonth == nJan1Month && nSDate < nJan1Date))
+ if ((solarMonth < jan1Month) ||
+ (solarMonth == jan1Month && solarDate < jan1Date))
{
// the corresponding lunar day is actually part of the previous
// lunar year
- nLYear--;
+ lunarYear--;
// add a solar year to the lunar day #
- nLunarDay += ((GregorianIsLeapYear(nLYear) == 1) ? 366 : 365);
+ lunarDay += (GregorianIsLeapYear(lunarYear) ? 366 : 365);
// update the new start of year
- nJan1Month = GetYearInfo(nLYear, Jan1Month);
- nJan1Date = GetYearInfo(nLYear, Jan1Date);
+ jan1Month = GetYearInfo(lunarYear, Jan1Month);
+ jan1Date = GetYearInfo(lunarYear, Jan1Date);
}
}
@@ -327,120 +315,125 @@ namespace System.Globalization
// part of the lunar year. since this part is always in Jan or Feb,
// we don't need to handle Leap Year (LY only affects March
// and later).
- nLunarDay -= DaysToMonth365[nJan1Month - 1];
- nLunarDay -= (nJan1Date - 1);
+ lunarDay -= s_daysToMonth365[jan1Month - 1];
+ lunarDay -= (jan1Date - 1);
// convert the lunar day into a lunar month/date
- mask = 0x8000;
- LDpM = GetYearInfo(nLYear, nDaysPerMonth);
- nDays = ((LDpM & mask) != 0) ? 30 : 29;
- nLMonth = 1;
- while (nLunarDay > nDays)
- {
- nLunarDay -= nDays;
- nLMonth++;
+ int mask = 0x8000;
+ int yearInfo = GetYearInfo(lunarYear, nDaysPerMonth);
+ int days = ((yearInfo & mask) != 0) ? 30 : 29;
+ lunarMonth = 1;
+ while (lunarDay > days)
+ {
+ lunarDay -= days;
+ lunarMonth++;
mask >>= 1;
- nDays = ((LDpM & mask) != 0) ? 30 : 29;
+ days = ((yearInfo & mask) != 0) ? 30 : 29;
}
- nLDate = nLunarDay;
+ lunarDate = lunarDay;
}
- /*
- //Convert from Lunar to Gregorian
- //Highly inefficient, but it works based on the forward conversion
- */
- internal bool LunarToGregorian(int nLYear, int nLMonth, int nLDate, ref int nSolarYear, ref int nSolarMonth, ref int nSolarDay)
+ /// <summary>
+ /// Convert from Lunar to Gregorian
+ /// </summary>
+ /// <remarks>
+ /// Highly inefficient, but it works based on the forward conversion
+ /// </remarks>
+ private bool LunarToGregorian(int lunarYear, int lunarMonth, int lunarDate, out int solarYear, out int solarMonth, out int solarDay)
{
- int numLunarDays;
-
- if (nLDate < 1 || nLDate > 30)
+ if (lunarDate < 1 || lunarDate > 30)
+ {
+ solarYear = 0;
+ solarMonth = 0;
+ solarDay = 0;
return false;
+ }
- numLunarDays = nLDate - 1;
+ int numLunarDays = lunarDate - 1;
- //Add previous months days to form the total num of days from the first of the month.
- for (int i = 1; i < nLMonth; i++)
+ // Add previous months days to form the total num of days from the first of the month.
+ for (int i = 1; i < lunarMonth; i++)
{
- numLunarDays += InternalGetDaysInMonth(nLYear, i);
+ numLunarDays += InternalGetDaysInMonth(lunarYear, i);
}
- //Get Gregorian First of year
- int nJan1Month = GetYearInfo(nLYear, Jan1Month);
- int nJan1Date = GetYearInfo(nLYear, Jan1Date);
+ // Get Gregorian First of year
+ int jan1Month = GetYearInfo(lunarYear, Jan1Month);
+ int jan1Date = GetYearInfo(lunarYear, Jan1Date);
// calc the solar day of year of 1 Lunar day
- int fLeap = GregorianIsLeapYear(nLYear);
- int[] days = (fLeap == 1) ? DaysToMonth366 : DaysToMonth365;
+ bool isLeapYear = GregorianIsLeapYear(lunarYear);
+ int[] days = isLeapYear ? s_daysToMonth366 : s_daysToMonth365;
- nSolarDay = nJan1Date;
+ solarDay = jan1Date;
- if (nJan1Month > 1)
- nSolarDay += days[nJan1Month - 1];
+ if (jan1Month > 1)
+ {
+ solarDay += days[jan1Month - 1];
+ }
// Add the actual lunar day to get the solar day we want
- nSolarDay = nSolarDay + numLunarDays;// - 1;
+ solarDay = solarDay + numLunarDays;
- if (nSolarDay > (fLeap + 365))
+ if (solarDay > (365 + (isLeapYear ? 1 : 0)))
{
- nSolarYear = nLYear + 1;
- nSolarDay -= (fLeap + 365);
+ solarYear = lunarYear + 1;
+ solarDay -= (365 + (isLeapYear ? 1 : 0));
}
else
{
- nSolarYear = nLYear;
+ solarYear = lunarYear;
}
- for (nSolarMonth = 1; nSolarMonth < 12; nSolarMonth++)
+ for (solarMonth = 1; solarMonth < 12; solarMonth++)
{
- if (days[nSolarMonth] >= nSolarDay)
+ if (days[solarMonth] >= solarDay)
+ {
break;
+ }
}
- nSolarDay -= days[nSolarMonth - 1];
+ solarDay -= days[solarMonth - 1];
return true;
}
- internal DateTime LunarToTime(DateTime time, int year, int month, int day)
+ private DateTime LunarToTime(DateTime time, int year, int month, int day)
{
- int gy = 0; int gm = 0; int gd = 0;
- LunarToGregorian(year, month, day, ref gy, ref gm, ref gd);
- return (GregorianCalendar.GetDefaultInstance().ToDateTime(gy, gm, gd, time.Hour, time.Minute, time.Second, time.Millisecond));
+ LunarToGregorian(year, month, day, out int gy, out int gm, out int gd);
+ return GregorianCalendar.GetDefaultInstance().ToDateTime(gy, gm, gd, time.Hour, time.Minute, time.Second, time.Millisecond);
}
- internal void TimeToLunar(DateTime time, ref int year, ref int month, ref int day)
+ private void TimeToLunar(DateTime time, out int year, out int month, out int day)
{
- int gy = 0; int gm = 0; int gd = 0;
-
- Calendar Greg = GregorianCalendar.GetDefaultInstance();
- gy = Greg.GetYear(time);
- gm = Greg.GetMonth(time);
- gd = Greg.GetDayOfMonth(time);
+ Calendar gregorianCalendar = GregorianCalendar.GetDefaultInstance();
+ int gy = gregorianCalendar.GetYear(time);
+ int gm = gregorianCalendar.GetMonth(time);
+ int gd = gregorianCalendar.GetDayOfMonth(time);
- GregorianToLunar(gy, gm, gd, ref year, ref month, ref day);
+ GregorianToLunar(gy, gm, gd, out year, out month, out day);
}
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding the given number of
+ /// months to the specified DateTime. The result is computed by incrementing
+ /// (or decrementing) the year and month parts of the specified DateTime by
+ /// value months, and, if required, adjusting the day part of the
+ /// resulting date downwards to the last day of the resulting month in the
+ /// resulting year. The time-of-day part of the result is the same as the
+ /// time-of-day part of the specified DateTime.
+ /// </summary>
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException(
- nameof(months),
- SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
+ nameof(months),
+ months,
+ SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
CheckTicksRange(time.Ticks);
-
- int y = 0; int m = 0; int d = 0;
- TimeToLunar(time, ref y, ref m, ref d);
+ TimeToLunar(time, out int y, out int m, out int d);
int i = m + months;
if (i > 0)
@@ -478,13 +471,10 @@ namespace System.Globalization
return (dt);
}
-
public override DateTime AddYears(DateTime time, int years)
{
CheckTicksRange(time.Ticks);
-
- int y = 0; int m = 0; int d = 0;
- TimeToLunar(time, ref y, ref m, ref d);
+ TimeToLunar(time, out int y, out int m, out int d);
y += years;
@@ -493,27 +483,25 @@ namespace System.Globalization
m = 12;
d = InternalGetDaysInMonth(y, m);
}
- int DaysInMonths = InternalGetDaysInMonth(y, m);
- if (d > DaysInMonths)
+ int daysInMonths = InternalGetDaysInMonth(y, m);
+ if (d > daysInMonths)
{
- d = DaysInMonths;
+ d = daysInMonths;
}
DateTime dt = LunarToTime(time, y, m, d);
CheckAddResult(dt.Ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (dt);
+ return dt;
}
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and [354|355 |383|384].
- //
-
+ /// <summary>
+ /// Returns the day-of-year part of the specified DateTime. The returned value
+ /// is an integer between 1 and [354|355 |383|384].
+ /// </summary>
public override int GetDayOfYear(DateTime time)
{
CheckTicksRange(time.Ticks);
-
- int y = 0; int m = 0; int d = 0;
- TimeToLunar(time, ref y, ref m, ref d);
+ TimeToLunar(time, out int y, out int m, out int d);
for (int i = 1; i < m; i++)
{
@@ -522,88 +510,85 @@ namespace System.Globalization
return d;
}
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 29 or 30.
- //
-
+ /// <summary>
+ /// Returns the day-of-month part of the specified DateTime. The returned
+ /// value is an integer between 1 and 29 or 30.
+ /// </summary>
public override int GetDayOfMonth(DateTime time)
{
CheckTicksRange(time.Ticks);
-
- int y = 0; int m = 0; int d = 0;
- TimeToLunar(time, ref y, ref m, ref d);
+ TimeToLunar(time, out int y, out int m, out int d);
return d;
}
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
+ /// <summary>
+ /// Returns the number of days in the year given by the year argument for the current era.
+ /// </summary>
public override int GetDaysInYear(int year, int era)
{
year = CheckYearRange(year, era);
- int Days = 0;
+ int days = 0;
int monthsInYear = InternalIsLeapYear(year) ? 13 : 12;
while (monthsInYear != 0)
- Days += InternalGetDaysInMonth(year, monthsInYear--);
+ {
+ days += InternalGetDaysInMonth(year, monthsInYear--);
+ }
- return Days;
+ return days;
}
- // Returns the month part of the specified DateTime. The returned value is an
- // integer between 1 and 13.
- //
-
+ /// <summary>
+ /// Returns the month part of the specified DateTime.
+ /// The returned value is an integer between 1 and 13.
+ /// </summary>
public override int GetMonth(DateTime time)
{
CheckTicksRange(time.Ticks);
-
- int y = 0; int m = 0; int d = 0;
- TimeToLunar(time, ref y, ref m, ref d);
+ TimeToLunar(time, out int y, out int m, out int d);
return m;
}
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between 1 and MaxCalendarYear.
- //
-
+ /// <summary>
+ /// Returns the year part of the specified DateTime.
+ /// The returned value is an integer between 1 and MaxCalendarYear.
+ /// </summary>
public override int GetYear(DateTime time)
{
CheckTicksRange(time.Ticks);
-
- int y = 0; int m = 0; int d = 0;
- TimeToLunar(time, ref y, ref m, ref d);
+ TimeToLunar(time, out int y, out int m, out int d);
return GetYear(y, time);
}
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
+ /// <summary>
+ /// Returns the day-of-week part of the specified DateTime. The returned value
+ /// is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
+ /// Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
+ /// Thursday, 5 indicates Friday, and 6 indicates Saturday.
+ /// </summary>
public override DayOfWeek GetDayOfWeek(DateTime time)
{
CheckTicksRange(time.Ticks);
- return ((DayOfWeek)((int)(time.Ticks / Calendar.TicksPerDay + 1) % 7));
+ return (DayOfWeek)((int)(time.Ticks / Calendar.TicksPerDay + 1) % 7);
}
- // Returns the number of months in the specified year and era.
-
+ /// <summary>
+ /// Returns the number of months in the specified year and era.
+ /// </summary>
public override int GetMonthsInYear(int year, int era)
{
year = CheckYearRange(year, era);
- return (InternalIsLeapYear(year) ? 13 : 12);
+ return InternalIsLeapYear(year) ? 13 : 12;
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given day in the specified era is a leap day.
+ /// This method returns true if the date is a leap day, or false if not.
+ /// </summary>
public override bool IsLeapDay(int year, int month, int day, int era)
{
year = CheckYearMonthRange(year, month, era);
@@ -612,92 +597,93 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
+
int m = GetYearInfo(year, LeapMonth);
- return ((m != 0) && (month == (m + 1)));
+ return (m != 0) && (month == (m + 1));
}
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given month in the specified era is a leap month.
+ /// This method returns true if month is a leap month, or false if not.
+ /// </summary>
public override bool IsLeapMonth(int year, int month, int era)
{
year = CheckYearMonthRange(year, month, era);
int m = GetYearInfo(year, LeapMonth);
- return ((m != 0) && (month == (m + 1)));
+ return (m != 0) && (month == (m + 1));
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this this year is not a leap year.
- //
-
+ /// <summary>
+ /// Returns the leap month in a calendar year of the specified era. This method returns 0
+ /// if this this year is not a leap year.
+ /// </summary>
public override int GetLeapMonth(int year, int era)
{
year = CheckYearRange(year, era);
int month = GetYearInfo(year, LeapMonth);
- if (month > 0)
- {
- return (month + 1);
- }
- return 0;
+ return month > 0 ? month + 1 : 0;
}
internal bool InternalIsLeapYear(int year)
{
- return (GetYearInfo(year, LeapMonth) != 0);
+ return GetYearInfo(year, LeapMonth) != 0;
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
+ /// <summary>
+ /// Checks whether a given year in the specified era is a leap year.
+ /// This method returns true if year is a leap year, or false if not.
+ /// </summary>
public override bool IsLeapYear(int year, int era)
{
year = CheckYearRange(year, era);
return InternalIsLeapYear(year);
}
- private const int DEFAULT_GREGORIAN_TWO_DIGIT_YEAR_MAX = 2029;
-
+ private const int DefaultGregorianTwoDigitYearMax = 2029;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(BaseCalendarID, GetYear(new DateTime(DEFAULT_GREGORIAN_TWO_DIGIT_YEAR_MAX, 1, 1)));
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(BaseCalendarID, GetYear(new DateTime(DefaultGregorianTwoDigitYearMax, 1, 1)));
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
if (value < 99 || value > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(value),
- SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxCalendarYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxCalendarYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
+ throw new ArgumentOutOfRangeException(
+ nameof(year),
+ year,
SR.ArgumentOutOfRange_NeedNonNegNum);
}
year = base.ToFourDigitYear(year);
CheckYearRange(year, CurrentEra);
- return (year);
+ return year;
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
index 6b08ee5405..ebc5a54f40 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
@@ -2,136 +2,80 @@
// 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.Globalization;
-using System.Threading;
-
namespace System.Globalization
{
- // This calendar recognizes two era values:
- // 0 CurrentEra (AD)
- // 1 BeforeCurrentEra (BC)
+ /// <remarks>
+ /// This calendar recognizes two era values:
+ /// 0 CurrentEra (AD)
+ /// 1 BeforeCurrentEra (BC)
+ /// </remarks>
public class GregorianCalendar : Calendar
{
- /*
- A.D. = anno Domini
- */
-
public const int ADEra = 1;
- //
// This is the min Gregorian year can be represented by the DateTime class.
// The limitation is derived from the DateTime class.
- //
internal const int MinYear = 1;
- //
// This is the max Gregorian year can be represented by the DateTime class.
// The limitation is derived from the DateTime class.
- //
internal const int MaxYear = 9999;
- internal GregorianCalendarTypes m_type;
+ private GregorianCalendarTypes _type;
- internal static readonly int[] DaysToMonth365 =
- {
- 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
- };
+ private static readonly int[] DaysToMonth365 = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
- internal static readonly int[] DaysToMonth366 =
- {
- 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366
- };
+ private static readonly int[] DaysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
private static volatile Calendar s_defaultInstance;
+ public override DateTime MinSupportedDateTime => DateTime.MinValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (DateTime.MinValue);
- }
- }
+ public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
-
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
-
- /*=================================GetDefaultInstance==========================
- **Action: Internal method to provide a default intance of GregorianCalendar. Used by NLS+ implementation
- ** and other calendars.
- **Returns:
- **Arguments:
- **Exceptions:
- ============================================================================*/
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
+ /// <summary>
+ /// Internal method to provide a default intance of GregorianCalendar.
+ /// Used by NLS+ implementation
+ /// </summary>
internal static Calendar GetDefaultInstance()
{
- if (s_defaultInstance == null)
- {
- s_defaultInstance = new GregorianCalendar();
- }
- return (s_defaultInstance);
+ return s_defaultInstance ?? (s_defaultInstance = new GregorianCalendar());
}
- // Construct an instance of gregorian calendar.
-
- public GregorianCalendar() :
- this(GregorianCalendarTypes.Localized)
+ public GregorianCalendar() : this(GregorianCalendarTypes.Localized)
{
}
-
public GregorianCalendar(GregorianCalendarTypes type)
{
- if ((int)type < (int)GregorianCalendarTypes.Localized || (int)type > (int)GregorianCalendarTypes.TransliteratedFrench)
+ if (type < GregorianCalendarTypes.Localized || type > GregorianCalendarTypes.TransliteratedFrench)
{
throw new ArgumentOutOfRangeException(
- nameof(type),
- SR.Format(SR.ArgumentOutOfRange_Range,
- GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
+ nameof(type),
+ type,
+ SR.Format(SR.ArgumentOutOfRange_Range, GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
}
- this.m_type = type;
+
+ _type = type;
}
public virtual GregorianCalendarTypes CalendarType
{
- get
- {
- return (m_type);
- }
-
+ get => _type;
set
{
VerifyWritable();
-
- switch (value)
+ if (value < GregorianCalendarTypes.Localized || value > GregorianCalendarTypes.TransliteratedFrench)
{
- case GregorianCalendarTypes.Localized:
- case GregorianCalendarTypes.USEnglish:
- case GregorianCalendarTypes.MiddleEastFrench:
- case GregorianCalendarTypes.Arabic:
- case GregorianCalendarTypes.TransliteratedEnglish:
- case GregorianCalendarTypes.TransliteratedFrench:
- m_type = value;
- break;
-
- default:
- throw new ArgumentOutOfRangeException("m_type", SR.ArgumentOutOfRange_Enum);
+ throw new ArgumentOutOfRangeException(
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, GregorianCalendarTypes.Localized, GregorianCalendarTypes.TransliteratedFrench));
}
+
+ _type = value;
}
}
@@ -143,29 +87,20 @@ namespace System.Globalization
// we can support the Transliterated Gregorian calendar.
// DateTimeFormatInfo will use this ID to get formatting information about
// the calendar.
- return ((CalendarId)m_type);
+ return ((CalendarId)_type);
}
}
-
- /*=================================GetAbsoluteDate==========================
- **Action: Gets the absolute date for the given Gregorian date. The absolute date means
- ** the number of days from January 1st, 1 A.D.
- **Returns: the absolute date
- **Arguments:
- ** year the Gregorian year
- ** month the Gregorian month
- ** day the day
- **Exceptions:
- ** ArgumentOutOfRangException if year, month, day value is valid.
- **Note:
- ** This is an internal method used by DateToTicks() and the calculations of Hijri and Hebrew calendars.
- ** Number of Days in Prior Years (both common and leap years) +
- ** Number of Days in Prior Months of Current Year +
- ** Number of Days in Current Month
- **
- ============================================================================*/
-
+ /// <summary>
+ /// Gets the absolute date for the given Gregorian date. The absolute date means
+ /// the number of days from January 1st, 1 A.D.
+ /// </summary>
+ /// <remarks>
+ /// This is an internal method used by DateToTicks() and the calculations of Hijri and Hebrew calendars.
+ /// Number of Days in Prior Years (both common and leap years) +
+ /// Number of Days in Prior Months of Current Year +
+ /// Number of Days in Current Month
+ /// </remarks>
internal static long GetAbsoluteDate(int year, int month, int day)
{
if (year >= 1 && year <= MaxYear && month >= 1 && month <= 12)
@@ -174,50 +109,50 @@ namespace System.Globalization
if (day >= 1 && (day <= days[month] - days[month - 1]))
{
int y = year - 1;
- int absoluteDate = y * 365 + y / 4 - y / 100 + y / 400 + days[month - 1] + day - 1;
- return (absoluteDate);
+ return y * 365 + y / 4 - y / 100 + y / 400 + days[month - 1] + day - 1;
}
}
+
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
- // Returns the tick count corresponding to the given year, month, and day.
- // Will check the if the parameters are valid.
+ /// <summary>
+ /// Returns the tick count corresponding to the given year, month, and day.
+ /// Will check the if the parameters are valid.
+ /// </summary>
internal virtual long DateToTicks(int year, int month, int day)
{
return (GetAbsoluteDate(year, month, day) * TicksPerDay);
}
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
- // In more precise terms, considering the specified DateTime to be of the
- // form y / m / d + t, where y is the
- // year, m is the month, d is the day, and t is the
- // time-of-day, the result is y1 / m1 / d1 + t,
- // where y1 and m1 are computed by adding value months
- // to y and m, and d1 is the largest value less than
- // or equal to d that denotes a valid day in month m1 of year
- // y1.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding the given number of
+ /// months to the specified DateTime. The result is computed by incrementing
+ /// (or decrementing) the year and month parts of the specified DateTime by
+ /// value months, and, if required, adjusting the day part of the
+ /// resulting date downwards to the last day of the resulting month in the
+ /// resulting year. The time-of-day part of the result is the same as the
+ /// time-of-day part of the specified DateTime.
+ ///
+ /// In more precise terms, considering the specified DateTime to be of the
+ /// form y / m / d + t, where y is the
+ /// year, m is the month, d is the day, and t is the
+ /// time-of-day, the result is y1 / m1 / d1 + t,
+ /// where y1 and m1 are computed by adding value months
+ /// to y and m, and d1 is the largest value less than
+ /// or equal to d that denotes a valid day in month m1 of year
+ /// y1.
+ /// </summary>
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException(
- nameof(months),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- -120000,
- 120000));
+ nameof(months),
+ months,
+ SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
+
time.GetDatePart(out int y, out int m, out int d);
int i = m - 1 + months;
if (i >= 0)
@@ -230,6 +165,7 @@ namespace System.Globalization
m = 12 + (i + 1) % 12;
y = y + (i - 11) / 12;
}
+
int[] daysArray = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) ? DaysToMonth366 : DaysToMonth365;
int days = (daysArray[m] - daysArray[m - 1]);
@@ -240,159 +176,136 @@ namespace System.Globalization
long ticks = DateToTicks(y, m, d) + time.Ticks % TicksPerDay;
Calendar.CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (new DateTime(ticks));
+ return new DateTime(ticks);
}
-
- // Returns the DateTime resulting from adding the given number of
- // years to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year part of the specified DateTime by value
- // years. If the month and day of the specified DateTime is 2/29, and if the
- // resulting year is not a leap year, the month and day of the resulting
- // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
- // parts of the result are the same as those of the specified DateTime.
- //
-
+ /// <summary>
+ /// Returns the DateTime resulting from adding the given number of
+ /// years to the specified DateTime. The result is computed by incrementing
+ /// (or decrementing) the year part of the specified DateTime by value
+ /// years. If the month and day of the specified DateTime is 2/29, and if the
+ /// resulting year is not a leap year, the month and day of the resulting
+ /// DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
+ /// parts of the result are the same as those of the specified DateTime.
+ /// </summary>
public override DateTime AddYears(DateTime time, int years)
{
- return (AddMonths(time, years * 12));
+ return AddMonths(time, years * 12);
}
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 31.
- //
-
- public override int GetDayOfMonth(DateTime time)
- {
- return time.Day;
- }
-
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
+ /// <summary>
+ /// Returns the day-of-month part of the specified DateTime. The returned
+ /// value is an integer between 1 and 31.
+ /// </summary>
+ public override int GetDayOfMonth(DateTime time) => time.Day;
+
+ /// <summary>
+ /// Returns the day-of-week part of the specified DateTime. The returned value
+ /// is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
+ /// Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
+ /// Thursday, 5 indicates Friday, and 6 indicates Saturday.
+ /// </summary>
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7));
- }
-
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and 366.
- //
-
- public override int GetDayOfYear(DateTime time)
- {
- return time.DayOfYear;
+ return (DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7);
}
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
+ /// <summary>
+ /// Returns the day-of-year part of the specified DateTime. The returned value
+ /// is an integer between 1 and 366.
+ /// </summary>
+ public override int GetDayOfYear(DateTime time) => time.DayOfYear;
+ /// <summary>
+ /// Returns the number of days in the month given by the year and
+ /// month arguments.
+ /// </summary>
public override int GetDaysInMonth(int year, int month, int era)
{
- if (era == CurrentEra || era == ADEra)
+ if (era != CurrentEra && era != ADEra)
{
- if (year < 1 || year > MaxYear)
- {
- throw new ArgumentOutOfRangeException(nameof(year), SR.Format(SR.ArgumentOutOfRange_Range,
- 1, MaxYear));
- }
- if (month < 1 || month > 12)
- {
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
- }
- int[] days = ((year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? DaysToMonth366 : DaysToMonth365);
- return (days[month] - days[month - 1]);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
- }
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
- public override int GetDaysInYear(int year, int era)
- {
- if (era == CurrentEra || era == ADEra)
+ if (year < 1 || year > MaxYear)
{
- if (year >= 1 && year <= MaxYear)
- {
- return ((year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 366 : 365);
- }
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxYear));
- }
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
- }
-
- // Returns the era for the specified DateTime value.
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ }
+ if (month < 1 || month > 12)
+ {
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
+ }
- public override int GetEra(DateTime time)
- {
- return (ADEra);
+ int[] days = ((year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? DaysToMonth366 : DaysToMonth365);
+ return days[month] - days[month - 1];
}
-
- public override int[] Eras
+ /// <summary>
+ /// Returns the number of days in the year given by the year argument for
+ /// the current era.
+ /// </summary>
+ public override int GetDaysInYear(int year, int era)
{
- get
+ if (era != CurrentEra && era != ADEra)
{
- return (new int[] { ADEra });
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
- }
-
- // Returns the month part of the specified DateTime. The returned value is an
- // integer between 1 and 12.
- //
+ if (year < 1 || year > MaxYear)
+ {
+ throw new ArgumentOutOfRangeException(
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ }
- public override int GetMonth(DateTime time)
- {
- return time.Month;
+ return ((year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 366 : 365);
}
- // Returns the number of months in the specified year and era.
+ public override int GetEra(DateTime time) => ADEra;
+
+ public override int[] Eras => new int[] { ADEra };
+ /// <summary>
+ /// Returns the month part of the specified DateTime.
+ /// The returned value is an integer between 1 and 12.
+ /// </summary>
+ public override int GetMonth(DateTime time) => time.Month;
+
+ /// <summary>
+ /// Returns the number of months in the specified year and era.
+ /// </summary>
public override int GetMonthsInYear(int year, int era)
{
- if (era == CurrentEra || era == ADEra)
+ if (era != CurrentEra && era != ADEra)
+ {
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
+ }
+ if (year < 1 || year > MaxYear)
{
- if (year >= 1 && year <= MaxYear)
- {
- return (12);
- }
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxYear));
- }
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
- }
-
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between 1 and 9999.
- //
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ }
- public override int GetYear(DateTime time)
- {
- return time.Year;
+ return 12;
}
+ /// <summary>
+ /// Returns the year part of the specified DateTime. The returned value is an
+ /// integer between 1 and 9999.
+ /// </summary>
+ public override int GetYear(DateTime time) => time.Year;
+
internal override bool IsValidYear(int year, int era) => year >= 1 && year <= MaxYear;
internal override bool IsValidDay(int year, int month, int day, int era)
{
- if ((era != CurrentEra && era != ADEra) ||
+ if ((era != CurrentEra && era != ADEra) ||
year < 1 || year > MaxYear ||
month < 1 || month > 12 ||
day < 1)
@@ -404,187 +317,181 @@ namespace System.Globalization
return day <= (days[month] - days[month - 1]);
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
+ /// <summary>
+ /// Checks whether a given day in the specified era is a leap day. This method returns true if
+ /// the date is a leap day, or false if not.
+ /// </summary>
public override bool IsLeapDay(int year, int month, int day, int era)
{
if (month < 1 || month > 12)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.Format(SR.ArgumentOutOfRange_Range,
- 1, 12));
+ throw new ArgumentOutOfRangeException(
+ nameof(month),
+ month,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, 12));
}
if (era != CurrentEra && era != ADEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
if (year < 1 || year > MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
-
if (day < 1 || day > GetDaysInMonth(year, month))
{
- throw new ArgumentOutOfRangeException(nameof(day), SR.Format(SR.ArgumentOutOfRange_Range,
- 1, GetDaysInMonth(year, month)));
- }
- if (!IsLeapYear(year))
- {
- return (false);
- }
- if (month == 2 && day == 29)
- {
- return (true);
+ throw new ArgumentOutOfRangeException(
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, GetDaysInMonth(year, month)));
}
- return (false);
- }
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
+ return IsLeapYear(year) && month == 2 && day == 29;
+ }
+ /// <summary>
+ /// Returns the leap month in a calendar year of the specified era.
+ /// This method returns 0 if this calendar does not have leap month, or
+ /// this year is not a leap year.
+ /// </summary>
public override int GetLeapMonth(int year, int era)
{
if (era != CurrentEra && era != ADEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
if (year < 1 || year > MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
- return (0);
- }
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
+ return 0;
+ }
+ /// <summary>
+ /// Checks whether a given month in the specified era is a leap month.
+ /// This method returns true if month is a leap month, or false if not.
+ /// </summary>
public override bool IsLeapMonth(int year, int month, int era)
{
if (era != CurrentEra && era != ADEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
-
if (year < 1 || year > MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
-
if (month < 1 || month > 12)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.Format(SR.ArgumentOutOfRange_Range,
- 1, 12));
+ throw new ArgumentOutOfRangeException(
+ nameof(month),
+ month,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, 12));
}
- return (false);
- }
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
+ return false;
+ }
+ /// <summary>
+ /// Checks whether a given year in the specified era is a leap year. This method returns true if
+ /// year is a leap year, or false if not.
+ /// </summary>
public override bool IsLeapYear(int year, int era)
{
- if (era == CurrentEra || era == ADEra)
+ if (era != CurrentEra && era != ADEra)
+ {
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
+ }
+ if (year < 1 || year > MaxYear)
{
- if (year >= 1 && year <= MaxYear)
- {
- return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
- }
-
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
- }
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
+ return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
+ }
+ /// <summary>
+ /// Returns the date and time converted to a DateTime value.
+ /// Throws an exception if the n-tuple is invalid.
+ /// </summary>
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
- if (era == CurrentEra || era == ADEra)
+ if (era != CurrentEra && era != ADEra)
{
- return new DateTime(year, month, day, hour, minute, second, millisecond);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+
+ return new DateTime(year, month, day, hour, minute, second, millisecond);
}
internal override bool TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result)
{
- if (era == CurrentEra || era == ADEra)
+ if (era != CurrentEra && era != ADEra)
{
- return DateTime.TryCreate(year, month, day, hour, minute, second, millisecond, out result);
+ result = DateTime.MinValue;
+ return false;
}
- result = DateTime.MinValue;
- return false;
+
+ return DateTime.TryCreate(year, month, day, hour, minute, second, millisecond, out result);
}
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 2029;
+ private const int DefaultTwoDigitYearMax = 2029;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
if (value < 99 || value > MaxYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- MaxYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxYear));
}
- twoDigitYearMax = value;
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
-
if (year > MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, 1, MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
- return (base.ToFourDigitYear(year));
+
+ return base.ToFourDigitYear(year);
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs
index 06807811e2..3b8a77a99b 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs
@@ -6,72 +6,63 @@ using System.Diagnostics;
namespace System.Globalization
{
- ////////////////////////////////////////////////////////////////////////////
- //
- // Rules for the Hebrew calendar:
- // - The Hebrew calendar is both a Lunar (months) and Solar (years)
- // calendar, but allows for a week of seven days.
- // - Days begin at sunset.
- // - Leap Years occur in the 3, 6, 8, 11, 14, 17, & 19th years of a
- // 19-year cycle. Year = leap iff ((7y+1) mod 19 < 7).
- // - There are 12 months in a common year and 13 months in a leap year.
- // - In a common year, the 6th month, Adar, has 29 days. In a leap
- // year, the 6th month, Adar I, has 30 days and the leap month,
- // Adar II, has 29 days.
- // - Common years have 353-355 days. Leap years have 383-385 days.
- // - The Hebrew new year (Rosh HaShanah) begins on the 1st of Tishri,
- // the 7th month in the list below.
- // - The new year may not begin on Sunday, Wednesday, or Friday.
- // - If the new year would fall on a Tuesday and the conjunction of
- // the following year were at midday or later, the new year is
- // delayed until Thursday.
- // - If the new year would fall on a Monday after a leap year, the
- // new year is delayed until Tuesday.
- // - The length of the 8th and 9th months vary from year to year,
- // depending on the overall length of the year.
- // - The length of a year is determined by the dates of the new
- // years (Tishri 1) preceding and following the year in question.
- // - The 2th month is long (30 days) if the year has 355 or 385 days.
- // - The 3th month is short (29 days) if the year has 353 or 383 days.
- // - The Hebrew months are:
- // 1. Tishri (30 days)
- // 2. Heshvan (29 or 30 days)
- // 3. Kislev (29 or 30 days)
- // 4. Teveth (29 days)
- // 5. Shevat (30 days)
- // 6. Adar I (30 days)
- // 7. Adar {II} (29 days, this only exists if that year is a leap year)
- // 8. Nisan (30 days)
- // 9. Iyyar (29 days)
- // 10. Sivan (30 days)
- // 11. Tammuz (29 days)
- // 12. Av (30 days)
- // 13. Elul (29 days)
- //
- ////////////////////////////////////////////////////////////////////////////
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1583/01/01 2239/09/29
- ** Hebrew 5343/04/07 5999/13/29
- */
-
- // Includes CHebrew implemetation;i.e All the code necessary for converting
- // Gregorian to Hebrew Lunar from 1583 to 2239.
-
-
+ /// <remarks>
+ /// Rules for the Hebrew calendar:
+ /// - The Hebrew calendar is both a Lunar (months) and Solar (years)
+ /// calendar, but allows for a week of seven days.
+ /// - Days begin at sunset.
+ /// - Leap Years occur in the 3, 6, 8, 11, 14, 17, &amp; 19th years of a
+ /// 19-year cycle. Year = leap iff ((7y+1) mod 19 &lt; 7).
+ /// - There are 12 months in a common year and 13 months in a leap year.
+ /// - In a common year, the 6th month, Adar, has 29 days. In a leap
+ /// year, the 6th month, Adar I, has 30 days and the leap month,
+ /// Adar II, has 29 days.
+ /// - Common years have 353-355 days. Leap years have 383-385 days.
+ /// - The Hebrew new year (Rosh HaShanah) begins on the 1st of Tishri,
+ /// the 7th month in the list below.
+ /// - The new year may not begin on Sunday, Wednesday, or Friday.
+ /// - If the new year would fall on a Tuesday and the conjunction of
+ /// the following year were at midday or later, the new year is
+ /// delayed until Thursday.
+ /// - If the new year would fall on a Monday after a leap year, the
+ /// new year is delayed until Tuesday.
+ /// - The length of the 8th and 9th months vary from year to year,
+ /// depending on the overall length of the year.
+ /// - The length of a year is determined by the dates of the new
+ /// years (Tishri 1) preceding and following the year in question.
+ /// - The 2th month is long (30 days) if the year has 355 or 385 days.
+ /// - The 3th month is short (29 days) if the year has 353 or 383 days.
+ /// - The Hebrew months are:
+ /// 1. Tishri (30 days)
+ /// 2. Heshvan (29 or 30 days)
+ /// 3. Kislev (29 or 30 days)
+ /// 4. Teveth (29 days)
+ /// 5. Shevat (30 days)
+ /// 6. Adar I (30 days)
+ /// 7. Adar {II} (29 days, this only exists if that year is a leap year)
+ /// 8. Nisan (30 days)
+ /// 9. Iyyar (29 days)
+ /// 10. Sivan (30 days)
+ /// 11. Tammuz (29 days)
+ /// 12. Av (30 days)
+ /// 13. Elul (29 days)
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1583/01/01 2239/09/29
+ /// Hebrew 5343/04/07 5999/13/29
+ ///
+ /// Includes CHebrew implemetation;i.e All the code necessary for converting
+ /// Gregorian to Hebrew Lunar from 1583 to 2239.
+ /// </remarks>
public class HebrewCalendar : Calendar
{
public static readonly int HebrewEra = 1;
- internal const int DatePartYear = 0;
- internal const int DatePartDayOfYear = 1;
- internal const int DatePartMonth = 2;
- internal const int DatePartDay = 3;
- internal const int DatePartDayOfWeek = 4;
+ private const int DatePartYear = 0;
+ private const int DatePartMonth = 2;
+ private const int DatePartDay = 3;
- //
// Hebrew Translation Table.
//
// This table is used to get the following Hebrew calendar information for a
@@ -84,59 +75,52 @@ namespace System.Globalization
// by special values (numbers above 29 and below 1).
// 3. The type of the Hebrew year for a given Gregorian year.
//
-
- /*
- More notes:
-
- This table includes 2 numbers for each year.
- The offset into the table determines the year. (offset 0 is Gregorian year 1500)
- 1st number determines the day of the Hebrew month coresponeds to January 1st.
- 2nd number determines the type of the Hebrew year. (the type determines how
- many days are there in the year.)
-
- normal years : 1 = 353 days 2 = 354 days 3 = 355 days.
- Leap years : 4 = 383 5 384 6 = 385 days.
-
- A 99 means the year is not supported for translation.
- for convenience the table was defined for 750 year,
- but only 640 years are supported. (from 1583 to 2239)
- the years before 1582 (starting of Georgian calendar)
- and after 2239, are filled with 99.
-
- Greogrian January 1st falls usually in Tevet (4th month). Tevet has always 29 days.
- That's why, there no nead to specify the lunar month in the table.
- There are exceptions, these are coded by giving numbers above 29 and below 1.
- Actual decoding is takenig place whenever fetching information from the table.
- The function for decoding is in GetLunarMonthDay().
-
- Example:
- The data for 2000 - 2005 A.D. is:
-
- 23,6,6,1,17,2,27,6,7,3, // 2000 - 2004
-
- For year 2000, we know it has a Hebrew year type 6, which means it has 385 days.
- And 1/1/2000 A.D. is Hebrew year 5760, 23rd day of 4th month.
- */
-
+ // More notes:
+ // This table includes 2 numbers for each year.
+ // The offset into the table determines the year. (offset 0 is Gregorian year 1500)
+ // 1st number determines the day of the Hebrew month coresponeds to January 1st.
+ // 2nd number determines the type of the Hebrew year. (the type determines how
+ // many days are there in the year.)
+ //
+ // normal years : 1 = 353 days 2 = 354 days 3 = 355 days.
+ // Leap years : 4 = 383 5 384 6 = 385 days.
+ //
+ // A 99 means the year is not supported for translation.
+ // for convenience the table was defined for 750 year,
+ // but only 640 years are supported. (from 1583 to 2239)
+ // the years before 1582 (starting of Georgian calendar)
+ // and after 2239, are filled with 99.
+ //
+ // Greogrian January 1st falls usually in Tevet (4th month). Tevet has always 29 days.
+ // That's why, there no nead to specify the lunar month in the table.
+ // There are exceptions, these are coded by giving numbers above 29 and below 1.
+ // Actual decoding is takenig place whenever fetching information from the table.
+ // The function for decoding is in GetLunarMonthDay().
+ //
+ // Example:
+ // The data for 2000 - 2005 A.D. is:
+ // 23,6,6,1,17,2,27,6,7,3, // 2000 - 2004
+ //
+ // For year 2000, we know it has a Hebrew year type 6, which means it has 385 days.
+ // And 1/1/2000 A.D. is Hebrew year 5760, 23rd day of 4th month.
//
// Jewish Era in use today is dated from the supposed year of the
// Creation with its beginning in 3761 B.C.
//
-
// The Hebrew year of Gregorian 1st year AD.
// 0001/01/01 AD is Hebrew 3760/01/01
private const int HebrewYearOf1AD = 3760;
- // The first Gregorian year in HebrewTable.
private const int FirstGregorianTableYear = 1583; // == Hebrew Year 5343
- // The last Gregorian year in HebrewTable.
private const int LastGregorianTableYear = 2239; // == Hebrew Year 5999
- private const int TABLESIZE = (LastGregorianTableYear - FirstGregorianTableYear);
+
+ private const int TableSize = (LastGregorianTableYear - FirstGregorianTableYear);
private const int MinHebrewYear = HebrewYearOf1AD + FirstGregorianTableYear; // == 5343
private const int MaxHebrewYear = HebrewYearOf1AD + LastGregorianTableYear; // == 5999
- private static readonly byte[] s_hebrewTable = {
+ private static readonly byte[] s_hebrewTable =
+ {
7,3,17,3, // 1583-1584 (Hebrew year: 5343 - 5344)
0,4,11,2,21,6,1,3,13,2, // 1585-1589
25,4,5,3,16,2,27,6,9,1, // 1590-1594
@@ -274,11 +258,10 @@ namespace System.Globalization
private const int MaxMonthPlusOne = 14;
- //
// The lunar calendar has 6 different variations of month lengths
// within a year.
- //
- private static readonly byte[] s_lunarMonthLen = {
+ private static readonly byte[] s_lunarMonthLen =
+ {
0,00,00,00,00,00,00,00,00,00,00,00,00,0,
0,30,29,29,29,30,29,30,29,30,29,30,29,0, // 3 common year variations
0,30,29,30,29,30,29,30,29,30,29,30,29,0,
@@ -288,61 +271,23 @@ namespace System.Globalization
0,30,30,30,29,30,30,29,30,29,30,29,30,29
};
- internal static readonly DateTime calendarMinValue = new DateTime(1583, 1, 1);
+ private static readonly DateTime s_calendarMinValue = new DateTime(1583, 1, 1);
+
// Gregorian 2239/9/29 = Hebrew 5999/13/29 (last day in Hebrew year 5999).
// We can only format/parse Hebrew numbers up to 999, so we limit the max range to Hebrew year 5999.
- internal static readonly DateTime calendarMaxValue = new DateTime((new DateTime(2239, 9, 29, 23, 59, 59, 999)).Ticks + 9999);
-
+ private static readonly DateTime s_calendarMaxValue = new DateTime((new DateTime(2239, 9, 29, 23, 59, 59, 999)).Ticks + 9999);
+ public override DateTime MinSupportedDateTime => s_calendarMinValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (calendarMinValue);
- }
- }
+ public override DateTime MaxSupportedDateTime => s_calendarMaxValue;
-
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (calendarMaxValue);
- }
- }
-
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.LunisolarCalendar;
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.LunisolarCalendar;
public HebrewCalendar()
{
}
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.HEBREW);
- }
- }
-
-
- /*=================================CheckHebrewYearValue==========================
- **Action: Check if the Hebrew year value is supported in this class.
- **Returns: None.
- **Arguments: y Hebrew year value
- ** ear Hebrew era value
- **Exceptions: ArgumentOutOfRange_Range if the year value is not supported.
- **Note:
- ** We use a table for the Hebrew calendar calculation, so the year supported is limited.
- ============================================================================*/
+ internal override CalendarId ID => CalendarId.HEBREW;
private static void CheckHebrewYearValue(int y, int era, string varName)
{
@@ -350,129 +295,106 @@ namespace System.Globalization
if (y > MaxHebrewYear || y < MinHebrewYear)
{
throw new ArgumentOutOfRangeException(
- varName,
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MinHebrewYear,
- MaxHebrewYear));
+ varName,
+ y,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinHebrewYear, MaxHebrewYear));
}
}
- /*=================================CheckHebrewMonthValue==========================
- **Action: Check if the Hebrew month value is valid.
- **Returns: None.
- **Arguments: year Hebrew year value
- ** month Hebrew month value
- **Exceptions: ArgumentOutOfRange_Range if the month value is not valid.
- **Note:
- ** Call CheckHebrewYearValue() before calling this to verify the year value is supported.
- ============================================================================*/
-
+ /// <summary>
+ /// Check if the Hebrew month value is valid.
+ /// </summary>
+ /// <remarks>
+ /// Call CheckHebrewYearValue() before calling this to verify the year value is supported.
+ /// </remarks>
private void CheckHebrewMonthValue(int year, int month, int era)
{
int monthsInYear = GetMonthsInYear(year, era);
if (month < 1 || month > monthsInYear)
{
throw new ArgumentOutOfRangeException(
- nameof(month),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- monthsInYear));
+ nameof(month),
+ month,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, monthsInYear));
}
}
- /*=================================CheckHebrewDayValue==========================
- **Action: Check if the Hebrew day value is valid.
- **Returns: None.
- **Arguments: year Hebrew year value
- ** month Hebrew month value
- ** day Hebrew day value.
- **Exceptions: ArgumentOutOfRange_Range if the day value is not valid.
- **Note:
- ** Call CheckHebrewYearValue()/CheckHebrewMonthValue() before calling this to verify the year/month values are valid.
- ============================================================================*/
-
+ /// <summary>
+ /// Check if the Hebrew day value is valid.
+ /// </summary>
+ /// <remarks>
+ /// Call CheckHebrewYearValue()/CheckHebrewMonthValue() before calling this to verify the year/month values are valid.
+ /// </remarks>
private void CheckHebrewDayValue(int year, int month, int day, int era)
{
int daysInMonth = GetDaysInMonth(year, month, era);
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- daysInMonth));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, daysInMonth));
}
}
- internal static void CheckEraRange(int era)
+ private static void CheckEraRange(int era)
{
if (era != CurrentEra && era != HebrewEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
}
private static void CheckTicksRange(long ticks)
{
- if (ticks < calendarMinValue.Ticks || ticks > calendarMaxValue.Ticks)
+ if (ticks < s_calendarMinValue.Ticks || ticks > s_calendarMaxValue.Ticks)
{
throw new ArgumentOutOfRangeException(
- "time",
- // Print out the date in Gregorian using InvariantCulture since the DateTime is based on GreograinCalendar.
- string.Format(
- CultureInfo.InvariantCulture,
- SR.ArgumentOutOfRange_CalendarRange,
- calendarMinValue,
- calendarMaxValue));
+ "time",
+ ticks,
+ // Print out the date in Gregorian using InvariantCulture since the DateTime is based on GreograinCalendar.
+ string.Format(
+ CultureInfo.InvariantCulture,
+ SR.ArgumentOutOfRange_CalendarRange,
+ s_calendarMinValue,
+ s_calendarMaxValue));
}
}
- internal static int GetResult(__DateBuffer result, int part)
+ private static int GetResult(DateBuffer result, int part)
{
switch (part)
{
case DatePartYear:
- return (result.year);
+ return result.year;
case DatePartMonth:
- return (result.month);
+ return result.month;
case DatePartDay:
- return (result.day);
+ return result.day;
}
throw new InvalidOperationException(SR.InvalidOperation_DateTimeParsing);
}
- /*=================================GetLunarMonthDay==========================
- **Action: Using the Hebrew table (HebrewTable) to get the Hebrew month/day value for Gregorian January 1st
- ** in a given Gregorian year.
- ** Greogrian January 1st falls usually in Tevet (4th month). Tevet has always 29 days.
- ** That's why, there no nead to specify the lunar month in the table. There are exceptions, and these
- ** are coded by giving numbers above 29 and below 1.
- ** Actual decoding is takenig place in the switch statement below.
- **Returns:
- ** The Hebrew year type. The value is from 1 to 6.
- ** normal years : 1 = 353 days 2 = 354 days 3 = 355 days.
- ** Leap years : 4 = 383 5 384 6 = 385 days.
- **Arguments:
- ** gregorianYear The year value in Gregorian calendar. The value should be between 1500 and 2239.
- ** lunarDate Object to take the result of the Hebrew year/month/day.
- **Exceptions:
- ============================================================================*/
-
- internal static int GetLunarMonthDay(int gregorianYear, __DateBuffer lunarDate)
+ /// <summary>
+ /// Using the Hebrew table (HebrewTable) to get the Hebrew month/day value for Gregorian January 1st
+ /// in a given Gregorian year.
+ /// Greogrian January 1st falls usually in Tevet (4th month). Tevet has always 29 days.
+ /// That's why, there no nead to specify the lunar month in the table. There are exceptions, and these
+ /// are coded by giving numbers above 29 and below 1.
+ /// Actual decoding is takenig place in the switch statement below.
+ /// </summary>
+ /// <returns>
+ /// The Hebrew year type. The value is from 1 to 6.
+ /// normal years : 1 = 353 days 2 = 354 days 3 = 355 days.
+ /// Leap years : 4 = 383 5 384 6 = 385 days.
+ /// </returns>
+ internal static int GetLunarMonthDay(int gregorianYear, DateBuffer lunarDate)
{
- //
// Get the offset into the LunarMonthLen array and the lunar day
// for January 1st.
- //
int index = gregorianYear - FirstGregorianTableYear;
- if (index < 0 || index > TABLESIZE)
+ if (index < 0 || index > TableSize)
{
throw new ArgumentOutOfRangeException(nameof(gregorianYear));
}
@@ -481,29 +403,27 @@ namespace System.Globalization
lunarDate.day = s_hebrewTable[index];
// Get the type of the year. The value is from 1 to 6
- int LunarYearType = s_hebrewTable[index + 1];
+ int lunarYearType = s_hebrewTable[index + 1];
- //
// Get the Lunar Month.
- //
switch (lunarDate.day)
{
- case (0): // 1/1 is on Shvat 1
+ case 0: // 1/1 is on Shvat 1
lunarDate.month = 5;
lunarDate.day = 1;
break;
- case (30): // 1/1 is on Kislev 30
+ case 30: // 1/1 is on Kislev 30
lunarDate.month = 3;
break;
- case (31): // 1/1 is on Shvat 2
+ case 31: // 1/1 is on Shvat 2
lunarDate.month = 5;
lunarDate.day = 2;
break;
- case (32): // 1/1 is on Shvat 3
+ case 32: // 1/1 is on Shvat 3
lunarDate.month = 5;
lunarDate.day = 3;
break;
- case (33): // 1/1 is on Kislev 29
+ case 33: // 1/1 is on Kislev 29
lunarDate.month = 3;
lunarDate.day = 29;
break;
@@ -511,12 +431,14 @@ namespace System.Globalization
lunarDate.month = 4;
break;
}
- return (LunarYearType);
- }
- // Returns a given date part of this DateTime. This method is used
- // to compute the year, day-of-year, month, or day part.
+ return lunarYearType;
+ }
+ /// <summary>
+ /// Returns a given date part of this DateTime. This method is used
+ /// to compute the year, day-of-year, month, or day part.
+ /// </summary>
internal virtual int GetDatePart(long ticks, int part)
{
// The Gregorian year, month, day value for ticks.
@@ -524,20 +446,16 @@ namespace System.Globalization
int hebrewYearType; // lunar year type
long AbsoluteDate; // absolute date - absolute date 1/1/1600
- //
- // Make sure we have a valid Gregorian date that will fit into our
- // Hebrew conversion limits.
- //
+ // Make sure we have a valid Gregorian date that will fit into our
+ // Hebrew conversion limits.
CheckTicksRange(ticks);
DateTime time = new DateTime(ticks);
- //
- // Save the Gregorian date values.
- //
+ // Save the Gregorian date values.
time.GetDatePart(out gregorianYear, out gregorianMonth, out gregorianDay);
- __DateBuffer lunarDate = new __DateBuffer(); // lunar month and day for Jan 1
+ DateBuffer lunarDate = new DateBuffer(); // lunar month and day for Jan 1
// From the table looking-up value of HebrewTable[index] (stored in lunarDate.day), we get the the
// lunar month and lunar day where the Gregorian date 1/1 falls.
@@ -545,117 +463,73 @@ namespace System.Globalization
hebrewYearType = GetLunarMonthDay(gregorianYear, lunarDate);
// This is the buffer used to store the result Hebrew date.
- __DateBuffer result = new __DateBuffer();
+ DateBuffer result = new DateBuffer();
- //
// Store the values for the start of the new year - 1/1.
- //
result.year = lunarDate.year;
result.month = lunarDate.month;
result.day = lunarDate.day;
- //
// Get the absolute date from 1/1/1600.
- //
AbsoluteDate = GregorianCalendar.GetAbsoluteDate(gregorianYear, gregorianMonth, gregorianDay);
- //
// If the requested date was 1/1, then we're done.
- //
if ((gregorianMonth == 1) && (gregorianDay == 1))
{
- return (GetResult(result, part));
+ return GetResult(result, part);
}
- //
- // Calculate the number of days between 1/1 and the requested date.
- //
- long NumDays; // number of days since 1/1
- NumDays = AbsoluteDate - GregorianCalendar.GetAbsoluteDate(gregorianYear, 1, 1);
-
- //
- // If the requested date is within the current lunar month, then
- // we're done.
- //
- if ((NumDays + (long)lunarDate.day) <= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month]))
+ // Calculate the number of days between 1/1 and the requested date.
+ long numDays = AbsoluteDate - GregorianCalendar.GetAbsoluteDate(gregorianYear, 1, 1);
+
+ // If the requested date is within the current lunar month, then
+ // we're done.
+ if ((numDays + (long)lunarDate.day) <= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month]))
{
- result.day += (int)NumDays;
- return (GetResult(result, part));
+ result.day += (int)numDays;
+ return GetResult(result, part);
}
- //
- // Adjust for the current partial month.
- //
+ // Adjust for the current partial month.
result.month++;
result.day = 1;
- //
- // Adjust the Lunar Month and Year (if necessary) based on the number
- // of days between 1/1 and the requested date.
- //
- // Assumes Jan 1 can never translate to the last Lunar month, which
- // is true.
- //
- NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month] - lunarDate.day);
- Debug.Assert(NumDays >= 1, "NumDays >= 1");
+ // Adjust the Lunar Month and Year (if necessary) based on the number
+ // of days between 1/1 and the requested date.
+ // Assumes Jan 1 can never translate to the last Lunar month, which
+ // is true.
+ numDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month] - lunarDate.day);
+ Debug.Assert(numDays >= 1, "NumDays >= 1");
// If NumDays is 1, then we are done. Otherwise, find the correct Hebrew month
// and day.
- if (NumDays > 1)
+ if (numDays > 1)
{
- //
- // See if we're on the correct Lunar month.
- //
- while (NumDays > (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month]))
+ // See if we're on the correct Lunar month.
+ while (numDays > (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month]))
{
- //
- // Adjust the number of days and move to the next month.
- //
- NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month++]);
-
- //
- // See if we need to adjust the Year.
- // Must handle both 12 and 13 month years.
- //
+ // Adjust the number of days and move to the next month.
+ numDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month++]);
+
+ // See if we need to adjust the Year.
+ // Must handle both 12 and 13 month years.
if ((result.month > 13) || (s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month] == 0))
{
- //
- // Adjust the Year.
- //
+ // Adjust the Year.
result.year++;
hebrewYearType = s_hebrewTable[(gregorianYear + 1 - FirstGregorianTableYear) * 2 + 1];
- //
- // Adjust the Month.
- //
+ // Adjust the Month.
result.month = 1;
}
}
- //
- // Found the right Lunar month.
- //
- result.day += (int)(NumDays - 1);
+
+ // Found the right Lunar month.
+ result.day += (int)(numDays - 1);
}
- return (GetResult(result, part));
- }
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
- // In more precise terms, considering the specified DateTime to be of the
- // form y / m / d + t, where y is the
- // year, m is the month, d is the day, and t is the
- // time-of-day, the result is y1 / m1 / d1 + t,
- // where y1 and m1 are computed by adding value months
- // to y and m, and d1 is the largest value less than
- // or equal to d that denotes a valid day in month m1 of year
- // y1.
- //
+ return GetResult(result, part);
+ }
public override DateTime AddMonths(DateTime time, int months)
{
@@ -665,7 +539,6 @@ namespace System.Globalization
int m = GetDatePart(time.Ticks, DatePartMonth);
int d = GetDatePart(time.Ticks, DatePartDay);
-
int monthsInYear;
int i;
if (months >= 0)
@@ -700,29 +573,17 @@ namespace System.Globalization
{
d = days;
}
- return (new DateTime(ToDateTime(y, i, d, 0, 0, 0, 0).Ticks + (time.Ticks % TicksPerDay)));
+
+ return new DateTime(ToDateTime(y, i, d, 0, 0, 0, 0).Ticks + (time.Ticks % TicksPerDay));
}
// We expect ArgumentException and ArgumentOutOfRangeException (which is subclass of ArgumentException)
// If exception is thrown in the calls above, we are out of the supported range of this calendar.
catch (ArgumentException)
{
- throw new ArgumentOutOfRangeException(
- nameof(months),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_AddValue));
+ throw new ArgumentOutOfRangeException(nameof(months), months, SR.ArgumentOutOfRange_AddValue);
}
}
- // Returns the DateTime resulting from adding the given number of
- // years to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year part of the specified DateTime by value
- // years. If the month and day of the specified DateTime is 2/29, and if the
- // resulting year is not a leap year, the month and day of the resulting
- // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
- // parts of the result are the same as those of the specified DateTime.
- //
-
public override DateTime AddYears(DateTime time, int years)
{
int y = GetDatePart(time.Ticks, DatePartYear);
@@ -746,29 +607,19 @@ namespace System.Globalization
long ticks = ToDateTime(y, m, d, 0, 0, 0, 0).Ticks + (time.Ticks % TicksPerDay);
Calendar.CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (new DateTime(ticks));
+ return new DateTime(ticks);
}
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 31.
- //
-
public override int GetDayOfMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDay));
+ return GetDatePart(time.Ticks, DatePartDay);
}
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
// If we calculate back, the Hebrew day of week for Gregorian 0001/1/1 is Monday (1).
// Therfore, the fomula is:
- return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7));
+ return (DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7);
}
internal static int GetHebrewYearType(int year, int era)
@@ -776,13 +627,9 @@ namespace System.Globalization
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]);
+ return s_hebrewTable[(year - HebrewYearOf1AD - FirstGregorianTableYear) * 2 + 1];
}
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and 366.
- //
-
public override int GetDayOfYear(DateTime time)
{
// Get Hebrew year value of the specified time.
@@ -792,7 +639,7 @@ namespace System.Globalization
{
// Gregorian 1583/01/01 corresponds to Hebrew 5343/04/07 (MinSupportedDateTime)
// To figure out the Gregorian date associated with Hebrew 5343/01/01, we need to
- // count the days from 5343/01/01 to 5343/04/07 and subtract that from Gregorian
+ // count the days from 5343/01/01 to 5343/04/07 and subtract that from Gregorian
// 1583/01/01.
// 1. Tishri (30 days)
// 2. Heshvan (30 days since 5343 has 355 days)
@@ -808,12 +655,9 @@ namespace System.Globalization
// following line will fail when year is 5343 (first supported year)
beginOfYearDate = ToDateTime(year, 1, 1, 0, 0, 0, 0, CurrentEra);
}
- return ((int)((time.Ticks - beginOfYearDate.Ticks) / TicksPerDay) + 1);
- }
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
+ return (int)((time.Ticks - beginOfYearDate.Ticks) / TicksPerDay) + 1;
+ }
public override int GetDaysInMonth(int year, int month, int era)
{
@@ -826,13 +670,11 @@ namespace System.Globalization
int monthDays = s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + month];
if (monthDays == 0)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
}
- return (monthDays);
- }
- // Returns the number of days in the year given by the year argument for the current era.
- //
+ return monthDays;
+ }
public override int GetDaysInYear(int year, int era)
{
@@ -845,63 +687,38 @@ namespace System.Globalization
if (LunarYearType < 4)
{
// common year: LunarYearType = 1, 2, 3
- return (352 + LunarYearType);
+ return 352 + LunarYearType;
}
- return (382 + (LunarYearType - 3));
- }
-
- // Returns the era for the specified DateTime value.
- public override int GetEra(DateTime time)
- {
- return (HebrewEra);
+ return 382 + (LunarYearType - 3);
}
+ public override int GetEra(DateTime time) => HebrewEra;
- public override int[] Eras
- {
- get
- {
- return (new int[] { HebrewEra });
- }
- }
-
- // Returns the month part of the specified DateTime. The returned value is an
- // integer between 1 and 12.
- //
+ public override int[] Eras => new int[] { HebrewEra };
public override int GetMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartMonth));
+ return GetDatePart(time.Ticks, DatePartMonth);
}
- // Returns the number of months in the specified year and era.
-
public override int GetMonthsInYear(int year, int era)
{
- return (IsLeapYear(year, era) ? 13 : 12);
+ return IsLeapYear(year, era) ? 13 : 12;
}
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between 1 and 9999.
- //
-
public override int GetYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartYear));
+ return GetDatePart(time.Ticks, DatePartYear);
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
if (IsLeapMonth(year, month, era))
{
// Every day in a leap month is a leap day.
CheckHebrewDayValue(year, month, day, era);
- return (true);
+ return true;
}
else if (IsLeapYear(year, Calendar.CurrentEra))
{
@@ -909,60 +726,44 @@ namespace System.Globalization
// so we should return true for 6/30 if that's in a leap year.
if (month == 6 && day == 30)
{
- return (true);
+ return true;
}
}
+
CheckHebrewDayValue(year, month, day, era);
- return (false);
+ return false;
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
-
public override int GetLeapMonth(int year, int era)
{
// Year/era values are checked in IsLeapYear().
if (IsLeapYear(year, era))
{
// The 7th month in a leap year is a leap month.
- return (7);
+ return 7;
}
- return (0);
+ return 0;
}
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
public override bool IsLeapMonth(int year, int month, int era)
{
// Year/era values are checked in IsLeapYear().
bool isLeapYear = IsLeapYear(year, era);
CheckHebrewMonthValue(year, month, era);
+
// The 7th month in a leap year is a leap month.
- if (isLeapYear)
- {
- if (month == 7)
- {
- return (true);
- }
- }
- return (false);
+ return isLeapYear && month == 7;
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
public override bool IsLeapYear(int year, int era)
{
CheckHebrewYearValue(year, era, nameof(year));
- return (((7 * (long)year + 1) % 19) < 7);
+ return ((7 * (long)year + 1) % 19) < 7;
}
- // (month1, day1) - (month2, day2)
+ /// <summary>
+ /// (month1, day1) - (month2, day2)
+ /// </summary>
private static int GetDayDifference(int lunarYearType, int month1, int day1, int month2, int day2)
{
if (month1 == month2)
@@ -995,58 +796,47 @@ namespace System.Globalization
}
days += day2;
- return (swap ? days : -days);
- }
-
- /*=================================HebrewToGregorian==========================
- **Action: Convert Hebrew date to Gregorian date.
- **Returns:
- **Arguments:
- **Exceptions:
- ** The algorithm is like this:
- ** The hebrew year has an offset to the Gregorian year, so we can guess the Gregorian year for
- ** the specified Hebrew year. That is, GreogrianYear = HebrewYear - FirstHebrewYearOf1AD.
- **
- ** From the Gregorian year and HebrewTable, we can get the Hebrew month/day value
- ** of the Gregorian date January 1st. Let's call this month/day value [hebrewDateForJan1]
- **
- ** If the requested Hebrew month/day is less than [hebrewDateForJan1], we know the result
- ** Gregorian date falls in previous year. So we decrease the Gregorian year value, and
- ** retrieve the Hebrew month/day value of the Gregorian date january 1st again.
- **
- ** Now, we get the answer of the Gregorian year.
- **
- ** The next step is to get the number of days between the requested Hebrew month/day
- ** and [hebrewDateForJan1]. When we get that, we can create the DateTime by adding/subtracting
- ** the ticks value of the number of days.
- **
- ============================================================================*/
-
-
+ return swap ? days : -days;
+ }
+
+ /// <summary>
+ /// Convert Hebrew date to Gregorian date.
+ /// The algorithm is like this:
+ /// The hebrew year has an offset to the Gregorian year, so we can guess the Gregorian year for
+ /// the specified Hebrew year. That is, GreogrianYear = HebrewYear - FirstHebrewYearOf1AD.
+ ///
+ /// From the Gregorian year and HebrewTable, we can get the Hebrew month/day value
+ /// of the Gregorian date January 1st. Let's call this month/day value [hebrewDateForJan1]
+ ///
+ /// If the requested Hebrew month/day is less than [hebrewDateForJan1], we know the result
+ /// Gregorian date falls in previous year. So we decrease the Gregorian year value, and
+ /// retrieve the Hebrew month/day value of the Gregorian date january 1st again.
+ ///
+ /// Now, we get the answer of the Gregorian year.
+ ///
+ /// The next step is to get the number of days between the requested Hebrew month/day
+ /// and [hebrewDateForJan1]. When we get that, we can create the DateTime by adding/subtracting
+ /// the ticks value of the number of days.
+ /// </summary>
private static DateTime HebrewToGregorian(int hebrewYear, int hebrewMonth, int hebrewDay, int hour, int minute, int second, int millisecond)
{
// Get the rough Gregorian year for the specified hebrewYear.
- //
int gregorianYear = hebrewYear - HebrewYearOf1AD;
- __DateBuffer hebrewDateOfJan1 = new __DateBuffer(); // year value is unused.
+ DateBuffer hebrewDateOfJan1 = new DateBuffer(); // year value is unused.
int lunarYearType = GetLunarMonthDay(gregorianYear, hebrewDateOfJan1);
if ((hebrewMonth == hebrewDateOfJan1.month) && (hebrewDay == hebrewDateOfJan1.day))
{
- return (new DateTime(gregorianYear, 1, 1, hour, minute, second, millisecond));
+ return new DateTime(gregorianYear, 1, 1, hour, minute, second, millisecond);
}
int days = GetDayDifference(lunarYearType, hebrewMonth, hebrewDay, hebrewDateOfJan1.month, hebrewDateOfJan1.day);
DateTime gregorianNewYear = new DateTime(gregorianYear, 1, 1);
- return (new DateTime(gregorianNewYear.Ticks + days * TicksPerDay
- + TimeToTicks(hour, minute, second, millisecond)));
+ return new DateTime(gregorianNewYear.Ticks + days * TicksPerDay + TimeToTicks(hour, minute, second, millisecond));
}
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
CheckHebrewYearValue(year, era, nameof(year));
@@ -1054,66 +844,61 @@ namespace System.Globalization
CheckHebrewDayValue(year, month, day, era);
DateTime dt = HebrewToGregorian(year, month, day, hour, minute, second, millisecond);
CheckTicksRange(dt.Ticks);
- return (dt);
+ return dt;
}
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 5790;
-
+ private const int DefaultTwoDigitYearMax = 5790;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
if (value == 99)
{
- // Do nothing here. Year 99 is allowed so that TwoDitYearMax is disabled.
+ // Do nothing here. Year 99 is allowed so that TwoDitYearMax is disabled.
}
else
{
CheckHebrewYearValue(value, HebrewEra, nameof(value));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
if (year < 100)
{
- return (base.ToFourDigitYear(year));
+ return base.ToFourDigitYear(year);
}
if (year > MaxHebrewYear || year < MinHebrewYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MinHebrewYear,
- MaxHebrewYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinHebrewYear, MaxHebrewYear));
}
- return (year);
+ return year;
}
- internal class __DateBuffer
+ internal class DateBuffer
{
internal int year;
internal int month;
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs
index 3eaf3d2539..e773df1376 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs
@@ -2,107 +2,77 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
namespace System.Globalization
{
- ////////////////////////////////////////////////////////////////////////////
- //
- // Rules for the Hijri calendar:
- // - The Hijri calendar is a strictly Lunar calendar.
- // - Days begin at sunset.
- // - Islamic Year 1 (Muharram 1, 1 A.H.) is equivalent to absolute date
- // 227015 (Friday, July 16, 622 C.E. - Julian).
- // - Leap Years occur in the 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, & 29th
- // years of a 30-year cycle. Year = leap iff ((11y+14) mod 30 < 11).
- // - There are 12 months which contain alternately 30 and 29 days.
- // - The 12th month, Dhu al-Hijjah, contains 30 days instead of 29 days
- // in a leap year.
- // - Common years have 354 days. Leap years have 355 days.
- // - There are 10,631 days in a 30-year cycle.
- // - The Islamic months are:
- // 1. Muharram (30 days) 7. Rajab (30 days)
- // 2. Safar (29 days) 8. Sha'ban (29 days)
- // 3. Rabi I (30 days) 9. Ramadan (30 days)
- // 4. Rabi II (29 days) 10. Shawwal (29 days)
- // 5. Jumada I (30 days) 11. Dhu al-Qada (30 days)
- // 6. Jumada II (29 days) 12. Dhu al-Hijjah (29 days) {30}
- //
- // NOTENOTE
- // The calculation of the HijriCalendar is based on the absolute date. And the
- // absolute date means the number of days from January 1st, 1 A.D.
- // Therefore, we do not support the days before the January 1st, 1 A.D.
- //
- ////////////////////////////////////////////////////////////////////////////
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 0622/07/18 9999/12/31
- ** Hijri 0001/01/01 9666/04/03
- */
+ /// <remarks>
+ /// Rules for the Hijri calendar:
+ /// - The Hijri calendar is a strictly Lunar calendar.
+ /// - Days begin at sunset.
+ /// - Islamic Year 1 (Muharram 1, 1 A.H.) is equivalent to absolute date
+ /// 227015 (Friday, July 16, 622 C.E. - Julian).
+ /// - Leap Years occur in the 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, &amp; 29th
+ /// years of a 30-year cycle. Year = leap iff ((11y+14) mod 30 &lt; 11).
+ /// - There are 12 months which contain alternately 30 and 29 days.
+ /// - The 12th month, Dhu al-Hijjah, contains 30 days instead of 29 days
+ /// in a leap year.
+ /// - Common years have 354 days. Leap years have 355 days.
+ /// - There are 10,631 days in a 30-year cycle.
+ /// - The Islamic months are:
+ /// 1. Muharram (30 days) 7. Rajab (30 days)
+ /// 2. Safar (29 days) 8. Sha'ban (29 days)
+ /// 3. Rabi I (30 days) 9. Ramadan (30 days)
+ /// 4. Rabi II (29 days) 10. Shawwal (29 days)
+ /// 5. Jumada I (30 days) 11. Dhu al-Qada (30 days)
+ /// 6. Jumada II (29 days) 12. Dhu al-Hijjah (29 days) {30}
+ ///
+ /// NOTENOTE
+ /// The calculation of the HijriCalendar is based on the absolute date. And the
+ /// absolute date means the number of days from January 1st, 1 A.D.
+ /// Therefore, we do not support the days before the January 1st, 1 A.D.
+ ///
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 0622/07/18 9999/12/31
+ /// Hijri 0001/01/01 9666/04/03
+ /// </remarks>
public partial class HijriCalendar : Calendar
{
public static readonly int HijriEra = 1;
- internal const int DatePartYear = 0;
- internal const int DatePartDayOfYear = 1;
- internal const int DatePartMonth = 2;
- internal const int DatePartDay = 3;
+ private const int DatePartYear = 0;
+ private const int DatePartDayOfYear = 1;
+ private const int DatePartMonth = 2;
+ private const int DatePartDay = 3;
- internal const int MinAdvancedHijri = -2;
- internal const int MaxAdvancedHijri = 2;
+ private const int MinAdvancedHijri = -2;
+ private const int MaxAdvancedHijri = 2;
- internal static readonly int[] HijriMonthDays = { 0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325, 355 };
+ private static readonly int[] s_hijriMonthDays = { 0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325, 355 };
private int _hijriAdvance = int.MinValue;
// DateTime.MaxValue = Hijri calendar (year:9666, month: 4, day: 3).
- internal const int MaxCalendarYear = 9666;
- internal const int MaxCalendarMonth = 4;
- internal const int MaxCalendarDay = 3;
+ private const int MaxCalendarYear = 9666;
+ private const int MaxCalendarMonth = 4;
+
// Hijri calendar (year: 1, month: 1, day:1 ) = Gregorian (year: 622, month: 7, day: 18)
// This is the minimal Gregorian date that we support in the HijriCalendar.
- internal static readonly DateTime calendarMinValue = new DateTime(622, 7, 18);
- internal static readonly DateTime calendarMaxValue = DateTime.MaxValue;
-
+ private static readonly DateTime s_calendarMinValue = new DateTime(622, 7, 18);
+ private static readonly DateTime s_calendarMaxValue = DateTime.MaxValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (calendarMinValue);
- }
- }
+ public override DateTime MinSupportedDateTime => s_calendarMinValue;
+ public override DateTime MaxSupportedDateTime => s_calendarMaxValue;
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (calendarMaxValue);
- }
- }
-
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.LunarCalendar;
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.LunarCalendar;
public HijriCalendar()
{
}
- internal override CalendarId ID
- {
- get
- {
- return CalendarId.HIJRI;
- }
- }
+ internal override CalendarId ID => CalendarId.HIJRI;
protected override int DaysInYearBeforeMinSupportedYear
{
@@ -114,62 +84,30 @@ namespace System.Globalization
}
}
-
-
- /*=================================GetAbsoluteDateHijri==========================
- **Action: Gets the Absolute date for the given Hijri date. The absolute date means
- ** the number of days from January 1st, 1 A.D.
- **Returns:
- **Arguments:
- **Exceptions:
- ============================================================================*/
-
private long GetAbsoluteDateHijri(int y, int m, int d)
{
- return (long)(DaysUpToHijriYear(y) + HijriMonthDays[m - 1] + d - 1 - HijriAdjustment);
+ return (long)(DaysUpToHijriYear(y) + s_hijriMonthDays[m - 1] + d - 1 - HijriAdjustment);
}
- /*=================================DaysUpToHijriYear==========================
- **Action: Gets the total number of days (absolute date) up to the given Hijri Year.
- ** The absolute date means the number of days from January 1st, 1 A.D.
- **Returns: Gets the total number of days (absolute date) up to the given Hijri Year.
- **Arguments: HijriYear year value in Hijri calendar.
- **Exceptions: None
- **Notes:
- ============================================================================*/
-
private long DaysUpToHijriYear(int HijriYear)
{
- long NumDays; // number of absolute days
- int NumYear30; // number of years up to current 30 year cycle
- int NumYearsLeft; // number of years into 30 year cycle
-
- //
- // Compute the number of years up to the current 30 year cycle.
- //
- NumYear30 = ((HijriYear - 1) / 30) * 30;
-
- //
- // Compute the number of years left. This is the number of years
- // into the 30 year cycle for the given year.
- //
- NumYearsLeft = HijriYear - NumYear30 - 1;
-
- //
- // Compute the number of absolute days up to the given year.
- //
- NumDays = ((NumYear30 * 10631L) / 30L) + 227013L;
- while (NumYearsLeft > 0)
+ // Compute the number of years up to the current 30 year cycle.
+ int numYear30 = ((HijriYear - 1) / 30) * 30;
+
+ // Compute the number of years left. This is the number of years
+ // into the 30 year cycle for the given year.
+ int numYearsLeft = HijriYear - numYear30 - 1;
+
+ // Compute the number of absolute days up to the given year.
+ long numDays = ((numYear30 * 10631L) / 30L) + 227013L;
+ while (numYearsLeft > 0)
{
// Common year is 354 days, and leap year is 355 days.
- NumDays += 354 + (IsLeapYear(NumYearsLeft, CurrentEra) ? 1 : 0);
- NumYearsLeft--;
+ numDays += 354 + (IsLeapYear(numYearsLeft, CurrentEra) ? 1 : 0);
+ numYearsLeft--;
}
- //
- // Return the number of absolute days.
- //
- return (NumDays);
+ return numDays;
}
public int HijriAdjustment
@@ -181,39 +119,37 @@ namespace System.Globalization
// Never been set before. Use the system value from registry.
_hijriAdvance = GetHijriDateAdjustment();
}
- return (_hijriAdvance);
+
+ return _hijriAdvance;
}
set
{
- // NOTE: Check the value of Min/MaxAdvancedHijri with Arabic speakers to see if the assumption is good.
if (value < MinAdvancedHijri || value > MaxAdvancedHijri)
{
throw new ArgumentOutOfRangeException(
- "HijriAdjustment",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Bounds_Lower_Upper,
- MinAdvancedHijri,
- MaxAdvancedHijri));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, MinAdvancedHijri, MaxAdvancedHijri));
}
- VerifyWritable();
+ VerifyWritable();
_hijriAdvance = value;
}
}
internal static void CheckTicksRange(long ticks)
{
- if (ticks < calendarMinValue.Ticks || ticks > calendarMaxValue.Ticks)
+ if (ticks < s_calendarMinValue.Ticks || ticks > s_calendarMaxValue.Ticks)
{
throw new ArgumentOutOfRangeException(
- "time",
- string.Format(
- CultureInfo.InvariantCulture,
- SR.ArgumentOutOfRange_CalendarRange,
- calendarMinValue,
- calendarMaxValue));
+ "time",
+ ticks,
+ string.Format(
+ CultureInfo.InvariantCulture,
+ SR.ArgumentOutOfRange_CalendarRange,
+ s_calendarMinValue,
+ s_calendarMaxValue));
}
}
@@ -221,7 +157,7 @@ namespace System.Globalization
{
if (era != CurrentEra && era != HijriEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
}
@@ -232,11 +168,7 @@ namespace System.Globalization
{
throw new ArgumentOutOfRangeException(
nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxCalendarYear));
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarYear));
}
}
@@ -248,151 +180,106 @@ namespace System.Globalization
if (month > MaxCalendarMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(month),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxCalendarMonth));
+ nameof(month),
+ month,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarMonth));
}
}
if (month < 1 || month > 12)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
}
}
- /*=================================GetDatePart==========================
- **Action: Returns a given date part of this <i>DateTime</i>. This method is used
- ** to compute the year, day-of-year, month, or day part.
- **Returns:
- **Arguments:
- **Exceptions: ArgumentException if part is incorrect.
- **Notes:
- ** First, we get the absolute date (the number of days from January 1st, 1 A.C) for the given ticks.
- ** Use the formula (((AbsoluteDate - 227013) * 30) / 10631) + 1, we can a rough value for the Hijri year.
- ** In order to get the exact Hijri year, we compare the exact absolute date for HijriYear and (HijriYear + 1).
- ** From here, we can get the correct Hijri year.
- ============================================================================*/
-
+ /// <summary>
+ /// First, we get the absolute date (the number of days from January 1st, 1 A.C) for the given ticks.
+ /// Use the formula (((AbsoluteDate - 227013) * 30) / 10631) + 1, we can a rough value for the Hijri year.
+ /// In order to get the exact Hijri year, we compare the exact absolute date for HijriYear and (HijriYear + 1).
+ /// From here, we can get the correct Hijri year.
+ /// </summary>
internal virtual int GetDatePart(long ticks, int part)
{
- int HijriYear; // Hijri year
- int HijriMonth; // Hijri month
- int HijriDay; // Hijri day
- long NumDays; // The calculation buffer in number of days.
-
CheckTicksRange(ticks);
- //
- // Get the absolute date. The absolute date is the number of days from January 1st, 1 A.D.
- // 1/1/0001 is absolute date 1.
- //
- NumDays = ticks / GregorianCalendar.TicksPerDay + 1;
+ // Get the absolute date. The absolute date is the number of days from January 1st, 1 A.D.
+ // 1/1/0001 is absolute date 1.
+ long numDays = ticks / GregorianCalendar.TicksPerDay + 1;
- //
// See how much we need to backup or advance
- //
- NumDays += HijriAdjustment;
+ numDays += HijriAdjustment;
- //
- // Calculate the appromixate Hijri Year from this magic formula.
- //
- HijriYear = (int)(((NumDays - 227013) * 30) / 10631) + 1;
+ // Calculate the appromixate Hijri Year from this magic formula.
+ int hijriYear = (int)(((numDays - 227013) * 30) / 10631) + 1;
- long daysToHijriYear = DaysUpToHijriYear(HijriYear); // The absolute date for HijriYear
- long daysOfHijriYear = GetDaysInYear(HijriYear, CurrentEra); // The number of days for (HijriYear+1) year.
+ long daysToHijriYear = DaysUpToHijriYear(hijriYear); // The absolute date for HijriYear
+ long daysOfHijriYear = GetDaysInYear(hijriYear, CurrentEra); // The number of days for (HijriYear+1) year.
- if (NumDays < daysToHijriYear)
+ if (numDays < daysToHijriYear)
{
daysToHijriYear -= daysOfHijriYear;
- HijriYear--;
+ hijriYear--;
}
- else if (NumDays == daysToHijriYear)
+ else if (numDays == daysToHijriYear)
{
- HijriYear--;
- daysToHijriYear -= GetDaysInYear(HijriYear, CurrentEra);
+ hijriYear--;
+ daysToHijriYear -= GetDaysInYear(hijriYear, CurrentEra);
}
else
{
- if (NumDays > daysToHijriYear + daysOfHijriYear)
+ if (numDays > daysToHijriYear + daysOfHijriYear)
{
daysToHijriYear += daysOfHijriYear;
- HijriYear++;
+ hijriYear++;
}
}
if (part == DatePartYear)
{
- return (HijriYear);
+ return hijriYear;
}
- //
// Calculate the Hijri Month.
- //
-
- HijriMonth = 1;
- NumDays -= daysToHijriYear;
+ int hijriMonth = 1;
+ numDays -= daysToHijriYear;
if (part == DatePartDayOfYear)
{
- return ((int)NumDays);
+ return ((int)numDays);
}
- while ((HijriMonth <= 12) && (NumDays > HijriMonthDays[HijriMonth - 1]))
+ while ((hijriMonth <= 12) && (numDays > s_hijriMonthDays[hijriMonth - 1]))
{
- HijriMonth++;
+ hijriMonth++;
}
- HijriMonth--;
+ hijriMonth--;
if (part == DatePartMonth)
{
- return (HijriMonth);
+ return hijriMonth;
}
- //
// Calculate the Hijri Day.
- //
- HijriDay = (int)(NumDays - HijriMonthDays[HijriMonth - 1]);
+ int hijriDay = (int)(numDays - s_hijriMonthDays[hijriMonth - 1]);
if (part == DatePartDay)
{
- return (HijriDay);
+ return hijriDay;
}
+
// Incorrect part value.
throw new InvalidOperationException(SR.InvalidOperation_DateTimeParsing);
}
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
- // In more precise terms, considering the specified DateTime to be of the
- // form y / m / d + t, where y is the
- // year, m is the month, d is the day, and t is the
- // time-of-day, the result is y1 / m1 / d1 + t,
- // where y1 and m1 are computed by adding value months
- // to y and m, and d1 is the largest value less than
- // or equal to d that denotes a valid day in month m1 of year
- // y1.
- //
-
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException(
- nameof(months),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- -120000,
- 120000));
+ nameof(months),
+ months,
+ SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
+
// Get the date in Hijri calendar.
int y = GetDatePart(time.Ticks, DatePartYear);
int m = GetDatePart(time.Ticks, DatePartMonth);
@@ -408,131 +295,82 @@ namespace System.Globalization
m = 12 + (i + 1) % 12;
y = y + (i - 11) / 12;
}
+
int days = GetDaysInMonth(y, m);
if (d > days)
{
d = days;
}
+
long ticks = GetAbsoluteDateHijri(y, m, d) * TicksPerDay + (time.Ticks % TicksPerDay);
Calendar.CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (new DateTime(ticks));
+ return new DateTime(ticks);
}
- // Returns the DateTime resulting from adding the given number of
- // years to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year part of the specified DateTime by value
- // years. If the month and day of the specified DateTime is 2/29, and if the
- // resulting year is not a leap year, the month and day of the resulting
- // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
- // parts of the result are the same as those of the specified DateTime.
- //
-
public override DateTime AddYears(DateTime time, int years)
{
return (AddMonths(time, years * 12));
}
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 31.
- //
-
public override int GetDayOfMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDay));
+ return GetDatePart(time.Ticks, DatePartDay);
}
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7));
+ return (DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7);
}
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and 366.
- //
-
public override int GetDayOfYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDayOfYear));
+ return GetDatePart(time.Ticks, DatePartDayOfYear);
}
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
public override int GetDaysInMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
if (month == 12)
{
// For the 12th month, leap year has 30 days, and common year has 29 days.
- return (IsLeapYear(year, CurrentEra) ? 30 : 29);
+ return IsLeapYear(year, CurrentEra) ? 30 : 29;
}
+
// Other months contain 30 and 29 days alternatively. The 1st month has 30 days.
- return (((month % 2) == 1) ? 30 : 29);
+ return ((month % 2) == 1) ? 30 : 29;
}
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
public override int GetDaysInYear(int year, int era)
{
CheckYearRange(year, era);
- // Common years have 354 days. Leap years have 355 days.
- return (IsLeapYear(year, CurrentEra) ? 355 : 354);
+ // Common years have 354 days. Leap years have 355 days.
+ return IsLeapYear(year, CurrentEra) ? 355 : 354;
}
- // Returns the era for the specified DateTime value.
-
public override int GetEra(DateTime time)
{
CheckTicksRange(time.Ticks);
- return (HijriEra);
- }
-
-
- public override int[] Eras
- {
- get
- {
- return (new int[] { HijriEra });
- }
+ return HijriEra;
}
- // Returns the month part of the specified DateTime. The returned value is an
- // integer between 1 and 12.
- //
+ public override int[] Eras => new int[] { HijriEra };
public override int GetMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartMonth));
+ return GetDatePart(time.Ticks, DatePartMonth);
}
- // Returns the number of months in the specified year and era.
-
public override int GetMonthsInYear(int year, int era)
{
CheckYearRange(year, era);
- return (12);
+ return 12;
}
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between 1 and MaxCalendarYear.
- //
-
public override int GetYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartYear));
+ return GetDatePart(time.Ticks, DatePartYear);
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
// The year/month/era value checking is done in GetDaysInMonth().
@@ -540,49 +378,32 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Day,
- daysInMonth,
- month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
- return (IsLeapYear(year, era) && month == 12 && day == 30);
- }
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
+ return IsLeapYear(year, era) && month == 12 && day == 30;
+ }
public override int GetLeapMonth(int year, int era)
{
CheckYearRange(year, era);
- return (0);
+ return 0;
}
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
public override bool IsLeapMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
- return (false);
+ return false;
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
public override bool IsLeapYear(int year, int era)
{
CheckYearRange(year, era);
- return ((((year * 11) + 14) % 30) < 11);
+ return (((year * 11) + 14) % 30) < 11;
}
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
// The year/month/era checking is done in GetDaysInMonth().
@@ -590,82 +411,68 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Day,
- daysInMonth,
- month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
long lDate = GetAbsoluteDateHijri(year, month, day);
-
- if (lDate >= 0)
- {
- return (new DateTime(lDate * GregorianCalendar.TicksPerDay + TimeToTicks(hour, minute, second, millisecond)));
- }
- else
+ if (lDate < 0)
{
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
+
+ return new DateTime(lDate * GregorianCalendar.TicksPerDay + TimeToTicks(hour, minute, second, millisecond));
}
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 1451;
-
+ private const int DefaultTwoDigitYearMax = 1451;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
if (value < 99 || value > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(value),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- MaxCalendarYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxCalendarYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
if (year < 100)
{
- return (base.ToFourDigitYear(year));
+ return base.ToFourDigitYear(year);
}
if (year > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxCalendarYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarYear));
}
- return (year);
+ return year;
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs
index 5e66c94b2c..ef781666ca 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Unix.cs
@@ -40,7 +40,7 @@ namespace System.Globalization
return null;
}
- if (dt < JapaneseCalendar.calendarMinValue)
+ if (dt < s_calendarMinValue)
{
// only populate the Eras that are valid JapaneseCalendar date times
break;
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs
index fdf2dc670a..bcddd191a8 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs
@@ -2,76 +2,49 @@
// 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.Diagnostics.CodeAnalysis;
-
namespace System.Globalization
{
- /*=================================JapaneseCalendar==========================
- **
- ** JapaneseCalendar is based on Gregorian calendar. The month and day values are the same as
- ** Gregorian calendar. However, the year value is an offset to the Gregorian
- ** year based on the era.
- **
- ** This system is adopted by Emperor Meiji in 1868. The year value is counted based on the reign of an emperor,
- ** and the era begins on the day an emperor ascends the throne and continues until his death.
- ** The era changes at 12:00AM.
- **
- ** For example, the current era is Heisei. It started on 1989/1/8 A.D. Therefore, Gregorian year 1989 is also Heisei 1st.
- ** 1989/1/8 A.D. is also Heisei 1st 1/8.
- **
- ** Any date in the year during which era is changed can be reckoned in either era. For example,
- ** 1989/1/1 can be 1/1 Heisei 1st year or 1/1 Showa 64th year.
- **
- ** Note:
- ** The DateTime can be represented by the JapaneseCalendar are limited to two factors:
- ** 1. The min value and max value of DateTime class.
- ** 2. The available era information.
- **
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1868/09/08 9999/12/31
- ** Japanese Meiji 01/01 Heisei 8011/12/31
- ============================================================================*/
-
-
+ /// <summary>
+ /// JapaneseCalendar is based on Gregorian calendar. The month and day values are the same as
+ /// Gregorian calendar. However, the year value is an offset to the Gregorian
+ /// year based on the era.
+ ///
+ /// This system is adopted by Emperor Meiji in 1868. The year value is counted based on the reign of an emperor,
+ /// and the era begins on the day an emperor ascends the throne and continues until his death.
+ /// The era changes at 12:00AM.
+ ///
+ /// For example, the current era is Heisei. It started on 1989/1/8 A.D. Therefore, Gregorian year 1989 is also Heisei 1st.
+ /// 1989/1/8 A.D. is also Heisei 1st 1/8.
+ ///
+ /// Any date in the year during which era is changed can be reckoned in either era. For example,
+ /// 1989/1/1 can be 1/1 Heisei 1st year or 1/1 Showa 64th year.
+ ///
+ /// Note:
+ /// The DateTime can be represented by the JapaneseCalendar are limited to two factors:
+ /// 1. The min value and max value of DateTime class.
+ /// 2. The available era information.
+ /// </summary>
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1868/09/08 9999/12/31
+ /// Japanese Meiji 01/01 Heisei 8011/12/31
+ /// </remarks>
public partial class JapaneseCalendar : Calendar
{
- internal static readonly DateTime calendarMinValue = new DateTime(1868, 9, 8);
+ private static readonly DateTime s_calendarMinValue = new DateTime(1868, 9, 8);
+ public override DateTime MinSupportedDateTime => s_calendarMinValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (calendarMinValue);
- }
- }
+ public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
-
- //
// Using a field initializer rather than a static constructor so that the whole class can be lazy
// init.
- internal static volatile EraInfo[] japaneseEraInfo;
+ private static volatile EraInfo[] s_japaneseEraInfo;
- //
- // Read our era info
- //
// m_EraInfo must be listed in reverse chronological order. The most recent era
// should be the first element.
// That is, m_EraInfo[0] contains the most recent era.
@@ -92,57 +65,37 @@ namespace System.Globalization
// . is a delimiter, but the value of . doesn't matter.
// '_' marks the space between the japanese era name, japanese abbreviated era name
// english name, and abbreviated english names.
- //
internal static EraInfo[] GetEraInfo()
{
// See if we need to build it
- if (japaneseEraInfo == null)
+ if (s_japaneseEraInfo == null)
{
- japaneseEraInfo = GetJapaneseEras();
+ s_japaneseEraInfo = GetJapaneseEras();
+
// See if we have to use the built-in eras
- if (japaneseEraInfo == null)
+ if (s_japaneseEraInfo == null)
{
- // We know about some built-in ranges
- EraInfo[] defaultEraRanges = new EraInfo[4];
- defaultEraRanges[0] = new EraInfo(4, 1989, 1, 8, 1988, 1, GregorianCalendar.MaxYear - 1988,
- "\x5e73\x6210", "\x5e73", "H"); // era #4 start year/month/day, yearOffset, minEraYear
- defaultEraRanges[1] = new EraInfo(3, 1926, 12, 25, 1925, 1, 1989 - 1925,
- "\x662d\x548c", "\x662d", "S"); // era #3,start year/month/day, yearOffset, minEraYear
- defaultEraRanges[2] = new EraInfo(2, 1912, 7, 30, 1911, 1, 1926 - 1911,
- "\x5927\x6b63", "\x5927", "T"); // era #2,start year/month/day, yearOffset, minEraYear
- defaultEraRanges[3] = new EraInfo(1, 1868, 1, 1, 1867, 1, 1912 - 1867,
- "\x660e\x6cbb", "\x660e", "M"); // era #1,start year/month/day, yearOffset, minEraYear
-
- // Remember the ranges we built
- japaneseEraInfo = defaultEraRanges;
+ s_japaneseEraInfo = new EraInfo[]
+ {
+ new EraInfo(4, 1989, 1, 8, 1988, 1, GregorianCalendar.MaxYear - 1988, "\x5e73\x6210", "\x5e73", "H"),
+ new EraInfo(3, 1926, 12, 25, 1925, 1, 1989 - 1925, "\x662d\x548c", "\x662d", "S"),
+ new EraInfo(2, 1912, 7, 30, 1911, 1, 1926 - 1911, "\x5927\x6b63", "\x5927", "T"),
+ new EraInfo(1, 1868, 1, 1, 1867, 1, 1912 - 1867, "\x660e\x6cbb", "\x660e", "M")
+ };
}
}
- // return the era we found/made
- return japaneseEraInfo;
+ return s_japaneseEraInfo;
}
internal static volatile Calendar s_defaultInstance;
- internal GregorianCalendarHelper helper;
-
- /*=================================GetDefaultInstance==========================
- **Action: Internal method to provide a default intance of JapaneseCalendar. Used by NLS+ implementation
- ** and other calendars.
- **Returns:
- **Arguments:
- **Exceptions:
- ============================================================================*/
+ internal GregorianCalendarHelper _helper;
internal static Calendar GetDefaultInstance()
{
- if (s_defaultInstance == null)
- {
- s_defaultInstance = new JapaneseCalendar();
- }
- return (s_defaultInstance);
+ return s_defaultInstance ?? (s_defaultInstance = new JapaneseCalendar());
}
-
public JapaneseCalendar()
{
try
@@ -153,178 +106,126 @@ namespace System.Globalization
{
throw new TypeInitializationException(this.GetType().ToString(), e);
}
- helper = new GregorianCalendarHelper(this, GetEraInfo());
- }
- internal override CalendarId ID
- {
- get
- {
- return CalendarId.JAPAN;
- }
+ _helper = new GregorianCalendarHelper(this, GetEraInfo());
}
+ internal override CalendarId ID => CalendarId.JAPAN;
public override DateTime AddMonths(DateTime time, int months)
{
- return (helper.AddMonths(time, months));
+ return _helper.AddMonths(time, months);
}
-
public override DateTime AddYears(DateTime time, int years)
{
- return (helper.AddYears(time, years));
+ return _helper.AddYears(time, years);
}
-
- /*=================================GetDaysInMonth==========================
- **Action: Returns the number of days in the month given by the year and month arguments.
- **Returns: The number of days in the given month.
- **Arguments:
- ** year The year in Japanese calendar.
- ** month The month
- ** era The Japanese era value.
- **Exceptions
- ** ArgumentException If month is less than 1 or greater * than 12.
- ============================================================================*/
-
-
+
public override int GetDaysInMonth(int year, int month, int era)
{
- return (helper.GetDaysInMonth(year, month, era));
+ return _helper.GetDaysInMonth(year, month, era);
}
-
public override int GetDaysInYear(int year, int era)
{
- return (helper.GetDaysInYear(year, era));
+ return _helper.GetDaysInYear(year, era);
}
-
public override int GetDayOfMonth(DateTime time)
{
- return (helper.GetDayOfMonth(time));
+ return _helper.GetDayOfMonth(time);
}
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return (helper.GetDayOfWeek(time));
+ return _helper.GetDayOfWeek(time);
}
-
public override int GetDayOfYear(DateTime time)
{
- return (helper.GetDayOfYear(time));
+ return _helper.GetDayOfYear(time);
}
-
public override int GetMonthsInYear(int year, int era)
{
- return (helper.GetMonthsInYear(year, era));
+ return _helper.GetMonthsInYear(year, era);
}
-
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
- return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
+ return _helper.GetWeekOfYear(time, rule, firstDayOfWeek);
}
- /*=================================GetEra==========================
- **Action: Get the era value of the specified time.
- **Returns: The era value for the specified time.
- **Arguments:
- ** time the specified date time.
- **Exceptions: ArgumentOutOfRangeException if time is out of the valid era ranges.
- ============================================================================*/
-
-
public override int GetEra(DateTime time)
{
- return (helper.GetEra(time));
+ return _helper.GetEra(time);
}
-
public override int GetMonth(DateTime time)
{
- return (helper.GetMonth(time));
+ return _helper.GetMonth(time);
}
-
public override int GetYear(DateTime time)
{
- return (helper.GetYear(time));
+ return _helper.GetYear(time);
}
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
- return (helper.IsLeapDay(year, month, day, era));
+ return _helper.IsLeapDay(year, month, day, era);
}
-
public override bool IsLeapYear(int year, int era)
{
- return (helper.IsLeapYear(year, era));
+ return _helper.IsLeapYear(year, era);
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
public override int GetLeapMonth(int year, int era)
{
- return (helper.GetLeapMonth(year, era));
+ return _helper.GetLeapMonth(year, era);
}
-
public override bool IsLeapMonth(int year, int month, int era)
{
- return (helper.IsLeapMonth(year, month, era));
+ return _helper.IsLeapMonth(year, month, era);
}
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
- return (helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era));
+ return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era);
}
- // For Japanese calendar, four digit year is not used. Few emperors will live for more than one hundred years.
- // Therefore, for any two digit number, we just return the original number.
-
+ /// <summary>
+ /// For Japanese calendar, four digit year is not used. Few emperors will live for more than one hundred years.
+ /// Therefore, for any two digit number, we just return the original number.
+ /// </summary>
public override int ToFourDigitYear(int year)
{
if (year <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedPosNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedPosNum);
}
-
- if (year > helper.MaxYear)
+ if (year > _helper.MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- helper.MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, _helper.MaxYear));
}
- return (year);
+
+ return year;
}
- public override int[] Eras
- {
- get
- {
- return (helper.Eras);
- }
- }
+ public override int[] Eras => _helper.Eras;
- //
- // Return the various era strings
- // Note: The arrays are backwards of the eras
- //
+ /// <summary>
+ /// Return the various era strings
+ /// Note: The arrays are backwards of the eras
+ /// </summary>
internal static string[] EraNames()
{
EraInfo[] eras = GetEraInfo();
@@ -367,38 +268,36 @@ namespace System.Globalization
return erasEnglish;
}
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 99;
+ private const int DefaultTwoDigitYearMax = 99;
internal override bool IsValidYear(int year, int era)
{
- return helper.IsValidYear(year, era);
+ return _helper.IsValidYear(year, era);
}
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
- if (value < 99 || value > helper.MaxYear)
+ if (value < 99 || value > _helper.MaxYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- helper.MaxYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, _helper.MaxYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs
index 64aa79d875..2b018e49f0 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs
@@ -2,57 +2,31 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
namespace System.Globalization
{
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1960/01/28 2050/01/22
- ** JapaneseLunisolar 1960/01/01 2049/12/29
- */
-
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1960/01/28 2050/01/22
+ /// JapaneseLunisolar 1960/01/01 2049/12/29
+ /// </remarks>
public class JapaneseLunisolarCalendar : EastAsianLunisolarCalendar
{
- //
- // The era value for the current era.
- //
-
public const int JapaneseEra = 1;
- internal GregorianCalendarHelper helper;
-
- internal const int MIN_LUNISOLAR_YEAR = 1960;
- internal const int MAX_LUNISOLAR_YEAR = 2049;
+ private readonly GregorianCalendarHelper _helper;
- internal const int MIN_GREGORIAN_YEAR = 1960;
- internal const int MIN_GREGORIAN_MONTH = 1;
- internal const int MIN_GREGORIAN_DAY = 28;
+ private const int MinLunisolarYear = 1960;
+ private const int MaxLunisolarYear = 2049;
- internal const int MAX_GREGORIAN_YEAR = 2050;
- internal const int MAX_GREGORIAN_MONTH = 1;
- internal const int MAX_GREGORIAN_DAY = 22;
+ private static readonly DateTime s_minDate = new DateTime(1960, 1, 28);
+ private static readonly DateTime s_maxDate = new DateTime((new DateTime(2050, 1, 2, 23, 59, 59, 999)).Ticks + 9999);
- internal static DateTime minDate = new DateTime(MIN_GREGORIAN_YEAR, MIN_GREGORIAN_MONTH, MIN_GREGORIAN_DAY);
- internal static DateTime maxDate = new DateTime((new DateTime(MAX_GREGORIAN_YEAR, MAX_GREGORIAN_MONTH, MAX_GREGORIAN_DAY, 23, 59, 59, 999)).Ticks + 9999);
+ public override DateTime MinSupportedDateTime => s_minDate;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (minDate);
- }
- }
-
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (maxDate);
- }
- }
+ public override DateTime MaxSupportedDateTime => s_maxDate;
+
protected override int DaysInYearBeforeMinSupportedYear
{
get
@@ -63,8 +37,8 @@ namespace System.Globalization
}
// Data for years 1960-2049 matches output of Calendrical Calculations [1] and published calendar tables [2].
- // [1] Reingold, Edward M, and Nachum Dershowitz. Calendrical Calculations: The Ultimate Edition. Cambridge [etc.: Cambridge University Press, 2018. Print.
- // [2] Nishizawa, Yūsō. Rekijitsu Taikan: Meiji Kaireki 1873-Nen-2100-Nen Shinkyūreki, Kanshi Kyūsei Rokuyō Taishō. Tōkyō: Shin Jinbutsu Ōraisha, 1994. Print.
+ // [1] Reingold, Edward M, and Nachum Dershowitz. Calendrical Calculations: The Ultimate Edition. Cambridge [etc.: Cambridge University Press, 2018. Print.
+ // [2] Nishizawa, Yūsō. Rekijitsu Taikan: Meiji Kaireki 1873-Nen-2100-Nen Shinkyūreki, Kanshi Kyūsei Rokuyō Taishō. Tōkyō: Shin Jinbutsu Ōraisha, 1994. Print.
private static readonly int[,] s_yinfo =
{
/*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days
@@ -160,73 +134,42 @@ namespace System.Globalization
2049 */ { 00, 02, 02, 0b1010110110100000 }, /* 30 29 30 29 30 30 29 30 30 29 30 29 355
*/ };
- internal override int MinCalendarYear
- {
- get
- {
- return (MIN_LUNISOLAR_YEAR);
- }
- }
+ internal override int MinCalendarYear => MinLunisolarYear;
- internal override int MaxCalendarYear
- {
- get
- {
- return (MAX_LUNISOLAR_YEAR);
- }
- }
+ internal override int MaxCalendarYear => MaxLunisolarYear;
- internal override DateTime MinDate
- {
- get
- {
- return (minDate);
- }
- }
+ internal override DateTime MinDate => s_minDate;
- internal override DateTime MaxDate
- {
- get
- {
- return (maxDate);
- }
- }
+ internal override DateTime MaxDate => s_maxDate;
- internal override EraInfo[] CalEraInfo
- {
- get
- {
- return (JapaneseCalendar.GetEraInfo());
- }
- }
+ internal override EraInfo[] CalEraInfo => JapaneseCalendar.GetEraInfo();
internal override int GetYearInfo(int lunarYear, int index)
{
- if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
+ if (lunarYear < MinLunisolarYear || lunarYear > MaxLunisolarYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MIN_LUNISOLAR_YEAR,
- MAX_LUNISOLAR_YEAR));
+ "year",
+ lunarYear,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinLunisolarYear, MaxLunisolarYear));
}
- return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
+ return s_yinfo[lunarYear - MinLunisolarYear, index];
}
internal override int GetYear(int year, DateTime time)
{
- return helper.GetYear(year, time);
+ return _helper.GetYear(year, time);
}
internal override int GetGregorianYear(int year, int era)
{
- return helper.GetGregorianYear(year, era);
+ return _helper.GetGregorianYear(year, era);
}
- // Trim off the eras that are before our date range
+ /// <summary>
+ /// Trim off the eras that are before our date range
+ /// </summary>
private static EraInfo[] TrimEras(EraInfo[] baseEras)
{
EraInfo[] newEras = new EraInfo[baseEras.Length];
@@ -237,7 +180,7 @@ namespace System.Globalization
{
// If this one's minimum year is bigger than our maximum year
// then we can't use it.
- if (baseEras[i].yearOffset + baseEras[i].minEraYear >= MAX_LUNISOLAR_YEAR)
+ if (baseEras[i].yearOffset + baseEras[i].minEraYear >= MaxLunisolarYear)
{
// skip this one.
continue;
@@ -245,7 +188,7 @@ namespace System.Globalization
// If this one's maximum era is less than our minimum era
// then we've gotten too low in the era #s, so we're done
- if (baseEras[i].yearOffset + baseEras[i].maxEraYear < MIN_LUNISOLAR_YEAR)
+ if (baseEras[i].yearOffset + baseEras[i].maxEraYear < MinLunisolarYear)
{
break;
}
@@ -258,44 +201,21 @@ namespace System.Globalization
// If we didn't copy any then something was wrong, just return base
if (newIndex == 0) return baseEras;
- // Resize the output array
Array.Resize(ref newEras, newIndex);
return newEras;
}
- // Construct an instance of JapaneseLunisolar calendar.
public JapaneseLunisolarCalendar()
{
- helper = new GregorianCalendarHelper(this, TrimEras(JapaneseCalendar.GetEraInfo()));
+ _helper = new GregorianCalendarHelper(this, TrimEras(JapaneseCalendar.GetEraInfo()));
}
- public override int GetEra(DateTime time)
- {
- return (helper.GetEra(time));
- }
+ public override int GetEra(DateTime time) => _helper.GetEra(time);
- internal override CalendarId BaseCalendarID
- {
- get
- {
- return (CalendarId.JAPAN);
- }
- }
+ internal override CalendarId BaseCalendarID => CalendarId.JAPAN;
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.JAPANESELUNISOLAR);
- }
- }
+ internal override CalendarId ID => CalendarId.JAPANESELUNISOLAR;
- public override int[] Eras
- {
- get
- {
- return (helper.Eras);
- }
- }
+ public override int[] Eras => _helper.Eras;
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs
index a61cf978aa..bba7f07053 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs
@@ -2,20 +2,21 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
namespace System.Globalization
{
- //
- // This class implements the Julian calendar. In 48 B.C. Julius Caesar ordered a calendar reform, and this calendar
- // is called Julian calendar. It consisted of a solar year of twelve months and of 365 days with an extra day
- // every fourth year.
- //*
- //* Calendar support range:
- //* Calendar Minimum Maximum
- //* ========== ========== ==========
- //* Gregorian 0001/01/01 9999/12/31
- //* Julia 0001/01/03 9999/10/19
-
+ /// <summary>
+ /// This class implements the Julian calendar. In 48 B.C. Julius Caesar
+ /// ordered a calendar reform, and this calendar is called Julian calendar.
+ /// It consisted of a solar year of twelve months and of 365 days with an
+ /// extra day every fourth year.
+ /// </summary>
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 0001/01/01 9999/12/31
+ /// Julia 0001/01/03 9999/10/19
+ /// </remarks>
public class JulianCalendar : Calendar
{
public static readonly int JulianEra = 1;
@@ -27,6 +28,7 @@ namespace System.Globalization
// Number of days in a non-leap year
private const int JulianDaysPerYear = 365;
+
// Number of days in 4 years
private const int JulianDaysPer4Years = JulianDaysPerYear * 4 + 1;
@@ -44,50 +46,25 @@ namespace System.Globalization
// keep it as variable field for serialization compat.
internal int MaxYear = 9999;
+ public override DateTime MinSupportedDateTime => DateTime.MinValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (DateTime.MinValue);
- }
- }
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
+ public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
public JulianCalendar()
{
// There is no system setting of TwoDigitYear max, so set the value here.
- twoDigitYearMax = 2029;
+ _twoDigitYearMax = 2029;
}
- internal override CalendarId ID
- {
- get
- {
- return CalendarId.JULIAN;
- }
- }
+ internal override CalendarId ID => CalendarId.JULIAN;
internal static void CheckEraRange(int era)
{
if (era != CurrentEra && era != JulianEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
}
@@ -97,12 +74,9 @@ namespace System.Globalization
if (year <= 0 || year > MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxYear));
}
}
@@ -110,20 +84,17 @@ namespace System.Globalization
{
if (month < 1 || month > 12)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
}
}
- /*===================================CheckDayRange============================
- **Action: Check for if the day value is valid.
- **Returns:
- **Arguments:
- **Exceptions:
- **Notes:
- ** Before calling this method, call CheckYearEraRange()/CheckMonthRange() to make
- ** sure year/month values are correct.
- ============================================================================*/
-
+ /// <summary>
+ /// Check for if the day value is valid.
+ /// </summary>
+ /// <remarks>
+ /// Before calling this method, call CheckYearEraRange()/CheckMonthRange() to make
+ /// sure year/month values are correct.
+ /// </remarks>
internal static void CheckDayRange(int year, int month, int day)
{
if (year == 1 && month == 1)
@@ -131,28 +102,26 @@ namespace System.Globalization
// The minimum supported Julia date is Julian 0001/01/03.
if (day < 3)
{
- throw new ArgumentOutOfRangeException(null,
- SR.ArgumentOutOfRange_BadYearMonthDay);
+ throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
}
+
bool isLeapYear = (year % 4) == 0;
int[] days = isLeapYear ? s_daysToMonth366 : s_daysToMonth365;
int monthDays = days[month] - days[month - 1];
if (day < 1 || day > monthDays)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- monthDays));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, monthDays));
}
}
-
- // Returns a given date part of this DateTime. This method is used
- // to compute the year, day-of-year, month, or day part.
+ /// <summary>
+ /// Returns a given date part of this DateTime. This method is used
+ /// to compute the year, day-of-year, month, or day part.
+ /// </summary>
internal static int GetDatePart(long ticks, int part)
{
// Gregorian 1/1/0001 is Julian 1/3/0001. Remember DateTime(0) is refered to Gregorian 1/1/0001.
@@ -171,15 +140,17 @@ namespace System.Globalization
// If year was requested, compute and return it
if (part == DatePartYear)
{
- return (y4 * 4 + y1 + 1);
+ return y4 * 4 + y1 + 1;
}
+
// n = day number within year
n -= y1 * JulianDaysPerYear;
// If day-of-year was requested, return it
if (part == DatePartDayOfYear)
{
- return (n + 1);
+ return n + 1;
}
+
// Leap year calculation looks different from IsLeapYear since y1, y4,
// and y100 are relative to year 1, not year 0
bool leapYear = (y1 == 3);
@@ -188,14 +159,24 @@ namespace System.Globalization
// estimate for the month
int m = (n >> 5) + 1;
// m = 1-based month number
- while (n >= days[m]) m++;
+ while (n >= days[m])
+ {
+ m++;
+ }
+
// If month was requested, return it
- if (part == DatePartMonth) return (m);
+ if (part == DatePartMonth)
+ {
+ return m;
+ }
+
// Return 1-based day-of-month
- return (n - days[m - 1] + 1);
+ return n - days[m - 1] + 1;
}
- // Returns the tick count corresponding to the given year, month, and day.
+ /// <summary>
+ /// Returns the tick count corresponding to the given year, month, and day.
+ /// </summary>
internal static long DateToTicks(int year, int month, int day)
{
int[] days = (year % 4 == 0) ? s_daysToMonth366 : s_daysToMonth365;
@@ -204,22 +185,19 @@ namespace System.Globalization
// Gregorian 1/1/0001 is Julian 1/3/0001. n * TicksPerDay is the ticks in JulianCalendar.
// Therefore, we subtract two days in the following to convert the ticks in JulianCalendar
// to ticks in Gregorian calendar.
- return ((n - 2) * TicksPerDay);
+ return (n - 2) * TicksPerDay;
}
-
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException(
- nameof(months),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- -120000,
- 120000));
+ nameof(months),
+ months,
+ SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
+
int y = GetDatePart(time.Ticks, DatePartYear);
int m = GetDatePart(time.Ticks, DatePartMonth);
int d = GetDatePart(time.Ticks, DatePartDay);
@@ -234,93 +212,73 @@ namespace System.Globalization
m = 12 + (i + 1) % 12;
y = y + (i - 11) / 12;
}
- int[] daysArray = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) ? s_daysToMonth366 : s_daysToMonth365;
- int days = (daysArray[m] - daysArray[m - 1]);
+ int[] daysArray = (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) ? s_daysToMonth366 : s_daysToMonth365;
+ int days = daysArray[m] - daysArray[m - 1];
if (d > days)
{
d = days;
}
+
long ticks = DateToTicks(y, m, d) + time.Ticks % TicksPerDay;
Calendar.CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (new DateTime(ticks));
+ return new DateTime(ticks);
}
-
public override DateTime AddYears(DateTime time, int years)
{
- return (AddMonths(time, years * 12));
+ return AddMonths(time, years * 12);
}
-
public override int GetDayOfMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDay));
+ return GetDatePart(time.Ticks, DatePartDay);
}
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7));
+ return (DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7);
}
-
public override int GetDayOfYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDayOfYear));
+ return GetDatePart(time.Ticks, DatePartDayOfYear);
}
-
public override int GetDaysInMonth(int year, int month, int era)
{
CheckYearEraRange(year, era);
CheckMonthRange(month);
int[] days = (year % 4 == 0) ? s_daysToMonth366 : s_daysToMonth365;
- return (days[month] - days[month - 1]);
+ return days[month] - days[month - 1];
}
-
public override int GetDaysInYear(int year, int era)
{
// Year/Era range is done in IsLeapYear().
- return (IsLeapYear(year, era) ? 366 : 365);
- }
-
-
- public override int GetEra(DateTime time)
- {
- return (JulianEra);
+ return IsLeapYear(year, era) ? 366 : 365;
}
+ public override int GetEra(DateTime time) => JulianEra;
public override int GetMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartMonth));
- }
-
-
- public override int[] Eras
- {
- get
- {
- return (new int[] { JulianEra });
- }
+ return GetDatePart(time.Ticks, DatePartMonth);
}
+ public override int[] Eras => new int[] { JulianEra };
public override int GetMonthsInYear(int year, int era)
{
CheckYearEraRange(year, era);
- return (12);
+ return 12;
}
-
public override int GetYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartYear));
+ return GetDatePart(time.Ticks, DatePartYear);
}
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
CheckMonthRange(month);
@@ -328,41 +286,32 @@ namespace System.Globalization
if (IsLeapYear(year, era))
{
CheckDayRange(year, month, day);
- return (month == 2 && day == 29);
+ return month == 2 && day == 29;
}
+
CheckDayRange(year, month, day);
- return (false);
+ return false;
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
public override int GetLeapMonth(int year, int era)
{
CheckYearEraRange(year, era);
- return (0);
+ return 0;
}
-
public override bool IsLeapMonth(int year, int month, int era)
{
CheckYearEraRange(year, era);
CheckMonthRange(month);
- return (false);
+ return false;
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
public override bool IsLeapYear(int year, int era)
{
CheckYearEraRange(year, era);
return (year % 4 == 0);
}
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
CheckYearEraRange(year, era);
@@ -371,69 +320,52 @@ namespace System.Globalization
if (millisecond < 0 || millisecond >= MillisPerSecond)
{
throw new ArgumentOutOfRangeException(
- nameof(millisecond),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 0,
- MillisPerSecond - 1));
+ nameof(millisecond),
+ millisecond,
+ SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1));
}
- if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60 && second >= 0 && second < 60)
- {
- return new DateTime(DateToTicks(year, month, day) + (new TimeSpan(0, hour, minute, second, millisecond)).Ticks);
- }
- else
+ if (hour < 0 || hour >= 24 || minute < 0 || minute >= 60 || second < 0 || second >= 60)
{
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond);
}
- }
+ return new DateTime(DateToTicks(year, month, day) + (new TimeSpan(0, hour, minute, second, millisecond)).Ticks);
+ }
public override int TwoDigitYearMax
{
- get
- {
- return (twoDigitYearMax);
- }
-
+ get => _twoDigitYearMax;
set
{
VerifyWritable();
if (value < 99 || value > MaxYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- MaxYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
-
if (year > MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Bounds_Lower_Upper,
- 1,
- MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, 1, MaxYear));
}
- return (base.ToFourDigitYear(year));
+
+ return base.ToFourDigitYear(year);
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs
index 3f265f69e8..63c372e711 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs
@@ -2,32 +2,24 @@
// 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.Diagnostics.CodeAnalysis;
-
namespace System.Globalization
{
- /*=================================KoreanCalendar==========================
- **
- ** Korean calendar is based on the Gregorian calendar. And the year is an offset to Gregorian calendar.
- ** That is,
- ** Korean year = Gregorian year + 2333. So 2000/01/01 A.D. is Korean 4333/01/01
- **
- ** 0001/1/1 A.D. is Korean year 2334.
- **
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 0001/01/01 9999/12/31
- ** Korean 2334/01/01 12332/12/31
- ============================================================================*/
-
-
+ /// <summary>
+ /// Korean calendar is based on the Gregorian calendar. And the year is an offset to Gregorian calendar.
+ /// That is,
+ /// Korean year = Gregorian year + 2333. So 2000/01/01 A.D. is Korean 4333/01/01
+ ///
+ /// 0001/1/1 A.D. is Korean year 2334.
+ /// </summary>
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 0001/01/01 9999/12/31
+ /// Korean 2334/01/01 12332/12/31
+ /// </remarks>
public class KoreanCalendar : Calendar
{
- //
- // The era value for the current era.
- //
-
public const int KoreanEra = 1;
// Since
@@ -36,40 +28,18 @@ namespace System.Globalization
// 1 = 2334 + yearOffset
// So yearOffset = -2333
// Gregorian year 2001 is Korean year 4334.
-
- //m_EraInfo[0] = new EraInfo(1, new DateTime(1, 1, 1).Ticks, -2333, 2334, GregorianCalendar.MaxYear + 2333);
-
- // Initialize our era info.
- internal static EraInfo[] koreanEraInfo = new EraInfo[] {
- new EraInfo( 1, 1, 1, 1, -2333, 2334, GregorianCalendar.MaxYear + 2333) // era #, start year/month/day, yearOffset, minEraYear
+ private static readonly EraInfo[] s_koreanEraInfo = new EraInfo[]
+ {
+ new EraInfo( 1, 1, 1, 1, -2333, 2334, GregorianCalendar.MaxYear + 2333) // era #, start year/month/day, yearOffset, minEraYear
};
- internal GregorianCalendarHelper helper;
+ private readonly GregorianCalendarHelper _helper;
+ public override DateTime MinSupportedDateTime => DateTime.MinValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (DateTime.MinValue);
- }
- }
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
+ public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
public KoreanCalendar()
{
@@ -79,184 +49,142 @@ namespace System.Globalization
}
catch (ArgumentException e)
{
- throw new TypeInitializationException(this.GetType().ToString(), e);
+ throw new TypeInitializationException(GetType().ToString(), e);
}
- helper = new GregorianCalendarHelper(this, koreanEraInfo);
- }
- internal override CalendarId ID
- {
- get
- {
- return CalendarId.KOREA;
- }
+ _helper = new GregorianCalendarHelper(this, s_koreanEraInfo);
}
+ internal override CalendarId ID => CalendarId.KOREA;
+
public override DateTime AddMonths(DateTime time, int months)
{
- return (helper.AddMonths(time, months));
+ return _helper.AddMonths(time, months);
}
public override DateTime AddYears(DateTime time, int years)
{
- return (helper.AddYears(time, years));
+ return _helper.AddYears(time, years);
}
- /*=================================GetDaysInMonth==========================
- **Action: Returns the number of days in the month given by the year and month arguments.
- **Returns: The number of days in the given month.
- **Arguments:
- ** year The year in Korean calendar.
- ** month The month
- ** era The Japanese era value.
- **Exceptions
- ** ArgumentException If month is less than 1 or greater * than 12.
- ============================================================================*/
-
-
public override int GetDaysInMonth(int year, int month, int era)
{
- return (helper.GetDaysInMonth(year, month, era));
+ return _helper.GetDaysInMonth(year, month, era);
}
-
public override int GetDaysInYear(int year, int era)
{
- return (helper.GetDaysInYear(year, era));
+ return _helper.GetDaysInYear(year, era);
}
-
public override int GetDayOfMonth(DateTime time)
{
- return (helper.GetDayOfMonth(time));
+ return _helper.GetDayOfMonth(time);
}
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return (helper.GetDayOfWeek(time));
+ return _helper.GetDayOfWeek(time);
}
-
public override int GetDayOfYear(DateTime time)
{
- return (helper.GetDayOfYear(time));
+ return _helper.GetDayOfYear(time);
}
-
public override int GetMonthsInYear(int year, int era)
{
- return (helper.GetMonthsInYear(year, era));
+ return _helper.GetMonthsInYear(year, era);
}
-
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
- return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
+ return _helper.GetWeekOfYear(time, rule, firstDayOfWeek);
}
-
public override int GetEra(DateTime time)
{
- return (helper.GetEra(time));
+ return _helper.GetEra(time);
}
public override int GetMonth(DateTime time)
{
- return (helper.GetMonth(time));
+ return _helper.GetMonth(time);
}
-
public override int GetYear(DateTime time)
{
- return (helper.GetYear(time));
+ return _helper.GetYear(time);
}
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
- return (helper.IsLeapDay(year, month, day, era));
+ return _helper.IsLeapDay(year, month, day, era);
}
-
public override bool IsLeapYear(int year, int era)
{
- return (helper.IsLeapYear(year, era));
+ return _helper.IsLeapYear(year, era);
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
public override int GetLeapMonth(int year, int era)
{
- return (helper.GetLeapMonth(year, era));
+ return _helper.GetLeapMonth(year, era);
}
-
public override bool IsLeapMonth(int year, int month, int era)
{
- return (helper.IsLeapMonth(year, month, era));
+ return _helper.IsLeapMonth(year, month, era);
}
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
- return (helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era));
+ return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era);
}
- public override int[] Eras
- {
- get
- {
- return (helper.Eras);
- }
- }
+ public override int[] Eras => _helper.Eras;
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 4362;
+ private const int DefaultTwoDigitYearMax = 4362;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
- if (value < 99 || value > helper.MaxYear)
+ if (value < 99 || value > _helper.MaxYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- helper.MaxYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, _helper.MaxYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
- return (helper.ToFourDigitYear(year, this.TwoDigitYearMax));
+ return _helper.ToFourDigitYear(year, TwoDigitYearMax);
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs
index 63636f5e3f..aa90a83e46 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs
@@ -2,54 +2,28 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
namespace System.Globalization
{
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 918/02/19 2051/02/10
- ** KoreanLunisolar 918/01/01 2050/13/29
- */
-
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 918/02/19 2051/02/10
+ /// KoreanLunisolar 918/01/01 2050/13/29
+ /// </remarks>
public class KoreanLunisolarCalendar : EastAsianLunisolarCalendar
{
- //
- // The era value for the current era.
- //
-
public const int GregorianEra = 1;
- internal const int MIN_LUNISOLAR_YEAR = 918;
- internal const int MAX_LUNISOLAR_YEAR = 2050;
-
- internal const int MIN_GREGORIAN_YEAR = 918;
- internal const int MIN_GREGORIAN_MONTH = 2;
- internal const int MIN_GREGORIAN_DAY = 19;
+ private const int MinLunisolarYear = 918;
+ private const int MaxLunisolarYear = 2050;
- internal const int MAX_GREGORIAN_YEAR = 2051;
- internal const int MAX_GREGORIAN_MONTH = 2;
- internal const int MAX_GREGORIAN_DAY = 10;
+ private static readonly DateTime s_minDate = new DateTime(918, 2, 19);
+ private static readonly DateTime s_maxDate = new DateTime((new DateTime(2051, 2, 10, 23, 59, 59, 999)).Ticks + 9999);
- internal static DateTime minDate = new DateTime(MIN_GREGORIAN_YEAR, MIN_GREGORIAN_MONTH, MIN_GREGORIAN_DAY);
- internal static DateTime maxDate = new DateTime((new DateTime(MAX_GREGORIAN_YEAR, MAX_GREGORIAN_MONTH, MAX_GREGORIAN_DAY, 23, 59, 59, 999)).Ticks + 9999);
+ public override DateTime MinSupportedDateTime => s_minDate;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (minDate);
- }
- }
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (maxDate);
- }
- }
+ public override DateTime MaxSupportedDateTime => s_maxDate;
protected override int DaysInYearBeforeMinSupportedYear
{
@@ -67,479 +41,479 @@ namespace System.Globalization
private static readonly int[,] s_yinfo =
{
/*Y LM Lmon Lday DaysPerMonth D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 #Days
-0918 */ { 00, 02, 19, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
-0919 */ { 00, 02, 09, 0b0100010111010000 }, /* 29 30 29 29 29 30 29 30 30 30 29 30 354
-0920 */ { 06, 01, 29, 0b1010001011011000 }, /* 30 29 30 29 29 29 30 29 30 30 29 30 30 384
-0921 */ { 00, 02, 16, 0b1010001010110000 }, /* 30 29 30 29 29 29 30 29 30 29 30 30 354
-0922 */ { 00, 02, 05, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-0923 */ { 04, 01, 25, 0b1011010010101000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 30 384
-0924 */ { 00, 02, 13, 0b0110110100100000 }, /* 29 30 30 29 30 30 29 30 29 29 30 29 354
-0925 */ { 12, 02, 01, 0b1010110101100000 }, /* 30 29 30 29 30 30 29 30 29 30 30 29 29 384
-0926 */ { 00, 02, 20, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-0927 */ { 00, 02, 10, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
-0928 */ { 08, 01, 31, 0b0100010110111000 }, /* 29 30 29 29 29 30 29 30 30 29 30 30 30 384
-0929 */ { 00, 02, 18, 0b0100010101110000 }, /* 29 30 29 29 29 30 29 30 29 30 30 30 354
-0930 */ { 00, 02, 07, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-0931 */ { 05, 01, 27, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 29 383
-0932 */ { 00, 02, 14, 0b1110100101010000 }, /* 30 30 30 29 30 29 29 30 29 30 29 30 355
-0933 */ { 00, 02, 03, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-0934 */ { 01, 01, 23, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 29 384
-0935 */ { 00, 02, 11, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
-0936 */ { 11, 02, 01, 0b0101001101100000 }, /* 29 30 29 30 29 29 30 30 29 30 30 29 29 383
-0937 */ { 00, 02, 18, 0b1100101011000000 }, /* 30 30 29 29 30 29 30 29 30 30 29 29 354
-0938 */ { 00, 02, 07, 0b1110010101100000 }, /* 30 30 30 29 29 30 29 30 29 30 30 29 355
-0939 */ { 07, 01, 28, 0b1101001010101000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 30 384
-0940 */ { 00, 02, 16, 0b1101001010100000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 354
-0941 */ { 00, 02, 04, 0b1101100101010000 }, /* 30 30 29 30 30 29 29 30 29 30 29 30 355
-0942 */ { 03, 01, 25, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
-0943 */ { 00, 02, 13, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
-0944 */ { 12, 02, 02, 0b1010011011010000 }, /* 30 29 30 29 29 30 30 29 30 30 29 30 29 384
-0945 */ { 00, 02, 20, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
-0946 */ { 00, 02, 10, 0b0100101011010000 }, /* 29 30 29 29 30 29 30 29 30 30 29 30 354
-0947 */ { 07, 01, 30, 0b1010010011011000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 30 384
-0948 */ { 00, 02, 18, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
-0949 */ { 00, 02, 06, 0b1011001001100000 }, /* 30 29 30 30 29 29 30 29 29 30 30 29 354
-0950 */ { 05, 01, 26, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
-0951 */ { 00, 02, 14, 0b1011001101110000 }, /* 30 29 30 30 29 29 30 30 29 30 30 30 356
-0953 */ { 00, 01, 05, 0b1010101011010000 }, /* 30 29 30 29 30 29 30 29 30 30 29 30 355
-0953 */ { 01, 01, 23, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 29 384
-0954 */ { 00, 02, 11, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
-0955 */ { 09, 02, 01, 0b0100101010111000 }, /* 29 30 29 29 30 29 30 29 30 29 30 30 30 384
-0956 */ { 00, 02, 20, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
-0957 */ { 00, 02, 08, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
-0958 */ { 07, 01, 28, 0b1010101010011000 }, /* 30 29 30 29 30 29 30 29 30 29 29 30 30 384
-0959 */ { 00, 02, 16, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-0960 */ { 00, 02, 05, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-0961 */ { 03, 01, 25, 0b0100110110101000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 30 384
-0962 */ { 00, 02, 13, 0b0010101101100000 }, /* 29 29 30 29 30 29 30 30 29 30 30 29 354
-0963 */ { 12, 02, 02, 0b1001010101110000 }, /* 30 29 29 30 29 30 29 30 29 30 30 30 29 384
-0964 */ { 00, 02, 21, 0b1010001101110000 }, /* 30 29 30 29 29 29 30 30 29 30 30 30 355
-0965 */ { 00, 02, 10, 0b0101000101110000 }, /* 29 30 29 30 29 29 29 30 29 30 30 30 354
-0966 */ { 08, 01, 30, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 29 383
-0967 */ { 00, 02, 17, 0b1101010010110000 }, /* 30 30 29 30 29 30 29 29 30 29 30 30 355
-0968 */ { 00, 02, 07, 0b0101101010010000 }, /* 29 30 29 30 30 29 30 29 30 29 29 30 354
-0969 */ { 05, 01, 26, 0b0110101101010000 }, /* 29 30 30 29 30 29 30 30 29 30 29 30 29 384
-0970 */ { 00, 02, 14, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 355
-0971 */ { 00, 02, 04, 0b0010101011100000 }, /* 29 29 30 29 30 29 30 29 30 30 30 29 354
-0972 */ { 02, 01, 24, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 29 384
-0973 */ { 00, 02, 11, 0b1010001011100000 }, /* 30 29 30 29 29 29 30 29 30 30 30 29 354
-0974 */ { 10, 01, 31, 0b1100100101101000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 30 384
-0975 */ { 00, 02, 19, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-0976 */ { 00, 02, 08, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
-0977 */ { 07, 01, 27, 0b1101101010010000 }, /* 30 30 29 30 30 29 30 29 30 29 29 30 29 384
-0978 */ { 00, 02, 15, 0b1011010110100000 }, /* 30 29 30 30 29 30 29 30 30 29 30 29 355
-0979 */ { 00, 02, 05, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 355
-0980 */ { 03, 01, 26, 0b0010101011011000 }, /* 29 29 30 29 30 29 30 29 30 30 29 30 30 384
-0981 */ { 00, 02, 13, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
-0982 */ { 12, 02, 02, 0b1001001011011000 }, /* 30 29 29 30 29 29 30 29 30 30 29 30 30 384
-0983 */ { 00, 02, 21, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
-0984 */ { 00, 02, 10, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-0985 */ { 09, 01, 29, 0b1011010010101000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 30 384
-0986 */ { 00, 02, 17, 0b1010110010100000 }, /* 30 29 30 29 30 30 29 29 30 29 30 29 354
-0987 */ { 00, 02, 06, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-0988 */ { 05, 01, 27, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 29 384
-0989 */ { 00, 02, 14, 0b0100101110110000 }, /* 29 30 29 29 30 29 30 30 30 29 30 30 355
-0990 */ { 00, 02, 04, 0b0010010110110000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 354
-0991 */ { 02, 01, 24, 0b1001001010111000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 30 384
-0992 */ { 00, 02, 12, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-0993 */ { 10, 01, 31, 0b0110100101011000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 30 384
-0994 */ { 00, 02, 19, 0b0101100101010000 }, /* 29 30 29 30 30 29 29 30 29 30 29 30 354
-0995 */ { 00, 02, 08, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-0996 */ { 07, 01, 28, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 29 384
-0997 */ { 00, 02, 15, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-0998 */ { 00, 02, 05, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
-0999 */ { 03, 01, 25, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 29 384
-1000 */ { 00, 02, 13, 0b0010010101110000 }, /* 29 29 30 29 29 30 29 30 29 30 30 30 354
-1001 */ { 12, 02, 03, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 29 383
-1002 */ { 00, 02, 21, 0b1101001010100000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 354
-1003 */ { 00, 02, 10, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
-1004 */ { 09, 01, 31, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
-1005 */ { 00, 02, 18, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
-1006 */ { 00, 02, 07, 0b1001011011010000 }, /* 30 29 29 30 29 30 30 29 30 30 29 30 355
-1007 */ { 05, 01, 28, 0b0100101011101000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 30 384
-1008 */ { 00, 02, 16, 0b0100101011010000 }, /* 29 30 29 29 30 29 30 29 30 30 29 30 354
-1009 */ { 00, 02, 04, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
-1010 */ { 02, 01, 24, 0b1101001001101000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 30 384
-1011 */ { 00, 02, 12, 0b1011001001100000 }, /* 30 29 30 30 29 29 30 29 29 30 30 29 354
-1012 */ { 10, 02, 01, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
-1013 */ { 00, 02, 19, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-1014 */ { 00, 02, 09, 0b0011010110100000 }, /* 29 29 30 30 29 30 29 30 30 29 30 29 354
-1015 */ { 06, 01, 29, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 29 384
-1016 */ { 00, 02, 17, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
-1017 */ { 00, 02, 06, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
-1018 */ { 04, 01, 26, 0b1010010011011000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 30 384
-1019 */ { 00, 02, 14, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
-1020 */ { 12, 02, 03, 0b1010101001011000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 30 384
-1021 */ { 00, 02, 21, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-1022 */ { 00, 02, 10, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-1023 */ { 09, 01, 31, 0b0010110110101000 }, /* 29 29 30 29 30 30 29 30 30 29 30 29 30 384
-1024 */ { 00, 02, 19, 0b0010101101010000 }, /* 29 29 30 29 30 29 30 30 29 30 29 30 354
-1025 */ { 00, 02, 07, 0b1001010101110000 }, /* 30 29 29 30 29 30 29 30 29 30 30 30 355
-1026 */ { 05, 01, 28, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 29 383
-1027 */ { 00, 02, 15, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 355
-1028 */ { 00, 02, 05, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
-1029 */ { 02, 01, 24, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
-1030 */ { 00, 02, 11, 0b1101101010010000 }, /* 30 30 29 30 30 29 30 29 30 29 29 30 355
-1031 */ { 10, 02, 01, 0b0110101101010000 }, /* 29 30 30 29 30 29 30 30 29 30 29 30 29 384
-1032 */ { 00, 02, 20, 0b0110011011010000 }, /* 29 30 30 29 29 30 30 29 30 30 29 30 355
-1033 */ { 00, 02, 09, 0b0010011011100000 }, /* 29 29 30 29 29 30 30 29 30 30 30 29 354
-1034 */ { 06, 01, 29, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 29 384
-1035 */ { 00, 02, 17, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
-1036 */ { 00, 02, 06, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
-1037 */ { 04, 01, 25, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
-1038 */ { 00, 02, 13, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
-1039 */ { 12, 02, 02, 0b1101011010010000 }, /* 30 30 29 30 29 30 30 29 30 29 29 30 29 384
-1040 */ { 00, 02, 21, 0b1011010110000000 }, /* 30 29 30 30 29 30 29 30 30 29 29 29 354
-1041 */ { 00, 02, 09, 0b1101011010110000 }, /* 30 30 29 30 29 30 30 29 30 29 30 30 356
-1042 */ { 09, 01, 31, 0b0010011011011000 }, /* 29 29 30 29 29 30 30 29 30 30 29 30 30 384
-1043 */ { 00, 02, 19, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
-1044 */ { 00, 02, 08, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
-1045 */ { 05, 01, 27, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
-1046 */ { 00, 02, 15, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-1047 */ { 00, 02, 04, 0b1011010010100000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 354
-1048 */ { 01, 01, 24, 0b1011010101011000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 30 385
-1049 */ { 00, 02, 12, 0b0010110101010000 }, /* 29 29 30 29 30 30 29 30 29 30 29 30 354
-1050 */ { 11, 02, 01, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 29 384
-1051 */ { 00, 02, 20, 0b0100101110110000 }, /* 29 30 29 29 30 29 30 30 30 29 30 30 355
-1052 */ { 00, 02, 10, 0b0010010110110000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 354
-1053 */ { 07, 01, 29, 0b0101001010111000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 30 384
-1054 */ { 00, 02, 17, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-1055 */ { 00, 02, 06, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 354
-1056 */ { 03, 01, 26, 0b0110101010101000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 30 384
-1057 */ { 00, 02, 13, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-1058 */ { 12, 02, 02, 0b1010101101011000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 30 385
-1059 */ { 00, 02, 22, 0b0010011101010000 }, /* 29 29 30 29 29 30 30 30 29 30 29 30 354
-1060 */ { 00, 02, 11, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
-1061 */ { 08, 01, 30, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 29 384
-1062 */ { 00, 02, 18, 0b1010010101100000 }, /* 30 29 30 29 29 30 29 30 29 30 30 29 354
-1063 */ { 00, 02, 07, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
-1064 */ { 05, 01, 27, 0b1110100100110000 }, /* 30 30 30 29 30 29 29 30 29 29 30 30 29 384
-1065 */ { 00, 02, 14, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
-1066 */ { 00, 02, 04, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1067 */ { 01, 01, 24, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 29 384
-1068 */ { 00, 02, 12, 0b1001011011010000 }, /* 30 29 29 30 29 30 30 29 30 30 29 30 355
-1069 */ { 11, 02, 01, 0b0100101011101000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 30 384
-1070 */ { 00, 02, 20, 0b0100100111010000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 354
-1071 */ { 00, 02, 09, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
-1072 */ { 07, 01, 29, 0b1101001001101000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 30 384
-1073 */ { 00, 02, 16, 0b1010101001100000 }, /* 30 29 30 29 30 29 30 29 29 30 30 29 354
-1074 */ { 00, 02, 05, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
-1075 */ { 04, 01, 26, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
-1076 */ { 00, 02, 14, 0b0011010110100000 }, /* 29 29 30 30 29 30 29 30 30 29 30 29 354
-1077 */ { 00, 02, 02, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
-1078 */ { 01, 01, 23, 0b0100101110011000 }, /* 29 30 29 29 30 29 30 30 30 29 29 30 30 384
-1079 */ { 00, 02, 11, 0b0100010110110000 }, /* 29 30 29 29 29 30 29 30 30 29 30 30 354
-1080 */ { 09, 01, 31, 0b1010010010111000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 30 384
-1081 */ { 00, 02, 18, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
-1082 */ { 00, 02, 07, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
-1083 */ { 06, 01, 27, 0b1011010101001000 }, /* 30 29 30 30 29 30 29 30 29 30 29 29 30 384
-1084 */ { 00, 02, 15, 0b0110101101010000 }, /* 29 30 30 29 30 29 30 30 29 30 29 30 355
-1085 */ { 00, 02, 04, 0b0010110110100000 }, /* 29 29 30 29 30 30 29 30 30 29 30 29 354
-1086 */ { 02, 01, 24, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 29 384
-1087 */ { 00, 02, 12, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 355
-1088 */ { 12, 02, 02, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 29 383
-1089 */ { 00, 02, 19, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 355
-1090 */ { 00, 02, 09, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
-1091 */ { 08, 01, 29, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
-1092 */ { 00, 02, 16, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 355
-1093 */ { 00, 02, 05, 0b0101101101000000 }, /* 29 30 29 30 30 29 30 30 29 30 29 29 354
-1094 */ { 04, 01, 25, 0b1010101101101000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 30 385
-1095 */ { 00, 02, 14, 0b0010101011100000 }, /* 29 29 30 29 30 29 30 29 30 30 30 29 354
-1096 */ { 00, 02, 03, 0b1110011000010000 }, /* 30 30 30 29 29 30 30 29 29 29 29 30 354
-1097 */ { 02, 01, 22, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 29 384
-1098 */ { 00, 02, 10, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
-1099 */ { 09, 01, 30, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
-1100 */ { 00, 02, 18, 0b0101010010100000 }, /* 29 30 29 30 29 30 29 29 30 29 30 29 353
-1101 */ { 00, 02, 07, 0b1101011001010000 }, /* 30 30 29 30 29 30 30 29 29 30 29 30 355
-1102 */ { 06, 01, 28, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
-1103 */ { 00, 02, 16, 0b0101010111010000 }, /* 29 30 29 30 29 30 29 30 30 30 29 30 355
-1104 */ { 00, 02, 06, 0b0010011011010000 }, /* 29 29 30 29 29 30 30 29 30 30 29 30 354
-1105 */ { 02, 01, 25, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
-1106 */ { 00, 02, 13, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
-1107 */ { 10, 02, 02, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
-1108 */ { 00, 02, 21, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-1109 */ { 00, 02, 09, 0b1011010010100000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 354
-1110 */ { 08, 01, 29, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
-1111 */ { 00, 02, 17, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-1112 */ { 00, 02, 07, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
-1113 */ { 04, 01, 27, 0b0010010110111000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 30 384
-1114 */ { 00, 02, 15, 0b0100010101110000 }, /* 29 30 29 29 29 30 29 30 29 30 30 30 354
-1115 */ { 00, 02, 04, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-1116 */ { 01, 01, 24, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
-1117 */ { 00, 02, 11, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 354
-1118 */ { 09, 01, 31, 0b0111001010101000 }, /* 29 30 30 30 29 29 30 29 30 29 30 29 30 384
-1119 */ { 00, 02, 19, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1120 */ { 00, 02, 08, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
-1121 */ { 05, 01, 28, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
-1122 */ { 00, 02, 16, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
-1123 */ { 00, 02, 05, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
-1124 */ { 03, 01, 26, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 29 383
-1125 */ { 00, 02, 12, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
-1126 */ { 11, 02, 01, 0b1110100100110000 }, /* 30 30 30 29 30 29 29 30 29 29 30 30 29 384
-1127 */ { 00, 02, 20, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
-1128 */ { 00, 02, 10, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1129 */ { 08, 01, 29, 0b1001101110010000 }, /* 30 29 29 30 30 29 30 30 30 29 29 30 29 384
-1130 */ { 00, 02, 17, 0b1001011011010000 }, /* 30 29 29 30 29 30 30 29 30 30 29 30 355
-1131 */ { 00, 02, 07, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
-1132 */ { 04, 01, 27, 0b1010010011101000 }, /* 30 29 30 29 29 30 29 29 30 30 30 29 30 384
-1133 */ { 00, 02, 14, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
-1134 */ { 00, 02, 03, 0b1101001001010000 }, /* 30 30 29 30 29 29 30 29 29 30 29 30 354
-1135 */ { 02, 01, 23, 0b1101100100101000 }, /* 30 30 29 30 30 29 29 30 29 29 30 29 30 384
-1136 */ { 00, 02, 11, 0b1011010101000000 }, /* 30 29 30 30 29 30 29 30 29 30 29 29 354
-1137 */ { 10, 01, 30, 0b1101011010101000 }, /* 30 30 29 30 29 30 30 29 30 29 30 29 30 385
-1138 */ { 00, 02, 19, 0b0010110110100000 }, /* 29 29 30 29 30 30 29 30 30 29 30 29 354
-1139 */ { 00, 02, 08, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
-1140 */ { 06, 01, 29, 0b0100101011011000 }, /* 29 30 29 29 30 29 30 29 30 30 29 30 30 384
-1141 */ { 00, 02, 16, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
-1142 */ { 00, 02, 05, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
-1143 */ { 04, 01, 25, 0b1011001001011000 }, /* 30 29 30 30 29 29 30 29 29 30 29 30 30 384
-1144 */ { 00, 02, 13, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
-1145 */ { 11, 02, 01, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
-1146 */ { 00, 02, 20, 0b0110101101000000 }, /* 29 30 30 29 30 29 30 30 29 30 29 29 354
-1147 */ { 00, 02, 09, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-1148 */ { 08, 01, 30, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 29 384
-1149 */ { 00, 02, 17, 0b1001100101110000 }, /* 30 29 29 30 30 29 29 30 29 30 30 30 355
-1150 */ { 00, 02, 07, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
-1151 */ { 04, 01, 27, 0b0110010010111000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 30 384
-1152 */ { 00, 02, 15, 0b0101010010110000 }, /* 29 30 29 30 29 30 29 29 30 29 30 30 354
-1153 */ { 12, 02, 03, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
-1154 */ { 00, 02, 21, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 355
-1155 */ { 00, 02, 11, 0b0101101011000000 }, /* 29 30 29 30 30 29 30 29 30 30 29 29 354
-1156 */ { 10, 01, 31, 0b1010101101101000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 30 385
-1157 */ { 00, 02, 19, 0b0010011011100000 }, /* 29 29 30 29 29 30 30 29 30 30 30 29 354
-1158 */ { 00, 02, 08, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
-1159 */ { 06, 01, 28, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 29 384
-1160 */ { 00, 02, 16, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
-1161 */ { 00, 02, 04, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
-1162 */ { 02, 01, 24, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 29 384
-1163 */ { 00, 02, 12, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
-1164 */ { 11, 02, 02, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
-1165 */ { 00, 02, 20, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
-1166 */ { 00, 02, 10, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
-1167 */ { 07, 01, 30, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
-1168 */ { 00, 02, 18, 0b1001001001110000 }, /* 30 29 29 30 29 29 30 29 29 30 30 30 354
-1169 */ { 00, 02, 06, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-1170 */ { 05, 01, 26, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
-1171 */ { 00, 02, 14, 0b1011010010100000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 354
-1172 */ { 00, 02, 03, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
-1173 */ { 01, 01, 23, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
-1174 */ { 00, 02, 11, 0b0100110110110000 }, /* 29 30 29 29 30 30 29 30 30 29 30 30 355
-1175 */ { 09, 02, 01, 0b0010010110110000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 29 383
-1176 */ { 00, 02, 19, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
-1177 */ { 00, 02, 08, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-1178 */ { 06, 01, 28, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
-1179 */ { 00, 02, 16, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 354
-1180 */ { 00, 02, 05, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-1181 */ { 03, 01, 24, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 29 384
-1182 */ { 00, 02, 12, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
-1183 */ { 11, 02, 02, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
-1184 */ { 00, 02, 21, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
-1185 */ { 00, 02, 09, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
-1186 */ { 07, 01, 30, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 29 383
-1187 */ { 00, 02, 17, 0b1101000010010000 }, /* 30 30 29 30 29 29 29 29 30 29 29 30 353
-1188 */ { 00, 01, 08, 0b0111010010011000 }, /* 29 30 30 30 29 30 29 29 30 29 29 30 354
-1189 */ { 05, 01, 26, 0b0110101010101000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 30 384
-1190 */ { 00, 02, 14, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1191 */ { 00, 02, 03, 0b1001101101010000 }, /* 30 29 29 30 30 29 30 30 29 30 29 30 355
-1192 */ { 02, 01, 24, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
-1193 */ { 00, 02, 11, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
-1194 */ { 10, 01, 31, 0b1010010011101000 }, /* 30 29 30 29 29 30 29 29 30 30 30 29 30 384
-1195 */ { 00, 02, 19, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
-1196 */ { 00, 02, 08, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
-1197 */ { 06, 01, 27, 0b1101010100101000 }, /* 30 30 29 30 29 30 29 30 29 29 30 29 30 384
-1198 */ { 00, 02, 15, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
-1199 */ { 00, 02, 04, 0b1101011010100000 }, /* 30 30 29 30 29 30 30 29 30 29 30 29 355
-1200 */ { 02, 01, 25, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 29 384
-1201 */ { 00, 02, 12, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
-1202 */ { 12, 02, 02, 0b0100100111011000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 30 384
-1203 */ { 00, 02, 21, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
-1204 */ { 00, 02, 10, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
-1205 */ { 08, 01, 29, 0b1010101001011000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 30 384
-1206 */ { 00, 02, 17, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
-1207 */ { 00, 02, 06, 0b1011010101000000 }, /* 30 29 30 30 29 30 29 30 29 30 29 29 354
-1208 */ { 04, 01, 26, 0b1011010110100000 }, /* 30 29 30 30 29 30 29 30 30 29 30 29 29 384
-1209 */ { 00, 02, 13, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-1210 */ { 00, 02, 03, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
-1211 */ { 02, 01, 24, 0b0100100110111000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 30 384
-1212 */ { 00, 02, 12, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
-1213 */ { 09, 01, 31, 0b0110010010111000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 30 384
-1214 */ { 00, 02, 19, 0b0101010010110000 }, /* 29 30 29 30 29 30 29 29 30 29 30 30 354
-1215 */ { 00, 02, 08, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
-1216 */ { 07, 01, 28, 0b0110110100101000 }, /* 29 30 30 29 30 30 29 30 29 29 30 29 30 384
-1217 */ { 00, 02, 15, 0b0101101011000000 }, /* 29 30 29 30 30 29 30 29 30 30 29 29 354
-1218 */ { 00, 02, 04, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-1219 */ { 03, 01, 25, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 29 384
-1220 */ { 00, 02, 13, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
-1221 */ { 12, 02, 01, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 29 384
-1222 */ { 00, 02, 20, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
-1223 */ { 00, 02, 09, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
-1224 */ { 08, 01, 29, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 29 384
-1225 */ { 00, 02, 16, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
-1226 */ { 00, 02, 06, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
-1227 */ { 05, 01, 26, 0b1010101011011000 }, /* 30 29 30 29 30 29 30 29 30 30 29 30 30 385
-1228 */ { 00, 02, 15, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
-1229 */ { 00, 02, 03, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
-1230 */ { 02, 01, 23, 0b1100100101011000 }, /* 30 30 29 29 30 29 29 30 29 30 29 30 30 384
-1231 */ { 00, 02, 11, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-1232 */ { 09, 01, 31, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
-1233 */ { 00, 02, 18, 0b1011001010100000 }, /* 30 29 30 30 29 29 30 29 30 29 30 29 354
-1234 */ { 00, 02, 07, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
-1235 */ { 07, 01, 28, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
-1236 */ { 00, 02, 16, 0b0100110110100000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 354
-1237 */ { 00, 02, 04, 0b1010010110110000 }, /* 30 29 30 29 29 30 29 30 30 29 30 30 355
-1238 */ { 04, 01, 25, 0b0101001010111000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 30 384
-1239 */ { 00, 02, 13, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-1240 */ { 12, 02, 02, 0b1010100100111000 }, /* 30 29 30 29 30 29 29 30 29 29 30 30 30 384
-1241 */ { 00, 02, 20, 0b0110100100110000 }, /* 29 30 30 29 30 29 29 30 29 29 30 30 354
-1242 */ { 00, 02, 09, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-1243 */ { 08, 01, 29, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 29 384
-1244 */ { 00, 02, 17, 0b1010111001010000 }, /* 30 29 30 29 30 30 30 29 29 30 29 30 355
-1245 */ { 00, 02, 06, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
-1246 */ { 04, 01, 26, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 29 384
-1247 */ { 00, 02, 14, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
-1248 */ { 00, 02, 04, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 354
-1249 */ { 02, 01, 23, 0b0110100100110000 }, /* 29 30 30 29 30 29 29 30 29 29 30 30 29 383
-1250 */ { 00, 02, 10, 0b1110010100110000 }, /* 30 30 30 29 29 30 29 30 29 29 30 30 355
-1251 */ { 10, 01, 31, 0b0110110010011000 }, /* 29 30 30 29 30 30 29 29 30 29 29 30 30 384
-1252 */ { 00, 02, 19, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1253 */ { 00, 02, 07, 0b0101101011010000 }, /* 29 30 29 30 30 29 30 29 30 30 29 30 355
-1254 */ { 06, 01, 28, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
-1255 */ { 00, 02, 16, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
-1256 */ { 00, 02, 05, 0b1010010011100000 }, /* 30 29 30 29 29 30 29 29 30 30 30 29 354
-1257 */ { 04, 01, 24, 0b1101001001101000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 30 384
-1258 */ { 00, 02, 12, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
-1259 */ { 11, 02, 01, 0b1101010100101000 }, /* 30 30 29 30 29 30 29 30 29 29 30 29 30 384
-1260 */ { 00, 02, 20, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
-1261 */ { 00, 02, 08, 0b1011011010100000 }, /* 30 29 30 30 29 30 30 29 30 29 30 29 355
-1262 */ { 09, 01, 29, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 29 384
-1263 */ { 00, 02, 17, 0b0101010101110000 }, /* 29 30 29 30 29 30 29 30 29 30 30 30 355
-1264 */ { 00, 02, 07, 0b0100100111010000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 354
-1265 */ { 05, 01, 26, 0b1010010011011000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 30 384
-1266 */ { 00, 02, 14, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
-1267 */ { 00, 02, 03, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
-1268 */ { 01, 01, 23, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
-1269 */ { 00, 02, 10, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
-1270 */ { 11, 01, 30, 0b1011010111000000 }, /* 30 29 30 30 29 30 29 30 30 30 29 29 29 384
-1271 */ { 00, 02, 18, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-1272 */ { 00, 02, 08, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
-1273 */ { 06, 01, 28, 0b0100100110111000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 30 384
-1274 */ { 00, 02, 16, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
-1275 */ { 00, 02, 05, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
-1276 */ { 03, 01, 25, 0b0110101001011000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 30 384
-1277 */ { 00, 02, 12, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
-1278 */ { 11, 02, 01, 0b0110101100101000 }, /* 29 30 30 29 30 29 30 30 29 29 30 29 30 384
-1279 */ { 00, 02, 20, 0b0101101011000000 }, /* 29 30 29 30 30 29 30 29 30 30 29 29 354
-1280 */ { 00, 02, 09, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-1281 */ { 08, 01, 29, 0b0010101011101000 }, /* 29 29 30 29 30 29 30 29 30 30 30 29 30 384
-1282 */ { 00, 02, 17, 0b0100100111100000 }, /* 29 30 29 29 30 29 29 30 30 30 30 29 354
-1283 */ { 00, 02, 06, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
-1284 */ { 05, 01, 26, 0b1101001001011000 }, /* 30 30 29 30 29 29 30 29 29 30 29 30 30 384
-1285 */ { 00, 02, 13, 0b1011001001010000 }, /* 30 29 30 30 29 29 30 29 29 30 29 30 354
-1286 */ { 00, 02, 02, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
-1287 */ { 02, 01, 22, 0b1111001010010000 }, /* 30 30 30 30 29 29 30 29 30 29 29 30 29 384
-1288 */ { 00, 02, 10, 0b1011010110100000 }, /* 30 29 30 30 29 30 29 30 30 29 30 29 355
-1289 */ { 10, 01, 30, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 29 384
-1290 */ { 00, 02, 18, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
-1291 */ { 00, 02, 08, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
-1292 */ { 06, 01, 28, 0b1010010010111000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 30 384
-1293 */ { 00, 02, 15, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
-1294 */ { 00, 02, 04, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
-1295 */ { 04, 01, 24, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
-1296 */ { 00, 02, 12, 0b0110110101000000 }, /* 29 30 30 29 30 30 29 30 29 30 29 29 354
-1297 */ { 12, 01, 31, 0b1010110101100000 }, /* 30 29 30 29 30 30 29 30 29 30 30 29 29 384
-1298 */ { 00, 02, 19, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
-1299 */ { 00, 02, 09, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 355
-1300 */ { 08, 01, 30, 0b0000100101111000 }, /* 29 29 29 29 30 29 29 30 29 30 30 30 30 383
-1301 */ { 00, 02, 18, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
-1302 */ { 00, 02, 07, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
-1303 */ { 05, 01, 27, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
-1304 */ { 00, 02, 14, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 355
-1305 */ { 00, 02, 03, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1306 */ { 01, 01, 23, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 29 384
-1307 */ { 00, 02, 11, 0b1010011011100000 }, /* 30 29 30 29 29 30 30 29 30 30 30 29 355
-1308 */ { 11, 02, 01, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
-1309 */ { 00, 02, 19, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
-1310 */ { 00, 02, 08, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
-1311 */ { 07, 01, 28, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
-1312 */ { 00, 02, 16, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
-1313 */ { 00, 02, 04, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
-1314 */ { 03, 01, 25, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
-1315 */ { 00, 02, 13, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
-1316 */ { 00, 02, 02, 0b1010011011010000 }, /* 30 29 30 29 29 30 30 29 30 30 29 30 355
-1317 */ { 01, 01, 22, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
-1318 */ { 00, 02, 10, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
-1319 */ { 08, 01, 30, 0b1010010101011000 }, /* 30 29 30 29 29 30 29 30 29 30 29 30 30 384
-1320 */ { 00, 02, 18, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
-1321 */ { 00, 02, 06, 0b1011001010100000 }, /* 30 29 30 30 29 29 30 29 30 29 30 29 354
-1322 */ { 05, 01, 26, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
-1323 */ { 00, 02, 14, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-1324 */ { 00, 02, 04, 0b0100110110100000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 354
-1325 */ { 01, 01, 23, 0b1010010111010000 }, /* 30 29 30 29 29 30 29 30 30 30 29 30 29 384
-1326 */ { 00, 02, 11, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
-1327 */ { 09, 02, 01, 0b0101001010111000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 30 384
-1328 */ { 00, 02, 20, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 354
-1329 */ { 00, 02, 08, 0b0110100100110000 }, /* 29 30 30 29 30 29 29 30 29 29 30 30 354
-1330 */ { 07, 01, 28, 0b0110101010011000 }, /* 29 30 30 29 30 29 30 29 30 29 29 30 30 384
-1331 */ { 00, 02, 16, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
-1332 */ { 00, 02, 05, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
-1333 */ { 03, 01, 25, 0b0100101110101000 }, /* 29 30 29 29 30 29 30 30 30 29 30 29 30 384
-1334 */ { 00, 02, 13, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
-1335 */ { 12, 02, 02, 0b1010011001110000 }, /* 30 29 30 29 29 30 30 29 29 30 30 30 29 384
-1336 */ { 00, 02, 21, 0b1010001011100000 }, /* 30 29 30 29 29 29 30 29 30 30 30 29 354
-1337 */ { 00, 02, 09, 0b1101000101100000 }, /* 30 30 29 30 29 29 29 30 29 30 30 29 354
-1338 */ { 08, 01, 29, 0b1110100100110000 }, /* 30 30 30 29 30 29 29 30 29 29 30 30 29 384
-1339 */ { 00, 02, 17, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
-1340 */ { 00, 02, 06, 0b1101101010100000 }, /* 30 30 29 30 30 29 30 29 30 29 30 29 355
-1341 */ { 05, 01, 26, 0b0101101101010000 }, /* 29 30 29 30 30 29 30 30 29 30 29 30 29 384
-1342 */ { 00, 02, 14, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 355
-1343 */ { 00, 02, 04, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
-1344 */ { 02, 01, 24, 0b1010001011101000 }, /* 30 29 30 29 29 29 30 29 30 30 30 29 30 384
-1345 */ { 00, 02, 11, 0b1010001011010000 }, /* 30 29 30 29 29 29 30 29 30 30 29 30 354
-1346 */ { 10, 01, 31, 0b1101000101011000 }, /* 30 30 29 30 29 29 29 30 29 30 29 30 30 384
-1347 */ { 00, 02, 19, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
-1348 */ { 00, 02, 08, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
-1349 */ { 07, 01, 27, 0b1101011010100000 }, /* 30 30 29 30 29 30 30 29 30 29 30 29 29 384
-1350 */ { 00, 02, 15, 0b1010110110100000 }, /* 30 29 30 29 30 30 29 30 30 29 30 29 355
-1351 */ { 00, 02, 05, 0b0101010111010000 }, /* 29 30 29 30 29 30 29 30 30 30 29 30 355
-1352 */ { 03, 01, 26, 0b0100100111011000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 30 384
-1353 */ { 00, 02, 13, 0b0100010110110000 }, /* 29 30 29 29 29 30 29 30 30 29 30 30 354
-1354 */ { 00, 02, 02, 0b1010001010110000 }, /* 30 29 30 29 29 29 30 29 30 29 30 30 354
-1355 */ { 01, 01, 22, 0b1101000101011000 }, /* 30 30 29 30 29 29 29 30 29 30 29 30 30 384
-1356 */ { 00, 02, 10, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
-1357 */ { 09, 01, 29, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
-1358 */ { 00, 02, 17, 0b0110101100100000 }, /* 29 30 30 29 30 29 30 30 29 29 30 29 354
-1359 */ { 00, 02, 06, 0b1010110101100000 }, /* 30 29 30 29 30 30 29 30 29 30 30 29 355
-1360 */ { 05, 01, 27, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 29 384
-1361 */ { 00, 02, 14, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 355
-1362 */ { 00, 02, 04, 0b0100010101110000 }, /* 29 30 29 29 29 30 29 30 29 30 30 30 354
-1363 */ { 03, 01, 24, 0b1010001010111000 }, /* 30 29 30 29 29 29 30 29 30 29 30 30 30 384
-1364 */ { 00, 02, 12, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-1365 */ { 10, 01, 31, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 29 383
-1366 */ { 00, 02, 18, 0b1101100101010000 }, /* 30 30 29 30 30 29 29 30 29 30 29 30 355
-1367 */ { 00, 02, 08, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
-1368 */ { 07, 01, 28, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 29 384
-1369 */ { 00, 02, 15, 0b1010011011100000 }, /* 30 29 30 29 29 30 30 29 30 30 30 29 355
-1370 */ { 00, 02, 05, 0b0101001011100000 }, /* 29 30 29 30 29 29 30 29 30 30 30 29 354
-1371 */ { 03, 01, 25, 0b1100010101110000 }, /* 30 30 29 29 29 30 29 30 29 30 30 30 29 384
-1372 */ { 00, 02, 13, 0b1010010101100000 }, /* 30 29 30 29 29 30 29 30 29 30 30 29 354
-1373 */ { 11, 02, 01, 0b1101001010101000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 30 384
-1374 */ { 00, 02, 20, 0b1101001010100000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 354
-1375 */ { 00, 02, 09, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
-1376 */ { 09, 01, 30, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
-1377 */ { 00, 02, 17, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
-1378 */ { 00, 02, 06, 0b1010011011010000 }, /* 30 29 30 29 29 30 30 29 30 30 29 30 355
-1379 */ { 05, 01, 27, 0b0101001011101000 }, /* 29 30 29 30 29 29 30 29 30 30 30 29 30 384
-1380 */ { 00, 02, 15, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
-1381 */ { 00, 02, 03, 0b1010100011010000 }, /* 30 29 30 29 30 29 29 29 30 30 29 30 354
-1382 */ { 02, 01, 23, 0b1101001010101000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 30 384
-1383 */ { 00, 02, 11, 0b1011001010100000 }, /* 30 29 30 30 29 29 30 29 30 29 30 29 354
-1384 */ { 10, 01, 31, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
-1385 */ { 00, 02, 18, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
-1386 */ { 00, 02, 08, 0b0100110110100000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 354
-1387 */ { 06, 01, 28, 0b1010010111010000 }, /* 30 29 30 29 29 30 29 30 30 30 29 30 29 384
-1388 */ { 00, 02, 16, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
-1389 */ { 00, 02, 05, 0b0101000110110000 }, /* 29 30 29 30 29 29 29 30 30 29 30 30 354
-1390 */ { 04, 01, 25, 0b1010100010111000 }, /* 30 29 30 29 30 29 29 29 30 29 30 30 30 384
+0918 */ { 00, 02, 19, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
+0919 */ { 00, 02, 09, 0b0100010111010000 }, /* 29 30 29 29 29 30 29 30 30 30 29 30 354
+0920 */ { 06, 01, 29, 0b1010001011011000 }, /* 30 29 30 29 29 29 30 29 30 30 29 30 30 384
+0921 */ { 00, 02, 16, 0b1010001010110000 }, /* 30 29 30 29 29 29 30 29 30 29 30 30 354
+0922 */ { 00, 02, 05, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+0923 */ { 04, 01, 25, 0b1011010010101000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 30 384
+0924 */ { 00, 02, 13, 0b0110110100100000 }, /* 29 30 30 29 30 30 29 30 29 29 30 29 354
+0925 */ { 12, 02, 01, 0b1010110101100000 }, /* 30 29 30 29 30 30 29 30 29 30 30 29 29 384
+0926 */ { 00, 02, 20, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+0927 */ { 00, 02, 10, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
+0928 */ { 08, 01, 31, 0b0100010110111000 }, /* 29 30 29 29 29 30 29 30 30 29 30 30 30 384
+0929 */ { 00, 02, 18, 0b0100010101110000 }, /* 29 30 29 29 29 30 29 30 29 30 30 30 354
+0930 */ { 00, 02, 07, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+0931 */ { 05, 01, 27, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 29 383
+0932 */ { 00, 02, 14, 0b1110100101010000 }, /* 30 30 30 29 30 29 29 30 29 30 29 30 355
+0933 */ { 00, 02, 03, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+0934 */ { 01, 01, 23, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 29 384
+0935 */ { 00, 02, 11, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
+0936 */ { 11, 02, 01, 0b0101001101100000 }, /* 29 30 29 30 29 29 30 30 29 30 30 29 29 383
+0937 */ { 00, 02, 18, 0b1100101011000000 }, /* 30 30 29 29 30 29 30 29 30 30 29 29 354
+0938 */ { 00, 02, 07, 0b1110010101100000 }, /* 30 30 30 29 29 30 29 30 29 30 30 29 355
+0939 */ { 07, 01, 28, 0b1101001010101000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 30 384
+0940 */ { 00, 02, 16, 0b1101001010100000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 354
+0941 */ { 00, 02, 04, 0b1101100101010000 }, /* 30 30 29 30 30 29 29 30 29 30 29 30 355
+0942 */ { 03, 01, 25, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
+0943 */ { 00, 02, 13, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
+0944 */ { 12, 02, 02, 0b1010011011010000 }, /* 30 29 30 29 29 30 30 29 30 30 29 30 29 384
+0945 */ { 00, 02, 20, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
+0946 */ { 00, 02, 10, 0b0100101011010000 }, /* 29 30 29 29 30 29 30 29 30 30 29 30 354
+0947 */ { 07, 01, 30, 0b1010010011011000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 30 384
+0948 */ { 00, 02, 18, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
+0949 */ { 00, 02, 06, 0b1011001001100000 }, /* 30 29 30 30 29 29 30 29 29 30 30 29 354
+0950 */ { 05, 01, 26, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
+0951 */ { 00, 02, 14, 0b1011001101110000 }, /* 30 29 30 30 29 29 30 30 29 30 30 30 356
+0953 */ { 00, 01, 05, 0b1010101011010000 }, /* 30 29 30 29 30 29 30 29 30 30 29 30 355
+0953 */ { 01, 01, 23, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 29 384
+0954 */ { 00, 02, 11, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
+0955 */ { 09, 02, 01, 0b0100101010111000 }, /* 29 30 29 29 30 29 30 29 30 29 30 30 30 384
+0956 */ { 00, 02, 20, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
+0957 */ { 00, 02, 08, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
+0958 */ { 07, 01, 28, 0b1010101010011000 }, /* 30 29 30 29 30 29 30 29 30 29 29 30 30 384
+0959 */ { 00, 02, 16, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+0960 */ { 00, 02, 05, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+0961 */ { 03, 01, 25, 0b0100110110101000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 30 384
+0962 */ { 00, 02, 13, 0b0010101101100000 }, /* 29 29 30 29 30 29 30 30 29 30 30 29 354
+0963 */ { 12, 02, 02, 0b1001010101110000 }, /* 30 29 29 30 29 30 29 30 29 30 30 30 29 384
+0964 */ { 00, 02, 21, 0b1010001101110000 }, /* 30 29 30 29 29 29 30 30 29 30 30 30 355
+0965 */ { 00, 02, 10, 0b0101000101110000 }, /* 29 30 29 30 29 29 29 30 29 30 30 30 354
+0966 */ { 08, 01, 30, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 29 383
+0967 */ { 00, 02, 17, 0b1101010010110000 }, /* 30 30 29 30 29 30 29 29 30 29 30 30 355
+0968 */ { 00, 02, 07, 0b0101101010010000 }, /* 29 30 29 30 30 29 30 29 30 29 29 30 354
+0969 */ { 05, 01, 26, 0b0110101101010000 }, /* 29 30 30 29 30 29 30 30 29 30 29 30 29 384
+0970 */ { 00, 02, 14, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 355
+0971 */ { 00, 02, 04, 0b0010101011100000 }, /* 29 29 30 29 30 29 30 29 30 30 30 29 354
+0972 */ { 02, 01, 24, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 29 384
+0973 */ { 00, 02, 11, 0b1010001011100000 }, /* 30 29 30 29 29 29 30 29 30 30 30 29 354
+0974 */ { 10, 01, 31, 0b1100100101101000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 30 384
+0975 */ { 00, 02, 19, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+0976 */ { 00, 02, 08, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
+0977 */ { 07, 01, 27, 0b1101101010010000 }, /* 30 30 29 30 30 29 30 29 30 29 29 30 29 384
+0978 */ { 00, 02, 15, 0b1011010110100000 }, /* 30 29 30 30 29 30 29 30 30 29 30 29 355
+0979 */ { 00, 02, 05, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 355
+0980 */ { 03, 01, 26, 0b0010101011011000 }, /* 29 29 30 29 30 29 30 29 30 30 29 30 30 384
+0981 */ { 00, 02, 13, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
+0982 */ { 12, 02, 02, 0b1001001011011000 }, /* 30 29 29 30 29 29 30 29 30 30 29 30 30 384
+0983 */ { 00, 02, 21, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
+0984 */ { 00, 02, 10, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+0985 */ { 09, 01, 29, 0b1011010010101000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 30 384
+0986 */ { 00, 02, 17, 0b1010110010100000 }, /* 30 29 30 29 30 30 29 29 30 29 30 29 354
+0987 */ { 00, 02, 06, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+0988 */ { 05, 01, 27, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 29 384
+0989 */ { 00, 02, 14, 0b0100101110110000 }, /* 29 30 29 29 30 29 30 30 30 29 30 30 355
+0990 */ { 00, 02, 04, 0b0010010110110000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 354
+0991 */ { 02, 01, 24, 0b1001001010111000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 30 384
+0992 */ { 00, 02, 12, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+0993 */ { 10, 01, 31, 0b0110100101011000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 30 384
+0994 */ { 00, 02, 19, 0b0101100101010000 }, /* 29 30 29 30 30 29 29 30 29 30 29 30 354
+0995 */ { 00, 02, 08, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+0996 */ { 07, 01, 28, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 29 384
+0997 */ { 00, 02, 15, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+0998 */ { 00, 02, 05, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
+0999 */ { 03, 01, 25, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 29 384
+1000 */ { 00, 02, 13, 0b0010010101110000 }, /* 29 29 30 29 29 30 29 30 29 30 30 30 354
+1001 */ { 12, 02, 03, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 29 383
+1002 */ { 00, 02, 21, 0b1101001010100000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 354
+1003 */ { 00, 02, 10, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
+1004 */ { 09, 01, 31, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
+1005 */ { 00, 02, 18, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
+1006 */ { 00, 02, 07, 0b1001011011010000 }, /* 30 29 29 30 29 30 30 29 30 30 29 30 355
+1007 */ { 05, 01, 28, 0b0100101011101000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 30 384
+1008 */ { 00, 02, 16, 0b0100101011010000 }, /* 29 30 29 29 30 29 30 29 30 30 29 30 354
+1009 */ { 00, 02, 04, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
+1010 */ { 02, 01, 24, 0b1101001001101000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 30 384
+1011 */ { 00, 02, 12, 0b1011001001100000 }, /* 30 29 30 30 29 29 30 29 29 30 30 29 354
+1012 */ { 10, 02, 01, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
+1013 */ { 00, 02, 19, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+1014 */ { 00, 02, 09, 0b0011010110100000 }, /* 29 29 30 30 29 30 29 30 30 29 30 29 354
+1015 */ { 06, 01, 29, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 29 384
+1016 */ { 00, 02, 17, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
+1017 */ { 00, 02, 06, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
+1018 */ { 04, 01, 26, 0b1010010011011000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 30 384
+1019 */ { 00, 02, 14, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
+1020 */ { 12, 02, 03, 0b1010101001011000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 30 384
+1021 */ { 00, 02, 21, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+1022 */ { 00, 02, 10, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+1023 */ { 09, 01, 31, 0b0010110110101000 }, /* 29 29 30 29 30 30 29 30 30 29 30 29 30 384
+1024 */ { 00, 02, 19, 0b0010101101010000 }, /* 29 29 30 29 30 29 30 30 29 30 29 30 354
+1025 */ { 00, 02, 07, 0b1001010101110000 }, /* 30 29 29 30 29 30 29 30 29 30 30 30 355
+1026 */ { 05, 01, 28, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 29 383
+1027 */ { 00, 02, 15, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 355
+1028 */ { 00, 02, 05, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
+1029 */ { 02, 01, 24, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
+1030 */ { 00, 02, 11, 0b1101101010010000 }, /* 30 30 29 30 30 29 30 29 30 29 29 30 355
+1031 */ { 10, 02, 01, 0b0110101101010000 }, /* 29 30 30 29 30 29 30 30 29 30 29 30 29 384
+1032 */ { 00, 02, 20, 0b0110011011010000 }, /* 29 30 30 29 29 30 30 29 30 30 29 30 355
+1033 */ { 00, 02, 09, 0b0010011011100000 }, /* 29 29 30 29 29 30 30 29 30 30 30 29 354
+1034 */ { 06, 01, 29, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 29 384
+1035 */ { 00, 02, 17, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
+1036 */ { 00, 02, 06, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
+1037 */ { 04, 01, 25, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
+1038 */ { 00, 02, 13, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
+1039 */ { 12, 02, 02, 0b1101011010010000 }, /* 30 30 29 30 29 30 30 29 30 29 29 30 29 384
+1040 */ { 00, 02, 21, 0b1011010110000000 }, /* 30 29 30 30 29 30 29 30 30 29 29 29 354
+1041 */ { 00, 02, 09, 0b1101011010110000 }, /* 30 30 29 30 29 30 30 29 30 29 30 30 356
+1042 */ { 09, 01, 31, 0b0010011011011000 }, /* 29 29 30 29 29 30 30 29 30 30 29 30 30 384
+1043 */ { 00, 02, 19, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
+1044 */ { 00, 02, 08, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
+1045 */ { 05, 01, 27, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
+1046 */ { 00, 02, 15, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+1047 */ { 00, 02, 04, 0b1011010010100000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 354
+1048 */ { 01, 01, 24, 0b1011010101011000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 30 385
+1049 */ { 00, 02, 12, 0b0010110101010000 }, /* 29 29 30 29 30 30 29 30 29 30 29 30 354
+1050 */ { 11, 02, 01, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 29 384
+1051 */ { 00, 02, 20, 0b0100101110110000 }, /* 29 30 29 29 30 29 30 30 30 29 30 30 355
+1052 */ { 00, 02, 10, 0b0010010110110000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 354
+1053 */ { 07, 01, 29, 0b0101001010111000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 30 384
+1054 */ { 00, 02, 17, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+1055 */ { 00, 02, 06, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 354
+1056 */ { 03, 01, 26, 0b0110101010101000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 30 384
+1057 */ { 00, 02, 13, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+1058 */ { 12, 02, 02, 0b1010101101011000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 30 385
+1059 */ { 00, 02, 22, 0b0010011101010000 }, /* 29 29 30 29 29 30 30 30 29 30 29 30 354
+1060 */ { 00, 02, 11, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
+1061 */ { 08, 01, 30, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 29 384
+1062 */ { 00, 02, 18, 0b1010010101100000 }, /* 30 29 30 29 29 30 29 30 29 30 30 29 354
+1063 */ { 00, 02, 07, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
+1064 */ { 05, 01, 27, 0b1110100100110000 }, /* 30 30 30 29 30 29 29 30 29 29 30 30 29 384
+1065 */ { 00, 02, 14, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
+1066 */ { 00, 02, 04, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1067 */ { 01, 01, 24, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 29 384
+1068 */ { 00, 02, 12, 0b1001011011010000 }, /* 30 29 29 30 29 30 30 29 30 30 29 30 355
+1069 */ { 11, 02, 01, 0b0100101011101000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 30 384
+1070 */ { 00, 02, 20, 0b0100100111010000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 354
+1071 */ { 00, 02, 09, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
+1072 */ { 07, 01, 29, 0b1101001001101000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 30 384
+1073 */ { 00, 02, 16, 0b1010101001100000 }, /* 30 29 30 29 30 29 30 29 29 30 30 29 354
+1074 */ { 00, 02, 05, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
+1075 */ { 04, 01, 26, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
+1076 */ { 00, 02, 14, 0b0011010110100000 }, /* 29 29 30 30 29 30 29 30 30 29 30 29 354
+1077 */ { 00, 02, 02, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
+1078 */ { 01, 01, 23, 0b0100101110011000 }, /* 29 30 29 29 30 29 30 30 30 29 29 30 30 384
+1079 */ { 00, 02, 11, 0b0100010110110000 }, /* 29 30 29 29 29 30 29 30 30 29 30 30 354
+1080 */ { 09, 01, 31, 0b1010010010111000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 30 384
+1081 */ { 00, 02, 18, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
+1082 */ { 00, 02, 07, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
+1083 */ { 06, 01, 27, 0b1011010101001000 }, /* 30 29 30 30 29 30 29 30 29 30 29 29 30 384
+1084 */ { 00, 02, 15, 0b0110101101010000 }, /* 29 30 30 29 30 29 30 30 29 30 29 30 355
+1085 */ { 00, 02, 04, 0b0010110110100000 }, /* 29 29 30 29 30 30 29 30 30 29 30 29 354
+1086 */ { 02, 01, 24, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 29 384
+1087 */ { 00, 02, 12, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 355
+1088 */ { 12, 02, 02, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 29 383
+1089 */ { 00, 02, 19, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 355
+1090 */ { 00, 02, 09, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
+1091 */ { 08, 01, 29, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
+1092 */ { 00, 02, 16, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 355
+1093 */ { 00, 02, 05, 0b0101101101000000 }, /* 29 30 29 30 30 29 30 30 29 30 29 29 354
+1094 */ { 04, 01, 25, 0b1010101101101000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 30 385
+1095 */ { 00, 02, 14, 0b0010101011100000 }, /* 29 29 30 29 30 29 30 29 30 30 30 29 354
+1096 */ { 00, 02, 03, 0b1110011000010000 }, /* 30 30 30 29 29 30 30 29 29 29 29 30 354
+1097 */ { 02, 01, 22, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 29 384
+1098 */ { 00, 02, 10, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
+1099 */ { 09, 01, 30, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
+1100 */ { 00, 02, 18, 0b0101010010100000 }, /* 29 30 29 30 29 30 29 29 30 29 30 29 353
+1101 */ { 00, 02, 07, 0b1101011001010000 }, /* 30 30 29 30 29 30 30 29 29 30 29 30 355
+1102 */ { 06, 01, 28, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
+1103 */ { 00, 02, 16, 0b0101010111010000 }, /* 29 30 29 30 29 30 29 30 30 30 29 30 355
+1104 */ { 00, 02, 06, 0b0010011011010000 }, /* 29 29 30 29 29 30 30 29 30 30 29 30 354
+1105 */ { 02, 01, 25, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
+1106 */ { 00, 02, 13, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
+1107 */ { 10, 02, 02, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
+1108 */ { 00, 02, 21, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+1109 */ { 00, 02, 09, 0b1011010010100000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 354
+1110 */ { 08, 01, 29, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
+1111 */ { 00, 02, 17, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+1112 */ { 00, 02, 07, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
+1113 */ { 04, 01, 27, 0b0010010110111000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 30 384
+1114 */ { 00, 02, 15, 0b0100010101110000 }, /* 29 30 29 29 29 30 29 30 29 30 30 30 354
+1115 */ { 00, 02, 04, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+1116 */ { 01, 01, 24, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
+1117 */ { 00, 02, 11, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 354
+1118 */ { 09, 01, 31, 0b0111001010101000 }, /* 29 30 30 30 29 29 30 29 30 29 30 29 30 384
+1119 */ { 00, 02, 19, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1120 */ { 00, 02, 08, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
+1121 */ { 05, 01, 28, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
+1122 */ { 00, 02, 16, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
+1123 */ { 00, 02, 05, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
+1124 */ { 03, 01, 26, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 29 383
+1125 */ { 00, 02, 12, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
+1126 */ { 11, 02, 01, 0b1110100100110000 }, /* 30 30 30 29 30 29 29 30 29 29 30 30 29 384
+1127 */ { 00, 02, 20, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
+1128 */ { 00, 02, 10, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1129 */ { 08, 01, 29, 0b1001101110010000 }, /* 30 29 29 30 30 29 30 30 30 29 29 30 29 384
+1130 */ { 00, 02, 17, 0b1001011011010000 }, /* 30 29 29 30 29 30 30 29 30 30 29 30 355
+1131 */ { 00, 02, 07, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
+1132 */ { 04, 01, 27, 0b1010010011101000 }, /* 30 29 30 29 29 30 29 29 30 30 30 29 30 384
+1133 */ { 00, 02, 14, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
+1134 */ { 00, 02, 03, 0b1101001001010000 }, /* 30 30 29 30 29 29 30 29 29 30 29 30 354
+1135 */ { 02, 01, 23, 0b1101100100101000 }, /* 30 30 29 30 30 29 29 30 29 29 30 29 30 384
+1136 */ { 00, 02, 11, 0b1011010101000000 }, /* 30 29 30 30 29 30 29 30 29 30 29 29 354
+1137 */ { 10, 01, 30, 0b1101011010101000 }, /* 30 30 29 30 29 30 30 29 30 29 30 29 30 385
+1138 */ { 00, 02, 19, 0b0010110110100000 }, /* 29 29 30 29 30 30 29 30 30 29 30 29 354
+1139 */ { 00, 02, 08, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
+1140 */ { 06, 01, 29, 0b0100101011011000 }, /* 29 30 29 29 30 29 30 29 30 30 29 30 30 384
+1141 */ { 00, 02, 16, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
+1142 */ { 00, 02, 05, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
+1143 */ { 04, 01, 25, 0b1011001001011000 }, /* 30 29 30 30 29 29 30 29 29 30 29 30 30 384
+1144 */ { 00, 02, 13, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
+1145 */ { 11, 02, 01, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
+1146 */ { 00, 02, 20, 0b0110101101000000 }, /* 29 30 30 29 30 29 30 30 29 30 29 29 354
+1147 */ { 00, 02, 09, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+1148 */ { 08, 01, 30, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 29 384
+1149 */ { 00, 02, 17, 0b1001100101110000 }, /* 30 29 29 30 30 29 29 30 29 30 30 30 355
+1150 */ { 00, 02, 07, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
+1151 */ { 04, 01, 27, 0b0110010010111000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 30 384
+1152 */ { 00, 02, 15, 0b0101010010110000 }, /* 29 30 29 30 29 30 29 29 30 29 30 30 354
+1153 */ { 12, 02, 03, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
+1154 */ { 00, 02, 21, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 355
+1155 */ { 00, 02, 11, 0b0101101011000000 }, /* 29 30 29 30 30 29 30 29 30 30 29 29 354
+1156 */ { 10, 01, 31, 0b1010101101101000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 30 385
+1157 */ { 00, 02, 19, 0b0010011011100000 }, /* 29 29 30 29 29 30 30 29 30 30 30 29 354
+1158 */ { 00, 02, 08, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
+1159 */ { 06, 01, 28, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 29 384
+1160 */ { 00, 02, 16, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
+1161 */ { 00, 02, 04, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
+1162 */ { 02, 01, 24, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 29 384
+1163 */ { 00, 02, 12, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
+1164 */ { 11, 02, 02, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
+1165 */ { 00, 02, 20, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 355
+1166 */ { 00, 02, 10, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
+1167 */ { 07, 01, 30, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
+1168 */ { 00, 02, 18, 0b1001001001110000 }, /* 30 29 29 30 29 29 30 29 29 30 30 30 354
+1169 */ { 00, 02, 06, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+1170 */ { 05, 01, 26, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
+1171 */ { 00, 02, 14, 0b1011010010100000 }, /* 30 29 30 30 29 30 29 29 30 29 30 29 354
+1172 */ { 00, 02, 03, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
+1173 */ { 01, 01, 23, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
+1174 */ { 00, 02, 11, 0b0100110110110000 }, /* 29 30 29 29 30 30 29 30 30 29 30 30 355
+1175 */ { 09, 02, 01, 0b0010010110110000 }, /* 29 29 30 29 29 30 29 30 30 29 30 30 29 383
+1176 */ { 00, 02, 19, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
+1177 */ { 00, 02, 08, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+1178 */ { 06, 01, 28, 0b1010100101011000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 30 384
+1179 */ { 00, 02, 16, 0b0110100101010000 }, /* 29 30 30 29 30 29 29 30 29 30 29 30 354
+1180 */ { 00, 02, 05, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+1181 */ { 03, 01, 24, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 29 384
+1182 */ { 00, 02, 12, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
+1183 */ { 11, 02, 02, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
+1184 */ { 00, 02, 21, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
+1185 */ { 00, 02, 09, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
+1186 */ { 07, 01, 30, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 29 383
+1187 */ { 00, 02, 17, 0b1101000010010000 }, /* 30 30 29 30 29 29 29 29 30 29 29 30 353
+1188 */ { 00, 01, 08, 0b0111010010011000 }, /* 29 30 30 30 29 30 29 29 30 29 29 30 354
+1189 */ { 05, 01, 26, 0b0110101010101000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 30 384
+1190 */ { 00, 02, 14, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1191 */ { 00, 02, 03, 0b1001101101010000 }, /* 30 29 29 30 30 29 30 30 29 30 29 30 355
+1192 */ { 02, 01, 24, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
+1193 */ { 00, 02, 11, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
+1194 */ { 10, 01, 31, 0b1010010011101000 }, /* 30 29 30 29 29 30 29 29 30 30 30 29 30 384
+1195 */ { 00, 02, 19, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
+1196 */ { 00, 02, 08, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
+1197 */ { 06, 01, 27, 0b1101010100101000 }, /* 30 30 29 30 29 30 29 30 29 29 30 29 30 384
+1198 */ { 00, 02, 15, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
+1199 */ { 00, 02, 04, 0b1101011010100000 }, /* 30 30 29 30 29 30 30 29 30 29 30 29 355
+1200 */ { 02, 01, 25, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 29 384
+1201 */ { 00, 02, 12, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 355
+1202 */ { 12, 02, 02, 0b0100100111011000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 30 384
+1203 */ { 00, 02, 21, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
+1204 */ { 00, 02, 10, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
+1205 */ { 08, 01, 29, 0b1010101001011000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 30 384
+1206 */ { 00, 02, 17, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
+1207 */ { 00, 02, 06, 0b1011010101000000 }, /* 30 29 30 30 29 30 29 30 29 30 29 29 354
+1208 */ { 04, 01, 26, 0b1011010110100000 }, /* 30 29 30 30 29 30 29 30 30 29 30 29 29 384
+1209 */ { 00, 02, 13, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+1210 */ { 00, 02, 03, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
+1211 */ { 02, 01, 24, 0b0100100110111000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 30 384
+1212 */ { 00, 02, 12, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
+1213 */ { 09, 01, 31, 0b0110010010111000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 30 384
+1214 */ { 00, 02, 19, 0b0101010010110000 }, /* 29 30 29 30 29 30 29 29 30 29 30 30 354
+1215 */ { 00, 02, 08, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
+1216 */ { 07, 01, 28, 0b0110110100101000 }, /* 29 30 30 29 30 30 29 30 29 29 30 29 30 384
+1217 */ { 00, 02, 15, 0b0101101011000000 }, /* 29 30 29 30 30 29 30 29 30 30 29 29 354
+1218 */ { 00, 02, 04, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+1219 */ { 03, 01, 25, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 29 384
+1220 */ { 00, 02, 13, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
+1221 */ { 12, 02, 01, 0b1100100101110000 }, /* 30 30 29 29 30 29 29 30 29 30 30 30 29 384
+1222 */ { 00, 02, 20, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
+1223 */ { 00, 02, 09, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
+1224 */ { 08, 01, 29, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 29 384
+1225 */ { 00, 02, 16, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
+1226 */ { 00, 02, 06, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
+1227 */ { 05, 01, 26, 0b1010101011011000 }, /* 30 29 30 29 30 29 30 29 30 30 29 30 30 385
+1228 */ { 00, 02, 15, 0b0010010111010000 }, /* 29 29 30 29 29 30 29 30 30 30 29 30 354
+1229 */ { 00, 02, 03, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
+1230 */ { 02, 01, 23, 0b1100100101011000 }, /* 30 30 29 29 30 29 29 30 29 30 29 30 30 384
+1231 */ { 00, 02, 11, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+1232 */ { 09, 01, 31, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
+1233 */ { 00, 02, 18, 0b1011001010100000 }, /* 30 29 30 30 29 29 30 29 30 29 30 29 354
+1234 */ { 00, 02, 07, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 355
+1235 */ { 07, 01, 28, 0b0101011010101000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 30 384
+1236 */ { 00, 02, 16, 0b0100110110100000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 354
+1237 */ { 00, 02, 04, 0b1010010110110000 }, /* 30 29 30 29 29 30 29 30 30 29 30 30 355
+1238 */ { 04, 01, 25, 0b0101001010111000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 30 384
+1239 */ { 00, 02, 13, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+1240 */ { 12, 02, 02, 0b1010100100111000 }, /* 30 29 30 29 30 29 29 30 29 29 30 30 30 384
+1241 */ { 00, 02, 20, 0b0110100100110000 }, /* 29 30 30 29 30 29 29 30 29 29 30 30 354
+1242 */ { 00, 02, 09, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+1243 */ { 08, 01, 29, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 29 384
+1244 */ { 00, 02, 17, 0b1010111001010000 }, /* 30 29 30 29 30 30 30 29 29 30 29 30 355
+1245 */ { 00, 02, 06, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
+1246 */ { 04, 01, 26, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 29 384
+1247 */ { 00, 02, 14, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
+1248 */ { 00, 02, 04, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 354
+1249 */ { 02, 01, 23, 0b0110100100110000 }, /* 29 30 30 29 30 29 29 30 29 29 30 30 29 383
+1250 */ { 00, 02, 10, 0b1110010100110000 }, /* 30 30 30 29 29 30 29 30 29 29 30 30 355
+1251 */ { 10, 01, 31, 0b0110110010011000 }, /* 29 30 30 29 30 30 29 29 30 29 29 30 30 384
+1252 */ { 00, 02, 19, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1253 */ { 00, 02, 07, 0b0101101011010000 }, /* 29 30 29 30 30 29 30 29 30 30 29 30 355
+1254 */ { 06, 01, 28, 0b0100101101101000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 30 384
+1255 */ { 00, 02, 16, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
+1256 */ { 00, 02, 05, 0b1010010011100000 }, /* 30 29 30 29 29 30 29 29 30 30 30 29 354
+1257 */ { 04, 01, 24, 0b1101001001101000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 30 384
+1258 */ { 00, 02, 12, 0b1101001001100000 }, /* 30 30 29 30 29 29 30 29 29 30 30 29 354
+1259 */ { 11, 02, 01, 0b1101010100101000 }, /* 30 30 29 30 29 30 29 30 29 29 30 29 30 384
+1260 */ { 00, 02, 20, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
+1261 */ { 00, 02, 08, 0b1011011010100000 }, /* 30 29 30 30 29 30 30 29 30 29 30 29 355
+1262 */ { 09, 01, 29, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 29 384
+1263 */ { 00, 02, 17, 0b0101010101110000 }, /* 29 30 29 30 29 30 29 30 29 30 30 30 355
+1264 */ { 00, 02, 07, 0b0100100111010000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 354
+1265 */ { 05, 01, 26, 0b1010010011011000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 30 384
+1266 */ { 00, 02, 14, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
+1267 */ { 00, 02, 03, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
+1268 */ { 01, 01, 23, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
+1269 */ { 00, 02, 10, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
+1270 */ { 11, 01, 30, 0b1011010111000000 }, /* 30 29 30 30 29 30 29 30 30 30 29 29 29 384
+1271 */ { 00, 02, 18, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+1272 */ { 00, 02, 08, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
+1273 */ { 06, 01, 28, 0b0100100110111000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 30 384
+1274 */ { 00, 02, 16, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
+1275 */ { 00, 02, 05, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
+1276 */ { 03, 01, 25, 0b0110101001011000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 30 384
+1277 */ { 00, 02, 12, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 354
+1278 */ { 11, 02, 01, 0b0110101100101000 }, /* 29 30 30 29 30 29 30 30 29 29 30 29 30 384
+1279 */ { 00, 02, 20, 0b0101101011000000 }, /* 29 30 29 30 30 29 30 29 30 30 29 29 354
+1280 */ { 00, 02, 09, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+1281 */ { 08, 01, 29, 0b0010101011101000 }, /* 29 29 30 29 30 29 30 29 30 30 30 29 30 384
+1282 */ { 00, 02, 17, 0b0100100111100000 }, /* 29 30 29 29 30 29 29 30 30 30 30 29 354
+1283 */ { 00, 02, 06, 0b1010010011010000 }, /* 30 29 30 29 29 30 29 29 30 30 29 30 354
+1284 */ { 05, 01, 26, 0b1101001001011000 }, /* 30 30 29 30 29 29 30 29 29 30 29 30 30 384
+1285 */ { 00, 02, 13, 0b1011001001010000 }, /* 30 29 30 30 29 29 30 29 29 30 29 30 354
+1286 */ { 00, 02, 02, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
+1287 */ { 02, 01, 22, 0b1111001010010000 }, /* 30 30 30 30 29 29 30 29 30 29 29 30 29 384
+1288 */ { 00, 02, 10, 0b1011010110100000 }, /* 30 29 30 30 29 30 29 30 30 29 30 29 355
+1289 */ { 10, 01, 30, 0b1001010111010000 }, /* 30 29 29 30 29 30 29 30 30 30 29 30 29 384
+1290 */ { 00, 02, 18, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 355
+1291 */ { 00, 02, 08, 0b0100100110110000 }, /* 29 30 29 29 30 29 29 30 30 29 30 30 354
+1292 */ { 06, 01, 28, 0b1010010010111000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 30 384
+1293 */ { 00, 02, 15, 0b1010010010110000 }, /* 30 29 30 29 29 30 29 29 30 29 30 30 354
+1294 */ { 00, 02, 04, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
+1295 */ { 04, 01, 24, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
+1296 */ { 00, 02, 12, 0b0110110101000000 }, /* 29 30 30 29 30 30 29 30 29 30 29 29 354
+1297 */ { 12, 01, 31, 0b1010110101100000 }, /* 30 29 30 29 30 30 29 30 29 30 30 29 29 384
+1298 */ { 00, 02, 19, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 355
+1299 */ { 00, 02, 09, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 355
+1300 */ { 08, 01, 30, 0b0000100101111000 }, /* 29 29 29 29 30 29 29 30 29 30 30 30 30 383
+1301 */ { 00, 02, 18, 0b0100100101110000 }, /* 29 30 29 29 30 29 29 30 29 30 30 30 354
+1302 */ { 00, 02, 07, 0b0110010010110000 }, /* 29 30 30 29 29 30 29 29 30 29 30 30 354
+1303 */ { 05, 01, 27, 0b0110101001010000 }, /* 29 30 30 29 30 29 30 29 29 30 29 30 29 383
+1304 */ { 00, 02, 14, 0b1101101001010000 }, /* 30 30 29 30 30 29 30 29 29 30 29 30 355
+1305 */ { 00, 02, 03, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1306 */ { 01, 01, 23, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 29 384
+1307 */ { 00, 02, 11, 0b1010011011100000 }, /* 30 29 30 29 29 30 30 29 30 30 30 29 355
+1308 */ { 11, 02, 01, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
+1309 */ { 00, 02, 19, 0b1001001011100000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 354
+1310 */ { 00, 02, 08, 0b1100100101100000 }, /* 30 30 29 29 30 29 29 30 29 30 30 29 354
+1311 */ { 07, 01, 28, 0b1101010010101000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 30 384
+1312 */ { 00, 02, 16, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
+1313 */ { 00, 02, 04, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
+1314 */ { 03, 01, 25, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
+1315 */ { 00, 02, 13, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
+1316 */ { 00, 02, 02, 0b1010011011010000 }, /* 30 29 30 29 29 30 30 29 30 30 29 30 355
+1317 */ { 01, 01, 22, 0b1001001011101000 }, /* 30 29 29 30 29 29 30 29 30 30 30 29 30 384
+1318 */ { 00, 02, 10, 0b1001001010110000 }, /* 30 29 29 30 29 29 30 29 30 29 30 30 354
+1319 */ { 08, 01, 30, 0b1010010101011000 }, /* 30 29 30 29 29 30 29 30 29 30 29 30 30 384
+1320 */ { 00, 02, 18, 0b1010100101010000 }, /* 30 29 30 29 30 29 29 30 29 30 29 30 354
+1321 */ { 00, 02, 06, 0b1011001010100000 }, /* 30 29 30 30 29 29 30 29 30 29 30 29 354
+1322 */ { 05, 01, 26, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
+1323 */ { 00, 02, 14, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+1324 */ { 00, 02, 04, 0b0100110110100000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 354
+1325 */ { 01, 01, 23, 0b1010010111010000 }, /* 30 29 30 29 29 30 29 30 30 30 29 30 29 384
+1326 */ { 00, 02, 11, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
+1327 */ { 09, 02, 01, 0b0101001010111000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 30 384
+1328 */ { 00, 02, 20, 0b0101001001110000 }, /* 29 30 29 30 29 29 30 29 29 30 30 30 354
+1329 */ { 00, 02, 08, 0b0110100100110000 }, /* 29 30 30 29 30 29 29 30 29 29 30 30 354
+1330 */ { 07, 01, 28, 0b0110101010011000 }, /* 29 30 30 29 30 29 30 29 30 29 29 30 30 384
+1331 */ { 00, 02, 16, 0b0110101010100000 }, /* 29 30 30 29 30 29 30 29 30 29 30 29 354
+1332 */ { 00, 02, 05, 0b1010101101010000 }, /* 30 29 30 29 30 29 30 30 29 30 29 30 355
+1333 */ { 03, 01, 25, 0b0100101110101000 }, /* 29 30 29 29 30 29 30 30 30 29 30 29 30 384
+1334 */ { 00, 02, 13, 0b0100101101100000 }, /* 29 30 29 29 30 29 30 30 29 30 30 29 354
+1335 */ { 12, 02, 02, 0b1010011001110000 }, /* 30 29 30 29 29 30 30 29 29 30 30 30 29 384
+1336 */ { 00, 02, 21, 0b1010001011100000 }, /* 30 29 30 29 29 29 30 29 30 30 30 29 354
+1337 */ { 00, 02, 09, 0b1101000101100000 }, /* 30 30 29 30 29 29 29 30 29 30 30 29 354
+1338 */ { 08, 01, 29, 0b1110100100110000 }, /* 30 30 30 29 30 29 29 30 29 29 30 30 29 384
+1339 */ { 00, 02, 17, 0b1101010010100000 }, /* 30 30 29 30 29 30 29 29 30 29 30 29 354
+1340 */ { 00, 02, 06, 0b1101101010100000 }, /* 30 30 29 30 30 29 30 29 30 29 30 29 355
+1341 */ { 05, 01, 26, 0b0101101101010000 }, /* 29 30 29 30 30 29 30 30 29 30 29 30 29 384
+1342 */ { 00, 02, 14, 0b0101011011010000 }, /* 29 30 29 30 29 30 30 29 30 30 29 30 355
+1343 */ { 00, 02, 04, 0b0100101011100000 }, /* 29 30 29 29 30 29 30 29 30 30 30 29 354
+1344 */ { 02, 01, 24, 0b1010001011101000 }, /* 30 29 30 29 29 29 30 29 30 30 30 29 30 384
+1345 */ { 00, 02, 11, 0b1010001011010000 }, /* 30 29 30 29 29 29 30 29 30 30 29 30 354
+1346 */ { 10, 01, 31, 0b1101000101011000 }, /* 30 30 29 30 29 29 29 30 29 30 29 30 30 384
+1347 */ { 00, 02, 19, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
+1348 */ { 00, 02, 08, 0b1011010100100000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 354
+1349 */ { 07, 01, 27, 0b1101011010100000 }, /* 30 30 29 30 29 30 30 29 30 29 30 29 29 384
+1350 */ { 00, 02, 15, 0b1010110110100000 }, /* 30 29 30 29 30 30 29 30 30 29 30 29 355
+1351 */ { 00, 02, 05, 0b0101010111010000 }, /* 29 30 29 30 29 30 29 30 30 30 29 30 355
+1352 */ { 03, 01, 26, 0b0100100111011000 }, /* 29 30 29 29 30 29 29 30 30 30 29 30 30 384
+1353 */ { 00, 02, 13, 0b0100010110110000 }, /* 29 30 29 29 29 30 29 30 30 29 30 30 354
+1354 */ { 00, 02, 02, 0b1010001010110000 }, /* 30 29 30 29 29 29 30 29 30 29 30 30 354
+1355 */ { 01, 01, 22, 0b1101000101011000 }, /* 30 30 29 30 29 29 29 30 29 30 29 30 30 384
+1356 */ { 00, 02, 10, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 354
+1357 */ { 09, 01, 29, 0b1011010100101000 }, /* 30 29 30 30 29 30 29 30 29 29 30 29 30 384
+1358 */ { 00, 02, 17, 0b0110101100100000 }, /* 29 30 30 29 30 29 30 30 29 29 30 29 354
+1359 */ { 00, 02, 06, 0b1010110101100000 }, /* 30 29 30 29 30 30 29 30 29 30 30 29 355
+1360 */ { 05, 01, 27, 0b0101010110110000 }, /* 29 30 29 30 29 30 29 30 30 29 30 30 29 384
+1361 */ { 00, 02, 14, 0b1001001101110000 }, /* 30 29 29 30 29 29 30 30 29 30 30 30 355
+1362 */ { 00, 02, 04, 0b0100010101110000 }, /* 29 30 29 29 29 30 29 30 29 30 30 30 354
+1363 */ { 03, 01, 24, 0b1010001010111000 }, /* 30 29 30 29 29 29 30 29 30 29 30 30 30 384
+1364 */ { 00, 02, 12, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+1365 */ { 10, 01, 31, 0b1010101001010000 }, /* 30 29 30 29 30 29 30 29 29 30 29 30 29 383
+1366 */ { 00, 02, 18, 0b1101100101010000 }, /* 30 30 29 30 30 29 29 30 29 30 29 30 355
+1367 */ { 00, 02, 08, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
+1368 */ { 07, 01, 28, 0b1010101101100000 }, /* 30 29 30 29 30 29 30 30 29 30 30 29 29 384
+1369 */ { 00, 02, 15, 0b1010011011100000 }, /* 30 29 30 29 29 30 30 29 30 30 30 29 355
+1370 */ { 00, 02, 05, 0b0101001011100000 }, /* 29 30 29 30 29 29 30 29 30 30 30 29 354
+1371 */ { 03, 01, 25, 0b1100010101110000 }, /* 30 30 29 29 29 30 29 30 29 30 30 30 29 384
+1372 */ { 00, 02, 13, 0b1010010101100000 }, /* 30 29 30 29 29 30 29 30 29 30 30 29 354
+1373 */ { 11, 02, 01, 0b1101001010101000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 30 384
+1374 */ { 00, 02, 20, 0b1101001010100000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 354
+1375 */ { 00, 02, 09, 0b1101010101010000 }, /* 30 30 29 30 29 30 29 30 29 30 29 30 355
+1376 */ { 09, 01, 30, 0b0101101010101000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 30 384
+1377 */ { 00, 02, 17, 0b0101011010100000 }, /* 29 30 29 30 29 30 30 29 30 29 30 29 354
+1378 */ { 00, 02, 06, 0b1010011011010000 }, /* 30 29 30 29 29 30 30 29 30 30 29 30 355
+1379 */ { 05, 01, 27, 0b0101001011101000 }, /* 29 30 29 30 29 29 30 29 30 30 30 29 30 384
+1380 */ { 00, 02, 15, 0b0101001010110000 }, /* 29 30 29 30 29 29 30 29 30 29 30 30 354
+1381 */ { 00, 02, 03, 0b1010100011010000 }, /* 30 29 30 29 30 29 29 29 30 30 29 30 354
+1382 */ { 02, 01, 23, 0b1101001010101000 }, /* 30 30 29 30 29 29 30 29 30 29 30 29 30 384
+1383 */ { 00, 02, 11, 0b1011001010100000 }, /* 30 29 30 30 29 29 30 29 30 29 30 29 354
+1384 */ { 10, 01, 31, 0b1011010101010000 }, /* 30 29 30 30 29 30 29 30 29 30 29 30 29 384
+1385 */ { 00, 02, 18, 0b1010110101010000 }, /* 30 29 30 29 30 30 29 30 29 30 29 30 355
+1386 */ { 00, 02, 08, 0b0100110110100000 }, /* 29 30 29 29 30 30 29 30 30 29 30 29 354
+1387 */ { 06, 01, 28, 0b1010010111010000 }, /* 30 29 30 29 29 30 29 30 30 30 29 30 29 384
+1388 */ { 00, 02, 16, 0b1010010101110000 }, /* 30 29 30 29 29 30 29 30 29 30 30 30 355
+1389 */ { 00, 02, 05, 0b0101000110110000 }, /* 29 30 29 30 29 29 29 30 30 29 30 30 354
+1390 */ { 04, 01, 25, 0b1010100010111000 }, /* 30 29 30 29 30 29 29 29 30 29 30 30 30 384
1391 */ { 00, 02, 13, 0b0110010100110000 }, /* 29 30 30 29 29 30 29 30 29 29 30 30 354
1392 */ { 12, 02, 02, 0b0110101010011000 }, /* 29 30 30 29 30 29 30 29 30 29 29 30 30 384
1393 */ { 00, 02, 20, 0b0101101010100000 }, /* 29 30 29 30 30 29 30 29 30 29 30 29 354
@@ -1202,59 +1176,27 @@ namespace System.Globalization
2050 */ { 03, 01, 23, 0b1001010110110000 }, /* 30 29 29 30 29 30 29 30 30 29 30 30 29 384
*/ };
- internal override int MinCalendarYear
- {
- get
- {
- return (MIN_LUNISOLAR_YEAR);
- }
- }
+ internal override int MinCalendarYear => MinLunisolarYear;
- internal override int MaxCalendarYear
- {
- get
- {
- return (MAX_LUNISOLAR_YEAR);
- }
- }
+ internal override int MaxCalendarYear => MaxLunisolarYear;
- internal override DateTime MinDate
- {
- get
- {
- return (minDate);
- }
- }
+ internal override DateTime MinDate => s_minDate;
- internal override DateTime MaxDate
- {
- get
- {
- return (maxDate);
- }
- }
+ internal override DateTime MaxDate => s_maxDate;
- internal override EraInfo[] CalEraInfo
- {
- get
- {
- return null;
- }
- }
+ internal override EraInfo[] CalEraInfo => null;
internal override int GetYearInfo(int lunarYear, int index)
{
- if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
+ if (lunarYear < MinLunisolarYear || lunarYear > MaxLunisolarYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MIN_LUNISOLAR_YEAR,
- MAX_LUNISOLAR_YEAR));
+ "year",
+ lunarYear,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinLunisolarYear, MaxLunisolarYear));
}
- return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
+
+ return s_yinfo[lunarYear - MinLunisolarYear, index];
}
internal override int GetYear(int year, DateTime time)
@@ -1265,15 +1207,15 @@ namespace System.Globalization
internal override int GetGregorianYear(int year, int era)
{
if (era != CurrentEra && era != GregorianEra)
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
-
- if (year < MIN_LUNISOLAR_YEAR || year > MAX_LUNISOLAR_YEAR)
+ {
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
+ }
+ if (year < MinLunisolarYear || year > MaxLunisolarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinLunisolarYear, MaxLunisolarYear));
}
return year;
@@ -1286,31 +1228,13 @@ namespace System.Globalization
public override int GetEra(DateTime time)
{
CheckTicksRange(time.Ticks);
- return (GregorianEra);
+ return GregorianEra;
}
- internal override CalendarId BaseCalendarID
- {
- get
- {
- return (CalendarId.KOREA);
- }
- }
+ internal override CalendarId BaseCalendarID => CalendarId.KOREA;
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.KOREANLUNISOLAR);
- }
- }
+ internal override CalendarId ID => CalendarId.KOREANLUNISOLAR;
- public override int[] Eras
- {
- get
- {
- return (new int[] { GregorianEra });
- }
- }
+ public override int[] Eras => new int[] { GregorianEra };
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs
index a6f964d342..40f9c9c846 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs
@@ -6,122 +6,79 @@ using System.Diagnostics;
namespace System.Globalization
{
- // Modern Persian calendar is a solar observation based calendar. Each new year begins on the day when the vernal equinox occurs before noon.
- // The epoch is the date of the vernal equinox prior to the epoch of the Islamic calendar (March 19, 622 Julian or March 22, 622 Gregorian)
-
- // There is no Persian year 0. Ordinary years have 365 days. Leap years have 366 days with the last month (Esfand) gaining the extra day.
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 0622/03/22 9999/12/31
- ** Persian 0001/01/01 9378/10/13
- */
-
+ /// <summary>
+ /// Modern Persian calendar is a solar observation based calendar. Each new year begins on the day when the vernal equinox occurs before noon.
+ /// The epoch is the date of the vernal equinox prior to the epoch of the Islamic calendar (March 19, 622 Julian or March 22, 622 Gregorian)
+ /// There is no Persian year 0. Ordinary years have 365 days. Leap years have 366 days with the last month (Esfand) gaining the extra day.
+ /// </summary>
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 0622/03/22 9999/12/31
+ /// Persian 0001/01/01 9378/10/13
+ /// </remarks>
public class PersianCalendar : Calendar
{
public static readonly int PersianEra = 1;
- internal static long PersianEpoch = new DateTime(622, 3, 22).Ticks / GregorianCalendar.TicksPerDay;
+ private static readonly long s_persianEpoch = new DateTime(622, 3, 22).Ticks / GregorianCalendar.TicksPerDay;
private const int ApproximateHalfYear = 180;
- internal const int DatePartYear = 0;
- internal const int DatePartDayOfYear = 1;
- internal const int DatePartMonth = 2;
- internal const int DatePartDay = 3;
- internal const int MonthsPerYear = 12;
+ private const int DatePartYear = 0;
+ private const int DatePartDayOfYear = 1;
+ private const int DatePartMonth = 2;
+ private const int DatePartDay = 3;
+ private const int MonthsPerYear = 12;
- internal static int[] DaysToMonth = { 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 366 };
+ private static readonly int[] s_daysToMonth = { 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336, 366 };
- internal const int MaxCalendarYear = 9378;
- internal const int MaxCalendarMonth = 10;
- internal const int MaxCalendarDay = 13;
+ private const int MaxCalendarYear = 9378;
+ private const int MaxCalendarMonth = 10;
+ private const int MaxCalendarDay = 13;
// Persian calendar (year: 1, month: 1, day:1 ) = Gregorian (year: 622, month: 3, day: 22)
// This is the minimal Gregorian date that we support in the PersianCalendar.
- internal static DateTime minDate = new DateTime(622, 3, 22);
- internal static DateTime maxDate = DateTime.MaxValue;
-
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (minDate);
- }
- }
+ private static readonly DateTime s_minDate = new DateTime(622, 3, 22);
+ private static readonly DateTime s_maxDate = DateTime.MaxValue;
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (maxDate);
- }
- }
+ public override DateTime MinSupportedDateTime => s_minDate;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
+ public override DateTime MaxSupportedDateTime => s_maxDate;
- // Construct an instance of Persian calendar.
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
public PersianCalendar()
{
}
+ internal override CalendarId BaseCalendarID => CalendarId.GREGORIAN;
- internal override CalendarId BaseCalendarID
- {
- get
- {
- return CalendarId.GREGORIAN;
- }
- }
-
- internal override CalendarId ID
- {
- get
- {
- return CalendarId.PERSIAN;
- }
- }
-
-
- /*=================================GetAbsoluteDatePersian==========================
- **Action: Gets the Absolute date for the given Persian date. The absolute date means
- ** the number of days from January 1st, 1 A.D.
- **Returns:
- **Arguments:
- **Exceptions:
- ============================================================================*/
+ internal override CalendarId ID => CalendarId.PERSIAN;
private long GetAbsoluteDatePersian(int year, int month, int day)
{
- if (year >= 1 && year <= MaxCalendarYear && month >= 1 && month <= 12)
+ if (year < 1 || year > MaxCalendarYear || month < 1 || month > 12)
{
- int ordinalDay = DaysInPreviousMonths(month) + day - 1; // day is one based, make 0 based since this will be the number of days we add to beginning of year below
- int approximateDaysFromEpochForYearStart = (int)(CalendricalCalculationsHelper.MeanTropicalYearInDays * (year - 1));
- long yearStart = CalendricalCalculationsHelper.PersianNewYearOnOrBefore(PersianEpoch + approximateDaysFromEpochForYearStart + ApproximateHalfYear);
- yearStart += ordinalDay;
- return yearStart;
+ throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
- throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
+
+ // day is one based, make 0 based since this will be the number of days we add to beginning of year below
+ int ordinalDay = DaysInPreviousMonths(month) + day - 1;
+ int approximateDaysFromEpochForYearStart = (int)(CalendricalCalculationsHelper.MeanTropicalYearInDays * (year - 1));
+ long yearStart = CalendricalCalculationsHelper.PersianNewYearOnOrBefore(s_persianEpoch + approximateDaysFromEpochForYearStart + ApproximateHalfYear);
+ yearStart += ordinalDay;
+ return yearStart;
}
internal static void CheckTicksRange(long ticks)
{
- if (ticks < minDate.Ticks || ticks > maxDate.Ticks)
+ if (ticks < s_minDate.Ticks || ticks > s_maxDate.Ticks)
{
throw new ArgumentOutOfRangeException(
- "time",
- string.Format(
- CultureInfo.InvariantCulture,
- SR.ArgumentOutOfRange_CalendarRange,
- minDate,
- maxDate));
+ "time",
+ ticks,
+ SR.Format(SR.ArgumentOutOfRange_CalendarRange, s_minDate, s_maxDate));
}
}
@@ -129,7 +86,7 @@ namespace System.Globalization
{
if (era != CurrentEra && era != PersianEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
}
@@ -139,12 +96,9 @@ namespace System.Globalization
if (year < 1 || year > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxCalendarYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarYear));
}
}
@@ -156,18 +110,15 @@ namespace System.Globalization
if (month > MaxCalendarMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(month),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxCalendarMonth));
+ nameof(month),
+ month,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarMonth));
}
}
if (month < 1 || month > 12)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
}
}
@@ -175,8 +126,10 @@ namespace System.Globalization
{
Debug.Assert(ordinalDay <= 366);
int index = 0;
- while (ordinalDay > DaysToMonth[index])
+ while (ordinalDay > s_daysToMonth[index])
+ {
index++;
+ }
return index;
}
@@ -184,36 +137,22 @@ namespace System.Globalization
private static int DaysInPreviousMonths(int month)
{
Debug.Assert(1 <= month && month <= 12);
- --month; // months are one based but for calculations use 0 based
- return DaysToMonth[month];
+ // months are one based but for calculations use 0 based
+ --month;
+ return s_daysToMonth[month];
}
- /*=================================GetDatePart==========================
- **Action: Returns a given date part of this <i>DateTime</i>. This method is used
- ** to compute the year, day-of-year, month, or day part.
- **Returns:
- **Arguments:
- **Exceptions: ArgumentException if part is incorrect.
- ============================================================================*/
-
internal int GetDatePart(long ticks, int part)
{
- long NumDays; // The calculation buffer in number of days.
-
CheckTicksRange(ticks);
- //
- // Get the absolute date. The absolute date is the number of days from January 1st, 1 A.D.
- // 1/1/0001 is absolute date 1.
- //
- NumDays = ticks / GregorianCalendar.TicksPerDay + 1;
+ // Get the absolute date. The absolute date is the number of days from January 1st, 1 A.D.
+ // 1/1/0001 is absolute date 1.
+ long numDays = ticks / GregorianCalendar.TicksPerDay + 1;
- //
// Calculate the appromixate Persian Year.
- //
-
- long yearStart = CalendricalCalculationsHelper.PersianNewYearOnOrBefore(NumDays);
- int y = (int)(Math.Floor(((yearStart - PersianEpoch) / CalendricalCalculationsHelper.MeanTropicalYearInDays) + 0.5)) + 1;
+ long yearStart = CalendricalCalculationsHelper.PersianNewYearOnOrBefore(numDays);
+ int y = (int)(Math.Floor(((yearStart - s_persianEpoch) / CalendricalCalculationsHelper.MeanTropicalYearInDays) + 0.5)) + 1;
Debug.Assert(y >= 1);
if (part == DatePartYear)
@@ -221,12 +160,8 @@ namespace System.Globalization
return y;
}
- //
// Calculate the Persian Month.
- //
-
- int ordinalDay = (int)(NumDays - CalendricalCalculationsHelper.GetNumberOfDays(this.ToDateTime(y, 1, 1, 0, 0, 0, 0, 1)));
-
+ int ordinalDay = (int)(numDays - CalendricalCalculationsHelper.GetNumberOfDays(this.ToDateTime(y, 1, 1, 0, 0, 0, 0, 1)));
if (part == DatePartDayOfYear)
{
return ordinalDay;
@@ -244,50 +179,26 @@ namespace System.Globalization
Debug.Assert(1 <= d);
Debug.Assert(d <= 31);
- //
// Calculate the Persian Day.
- //
-
if (part == DatePartDay)
{
- return (d);
+ return d;
}
// Incorrect part value.
throw new InvalidOperationException(SR.InvalidOperation_DateTimeParsing);
}
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
- // In more precise terms, considering the specified DateTime to be of the
- // form y / m / d + t, where y is the
- // year, m is the month, d is the day, and t is the
- // time-of-day, the result is y1 / m1 / d1 + t,
- // where y1 and m1 are computed by adding value months
- // to y and m, and d1 is the largest value less than
- // or equal to d that denotes a valid day in month m1 of year
- // y1.
- //
-
-
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException(
- nameof(months),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- -120000,
- 120000));
+ nameof(months),
+ months,
+ SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
+
// Get the date in Persian calendar.
int y = GetDatePart(time.Ticks, DatePartYear);
int m = GetDatePart(time.Ticks, DatePartMonth);
@@ -308,63 +219,32 @@ namespace System.Globalization
{
d = days;
}
+
long ticks = GetAbsoluteDatePersian(y, m, d) * TicksPerDay + time.Ticks % TicksPerDay;
Calendar.CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (new DateTime(ticks));
+ return new DateTime(ticks);
}
- // Returns the DateTime resulting from adding the given number of
- // years to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year part of the specified DateTime by value
- // years. If the month and day of the specified DateTime is 2/29, and if the
- // resulting year is not a leap year, the month and day of the resulting
- // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
- // parts of the result are the same as those of the specified DateTime.
- //
-
-
public override DateTime AddYears(DateTime time, int years)
{
- return (AddMonths(time, years * 12));
+ return AddMonths(time, years * 12);
}
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 31.
- //
-
-
public override int GetDayOfMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDay));
+ return GetDatePart(time.Ticks, DatePartDay);
}
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7));
+ return (DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7);
}
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and 366.
- //
-
-
public override int GetDayOfYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartDayOfYear));
+ return GetDatePart(time.Ticks, DatePartDayOfYear);
}
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
-
-
public override int GetDaysInMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
@@ -374,61 +254,40 @@ namespace System.Globalization
return MaxCalendarDay;
}
- int daysInMonth = DaysToMonth[month] - DaysToMonth[month - 1];
+ int daysInMonth = s_daysToMonth[month] - s_daysToMonth[month - 1];
if ((month == MonthsPerYear) && !IsLeapYear(year))
{
Debug.Assert(daysInMonth == 30);
--daysInMonth;
}
+
return daysInMonth;
}
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
public override int GetDaysInYear(int year, int era)
{
CheckYearRange(year, era);
if (year == MaxCalendarYear)
{
- return DaysToMonth[MaxCalendarMonth - 1] + MaxCalendarDay;
+ return s_daysToMonth[MaxCalendarMonth - 1] + MaxCalendarDay;
}
- // Common years have 365 days. Leap years have 366 days.
- return (IsLeapYear(year, CurrentEra) ? 366 : 365);
- }
-
- // Returns the era for the specified DateTime value.
+ return IsLeapYear(year, CurrentEra) ? 366 : 365;
+ }
public override int GetEra(DateTime time)
{
CheckTicksRange(time.Ticks);
- return (PersianEra);
+ return PersianEra;
}
-
-
- public override int[] Eras
- {
- get
- {
- return (new int[] { PersianEra });
- }
- }
-
- // Returns the month part of the specified DateTime. The returned value is an
- // integer between 1 and 12.
- //
-
+ public override int[] Eras => new int[] { PersianEra };
public override int GetMonth(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartMonth));
+ return GetDatePart(time.Ticks, DatePartMonth);
}
- // Returns the number of months in the specified year and era.
-
-
public override int GetMonthsInYear(int year, int era)
{
CheckYearRange(year, era);
@@ -436,24 +295,15 @@ namespace System.Globalization
{
return MaxCalendarMonth;
}
- return (12);
- }
-
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between 1 and MaxCalendarYear.
- //
+ return 12;
+ }
public override int GetYear(DateTime time)
{
- return (GetDatePart(time.Ticks, DatePartYear));
+ return GetDatePart(time.Ticks, DatePartYear);
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
// The year/month/era value checking is done in GetDaysInMonth().
@@ -461,42 +311,26 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Day,
- daysInMonth,
- month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
- return (IsLeapYear(year, era) && month == 12 && day == 30);
- }
-
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
+ return IsLeapYear(year, era) && month == 12 && day == 30;
+ }
public override int GetLeapMonth(int year, int era)
{
CheckYearRange(year, era);
- return (0);
+ return 0;
}
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
-
public override bool IsLeapMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
- return (false);
+ return false;
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
public override bool IsLeapYear(int year, int era)
{
CheckYearRange(year, era);
@@ -509,10 +343,6 @@ namespace System.Globalization
return (GetAbsoluteDatePersian(year + 1, 1, 1) - GetAbsoluteDatePersian(year, 1, 1)) == 366;
}
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
-
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
// The year/month/era checking is done in GetDaysInMonth().
@@ -520,82 +350,69 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Day,
- daysInMonth,
- month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
long lDate = GetAbsoluteDatePersian(year, month, day);
- if (lDate >= 0)
- {
- return (new DateTime(lDate * GregorianCalendar.TicksPerDay + TimeToTicks(hour, minute, second, millisecond)));
- }
- else
+ if (lDate < 0)
{
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
+
+ return new DateTime(lDate * GregorianCalendar.TicksPerDay + TimeToTicks(hour, minute, second, millisecond));
}
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 1410;
+ private const int DefaultTwoDigitYearMax = 1410;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
if (value < 99 || value > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(value),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- MaxCalendarYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxCalendarYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
-
if (year < 100)
{
- return (base.ToFourDigitYear(year));
+ return base.ToFourDigitYear(year);
}
if (year > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- MaxCalendarYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarYear));
}
- return (year);
+
+ return year;
}
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs
index e2455cd5e3..f3414d383a 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs
@@ -2,92 +2,50 @@
// 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.Diagnostics.CodeAnalysis;
namespace System.Globalization
{
- /*=================================TaiwanCalendar==========================
- **
- ** Taiwan calendar is based on the Gregorian calendar. And the year is an offset to Gregorian calendar.
- ** That is,
- ** Taiwan year = Gregorian year - 1911. So 1912/01/01 A.D. is Taiwan 1/01/01
- **
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1912/01/01 9999/12/31
- ** Taiwan 01/01/01 8088/12/31
- ============================================================================*/
-
+ /// <summary>
+ /// Taiwan calendar is based on the Gregorian calendar. And the year is an offset to Gregorian calendar.
+ /// That is,
+ /// Taiwan year = Gregorian year - 1911. So 1912/01/01 A.D. is Taiwan 1/01/01
+ /// </summary>
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1912/01/01 9999/12/31
+ /// Taiwan 01/01/01 8088/12/31
+ /// </remarks>
public class TaiwanCalendar : Calendar
{
- //
- // The era value for the current era.
- //
-
// Since
// Gregorian Year = Era Year + yearOffset
// When Gregorian Year 1912 is year 1, so that
// 1912 = 1 + yearOffset
// So yearOffset = 1911
- //m_EraInfo[0] = new EraInfo(1, new DateTime(1912, 1, 1).Ticks, 1911, 1, GregorianCalendar.MaxYear - 1911);
-
- // Initialize our era info.
- internal static EraInfo[] taiwanEraInfo = new EraInfo[] {
+ private static EraInfo[] s_taiwanEraInfo = new EraInfo[]
+ {
new EraInfo( 1, 1912, 1, 1, 1911, 1, GregorianCalendar.MaxYear - 1911) // era #, start year/month/day, yearOffset, minEraYear
};
- internal static volatile Calendar s_defaultInstance;
+ private static volatile Calendar s_defaultInstance;
- internal GregorianCalendarHelper helper;
-
- /*=================================GetDefaultInstance==========================
- **Action: Internal method to provide a default intance of TaiwanCalendar. Used by NLS+ implementation
- ** and other calendars.
- **Returns:
- **Arguments:
- **Exceptions:
- ============================================================================*/
+ private readonly GregorianCalendarHelper _helper;
internal static Calendar GetDefaultInstance()
{
- if (s_defaultInstance == null)
- {
- s_defaultInstance = new TaiwanCalendar();
- }
- return (s_defaultInstance);
+ return s_defaultInstance ?? (s_defaultInstance = new TaiwanCalendar());
}
- internal static readonly DateTime calendarMinValue = new DateTime(1912, 1, 1);
-
-
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (calendarMinValue);
- }
- }
+ private static readonly DateTime s_calendarMinValue = new DateTime(1912, 1, 1);
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
+ public override DateTime MinSupportedDateTime => s_calendarMinValue;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
+ public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
- // Return the type of the Taiwan calendar.
- //
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
public TaiwanCalendar()
{
@@ -97,185 +55,149 @@ namespace System.Globalization
}
catch (ArgumentException e)
{
- throw new TypeInitializationException(this.GetType().ToString(), e);
+ throw new TypeInitializationException(GetType().ToString(), e);
}
- helper = new GregorianCalendarHelper(this, taiwanEraInfo);
- }
- internal override CalendarId ID
- {
- get
- {
- return CalendarId.TAIWAN;
- }
+ _helper = new GregorianCalendarHelper(this, s_taiwanEraInfo);
}
+ internal override CalendarId ID => CalendarId.TAIWAN;
public override DateTime AddMonths(DateTime time, int months)
{
- return (helper.AddMonths(time, months));
+ return _helper.AddMonths(time, months);
}
-
public override DateTime AddYears(DateTime time, int years)
{
- return (helper.AddYears(time, years));
+ return _helper.AddYears(time, years);
}
-
public override int GetDaysInMonth(int year, int month, int era)
{
- return (helper.GetDaysInMonth(year, month, era));
+ return _helper.GetDaysInMonth(year, month, era);
}
-
public override int GetDaysInYear(int year, int era)
{
- return (helper.GetDaysInYear(year, era));
+ return _helper.GetDaysInYear(year, era);
}
-
public override int GetDayOfMonth(DateTime time)
{
- return (helper.GetDayOfMonth(time));
+ return _helper.GetDayOfMonth(time);
}
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return (helper.GetDayOfWeek(time));
+ return _helper.GetDayOfWeek(time);
}
-
public override int GetDayOfYear(DateTime time)
{
- return (helper.GetDayOfYear(time));
+ return _helper.GetDayOfYear(time);
}
-
public override int GetMonthsInYear(int year, int era)
{
- return (helper.GetMonthsInYear(year, era));
+ return _helper.GetMonthsInYear(year, era);
}
-
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
- return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
+ return _helper.GetWeekOfYear(time, rule, firstDayOfWeek);
}
-
public override int GetEra(DateTime time)
{
- return (helper.GetEra(time));
+ return _helper.GetEra(time);
}
public override int GetMonth(DateTime time)
{
- return (helper.GetMonth(time));
+ return _helper.GetMonth(time);
}
-
public override int GetYear(DateTime time)
{
- return (helper.GetYear(time));
+ return _helper.GetYear(time);
}
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
- return (helper.IsLeapDay(year, month, day, era));
+ return _helper.IsLeapDay(year, month, day, era);
}
-
public override bool IsLeapYear(int year, int era)
{
- return (helper.IsLeapYear(year, era));
+ return _helper.IsLeapYear(year, era);
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
public override int GetLeapMonth(int year, int era)
{
- return (helper.GetLeapMonth(year, era));
+ return _helper.GetLeapMonth(year, era);
}
-
public override bool IsLeapMonth(int year, int month, int era)
{
- return (helper.IsLeapMonth(year, month, era));
+ return _helper.IsLeapMonth(year, month, era);
}
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
- return (helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era));
+ return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era);
}
+ public override int[] Eras => _helper.Eras;
- public override int[] Eras
- {
- get
- {
- return (helper.Eras);
- }
- }
-
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 99;
+ private const int DefaultTwoDigitYearMax = 99;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
- if (value < 99 || value > helper.MaxYear)
+ if (value < 99 || value > _helper.MaxYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- helper.MaxYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, _helper.MaxYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
- // For Taiwan calendar, four digit year is not used.
- // Therefore, for any two digit number, we just return the original number.
+ /// <summary>
+ /// For Taiwan calendar, four digit year is not used.
+ /// Therefore, for any two digit number, we just return the original number.
+ /// </summary>
public override int ToFourDigitYear(int year)
{
if (year <= 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedPosNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedPosNum);
}
-
- if (year > helper.MaxYear)
+ if (year > _helper.MaxYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 1,
- helper.MaxYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, 1, _helper.MaxYear));
}
- return (year);
+
+ return year;
}
}
}
-
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs
index 451fc30747..4898e59411 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs
@@ -2,18 +2,15 @@
// 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;
-
namespace System.Globalization
{
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1912/02/18 2051/02/10
- ** TaiwanLunisolar 1912/01/01 2050/13/29
- */
-
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1912/02/18 2051/02/10
+ /// TaiwanLunisolar 1912/01/01 2050/13/29
+ /// </remarks>
public class TaiwanLunisolarCalendar : EastAsianLunisolarCalendar
{
// Since
@@ -21,46 +18,22 @@ namespace System.Globalization
// When Gregorian Year 1912 is year 1, so that
// 1912 = 1 + yearOffset
// So yearOffset = 1911
- //m_EraInfo[0] = new EraInfo(1, new DateTime(1912, 1, 1).Ticks, 1911, 1, GregorianCalendar.MaxYear - 1911);
-
- // Initialize our era info.
- internal static EraInfo[] taiwanLunisolarEraInfo = new EraInfo[] {
+ private static readonly EraInfo[] s_taiwanLunisolarEraInfo = new EraInfo[]
+ {
new EraInfo( 1, 1912, 1, 1, 1911, 1, GregorianCalendar.MaxYear - 1911) // era #, start year/month/day, yearOffset, minEraYear
};
- internal GregorianCalendarHelper helper;
+ private readonly GregorianCalendarHelper _helper;
- internal const int MIN_LUNISOLAR_YEAR = 1912;
- internal const int MAX_LUNISOLAR_YEAR = 2050;
+ private const int MinLunisolarYear = 1912;
+ private const int MaxLunisolarYear = 2050;
- internal const int MIN_GREGORIAN_YEAR = 1912;
- internal const int MIN_GREGORIAN_MONTH = 2;
- internal const int MIN_GREGORIAN_DAY = 18;
-
- internal const int MAX_GREGORIAN_YEAR = 2051;
- internal const int MAX_GREGORIAN_MONTH = 2;
- internal const int MAX_GREGORIAN_DAY = 10;
-
- internal static DateTime minDate = new DateTime(MIN_GREGORIAN_YEAR, MIN_GREGORIAN_MONTH, MIN_GREGORIAN_DAY);
- internal static DateTime maxDate = new DateTime((new DateTime(MAX_GREGORIAN_YEAR, MAX_GREGORIAN_MONTH, MAX_GREGORIAN_DAY, 23, 59, 59, 999)).Ticks + 9999);
-
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (minDate);
- }
- }
+ private static readonly DateTime s_minDate = new DateTime(1912, 2, 18);
+ private static readonly DateTime s_maxDate = new DateTime((new DateTime(2051, 2, 10, 23, 59, 59, 999)).Ticks + 9999);
+ public override DateTime MinSupportedDateTime => s_minDate;
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (maxDate);
- }
- }
+ public override DateTime MaxSupportedDateTime => s_maxDate;
protected override int DaysInYearBeforeMinSupportedYear
{
@@ -217,106 +190,50 @@ namespace System.Globalization
*/};
- internal override int MinCalendarYear
- {
- get
- {
- return (MIN_LUNISOLAR_YEAR);
- }
- }
+ internal override int MinCalendarYear => MinLunisolarYear;
- internal override int MaxCalendarYear
- {
- get
- {
- return (MAX_LUNISOLAR_YEAR);
- }
- }
+ internal override int MaxCalendarYear => MaxLunisolarYear;
- internal override DateTime MinDate
- {
- get
- {
- return (minDate);
- }
- }
+ internal override DateTime MinDate => s_minDate;
- internal override DateTime MaxDate
- {
- get
- {
- return (maxDate);
- }
- }
+ internal override DateTime MaxDate => s_maxDate;
- internal override EraInfo[] CalEraInfo
- {
- get
- {
- return (taiwanLunisolarEraInfo);
- }
- }
+ internal override EraInfo[] CalEraInfo => s_taiwanLunisolarEraInfo;
internal override int GetYearInfo(int lunarYear, int index)
{
- if ((lunarYear < MIN_LUNISOLAR_YEAR) || (lunarYear > MAX_LUNISOLAR_YEAR))
+ if ((lunarYear < MinLunisolarYear) || (lunarYear > MaxLunisolarYear))
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MIN_LUNISOLAR_YEAR,
- MAX_LUNISOLAR_YEAR));
+ "year",
+ lunarYear,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinLunisolarYear, MaxLunisolarYear));
}
- return s_yinfo[lunarYear - MIN_LUNISOLAR_YEAR, index];
+ return s_yinfo[lunarYear - MinLunisolarYear, index];
}
internal override int GetYear(int year, DateTime time)
{
- return helper.GetYear(year, time);
+ return _helper.GetYear(year, time);
}
internal override int GetGregorianYear(int year, int era)
{
- return helper.GetGregorianYear(year, era);
+ return _helper.GetGregorianYear(year, era);
}
public TaiwanLunisolarCalendar()
{
- helper = new GregorianCalendarHelper(this, taiwanLunisolarEraInfo);
+ _helper = new GregorianCalendarHelper(this, s_taiwanLunisolarEraInfo);
}
- public override int GetEra(DateTime time)
- {
- return (helper.GetEra(time));
- }
+ public override int GetEra(DateTime time) => _helper.GetEra(time);
- internal override CalendarId BaseCalendarID
- {
- get
- {
- return (CalendarId.TAIWAN);
- }
- }
+ internal override CalendarId BaseCalendarID => CalendarId.TAIWAN;
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.TAIWANLUNISOLAR);
- }
- }
+ internal override CalendarId ID => CalendarId.TAIWANLUNISOLAR;
-
-
- public override int[] Eras
- {
- get
- {
- return (helper.Eras);
- }
- }
+ public override int[] Eras => _helper.Eras;
}
}
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs
index 1175185dd6..8bc48db3f9 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs
@@ -2,231 +2,167 @@
// 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.Diagnostics.CodeAnalysis;
-
namespace System.Globalization
{
- /*=================================ThaiBuddhistCalendar==========================
- **
- ** ThaiBuddhistCalendar is based on Gregorian calendar. Its year value has
- ** an offset to the Gregorain calendar.
- **
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 0001/01/01 9999/12/31
- ** Thai 0544/01/01 10542/12/31
- ============================================================================*/
-
+ /// <summary>
+ /// ThaiBuddhistCalendar is based on Gregorian calendar.
+ /// Its year value has an offset to the Gregorain calendar.
+ /// </summary>
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 0001/01/01 9999/12/31
+ /// Thai 0544/01/01 10542/12/31
+ /// </remarks>
public class ThaiBuddhistCalendar : Calendar
{
- // Initialize our era info.
- internal static EraInfo[] thaiBuddhistEraInfo = new EraInfo[] {
- new EraInfo( 1, 1, 1, 1, -543, 544, GregorianCalendar.MaxYear + 543) // era #, start year/month/day, yearOffset, minEraYear
+ private static readonly EraInfo[] s_thaiBuddhistEraInfo = new EraInfo[]
+ {
+ new EraInfo( 1, 1, 1, 1, -543, 544, GregorianCalendar.MaxYear + 543) // era #, start year/month/day, yearOffset, minEraYear
};
- //
- // The era value for the current era.
- //
-
public const int ThaiBuddhistEra = 1;
- internal GregorianCalendarHelper helper;
+ private readonly GregorianCalendarHelper _helper;
+ public override DateTime MinSupportedDateTime => DateTime.MinValue;
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (DateTime.MinValue);
- }
- }
-
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (DateTime.MaxValue);
- }
- }
+ public override DateTime MaxSupportedDateTime => DateTime.MaxValue;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.SolarCalendar;
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.SolarCalendar;
public ThaiBuddhistCalendar()
{
- helper = new GregorianCalendarHelper(this, thaiBuddhistEraInfo);
- }
-
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.THAI);
- }
+ _helper = new GregorianCalendarHelper(this, s_thaiBuddhistEraInfo);
}
+ internal override CalendarId ID => CalendarId.THAI;
public override DateTime AddMonths(DateTime time, int months)
{
- return (helper.AddMonths(time, months));
+ return _helper.AddMonths(time, months);
}
-
public override DateTime AddYears(DateTime time, int years)
{
- return (helper.AddYears(time, years));
+ return _helper.AddYears(time, years);
}
-
public override int GetDaysInMonth(int year, int month, int era)
{
- return (helper.GetDaysInMonth(year, month, era));
+ return _helper.GetDaysInMonth(year, month, era);
}
-
public override int GetDaysInYear(int year, int era)
{
- return (helper.GetDaysInYear(year, era));
+ return _helper.GetDaysInYear(year, era);
}
-
public override int GetDayOfMonth(DateTime time)
{
- return (helper.GetDayOfMonth(time));
+ return _helper.GetDayOfMonth(time);
}
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return (helper.GetDayOfWeek(time));
+ return _helper.GetDayOfWeek(time);
}
-
public override int GetDayOfYear(DateTime time)
{
- return (helper.GetDayOfYear(time));
+ return _helper.GetDayOfYear(time);
}
-
public override int GetMonthsInYear(int year, int era)
{
- return (helper.GetMonthsInYear(year, era));
+ return _helper.GetMonthsInYear(year, era);
}
-
public override int GetWeekOfYear(DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)
{
- return (helper.GetWeekOfYear(time, rule, firstDayOfWeek));
+ return _helper.GetWeekOfYear(time, rule, firstDayOfWeek);
}
-
public override int GetEra(DateTime time)
{
- return (helper.GetEra(time));
+ return _helper.GetEra(time);
}
public override int GetMonth(DateTime time)
{
- return (helper.GetMonth(time));
+ return _helper.GetMonth(time);
}
-
public override int GetYear(DateTime time)
{
- return (helper.GetYear(time));
+ return _helper.GetYear(time);
}
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
- return (helper.IsLeapDay(year, month, day, era));
+ return _helper.IsLeapDay(year, month, day, era);
}
-
public override bool IsLeapYear(int year, int era)
{
- return (helper.IsLeapYear(year, era));
+ return _helper.IsLeapYear(year, era);
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
public override int GetLeapMonth(int year, int era)
{
- return (helper.GetLeapMonth(year, era));
+ return _helper.GetLeapMonth(year, era);
}
-
public override bool IsLeapMonth(int year, int month, int era)
{
- return (helper.IsLeapMonth(year, month, era));
+ return _helper.IsLeapMonth(year, month, era);
}
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
- return (helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era));
+ return _helper.ToDateTime(year, month, day, hour, minute, second, millisecond, era);
}
+ public override int[] Eras => _helper.Eras;
- public override int[] Eras
- {
- get
- {
- return (helper.Eras);
- }
- }
-
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 2572;
+ private const int DefaultTwoDigitYearMax = 2572;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
VerifyWritable();
- if (value < 99 || value > helper.MaxYear)
+ if (value < 99 || value > _helper.MaxYear)
{
throw new ArgumentOutOfRangeException(
- "year",
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- 99,
- helper.MaxYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, 99, _helper.MaxYear));
}
- twoDigitYearMax = value;
+
+ _twoDigitYearMax = value;
}
}
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
- return (helper.ToFourDigitYear(year, this.TwoDigitYearMax));
+ return _helper.ToFourDigitYear(year, TwoDigitYearMax);
}
}
}
-
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs
index 777af1800f..b54e087cce 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs
@@ -6,26 +6,26 @@ using System.Diagnostics;
namespace System.Globalization
{
- /*
- ** Calendar support range:
- ** Calendar Minimum Maximum
- ** ========== ========== ==========
- ** Gregorian 1900/04/30 2077/05/13
- ** UmAlQura 1318/01/01 1500/12/30
- */
-
+ /// <remarks>
+ /// Calendar support range:
+ /// Calendar Minimum Maximum
+ /// ========== ========== ==========
+ /// Gregorian 1900/04/30 2077/05/13
+ /// UmAlQura 1318/01/01 1500/12/30
+ /// </remarks>
public partial class UmAlQuraCalendar : Calendar
{
- internal const int MinCalendarYear = 1318;
- internal const int MaxCalendarYear = 1500;
+ private const int MinCalendarYear = 1318;
+ private const int MaxCalendarYear = 1500;
- internal struct DateMapping
+ private struct DateMapping
{
internal DateMapping(int MonthsLengthFlags, int GYear, int GMonth, int GDay)
{
HijriMonthsLengthFlags = MonthsLengthFlags;
GregorianDate = new DateTime(GYear, GMonth, GDay);
}
+
internal int HijriMonthsLengthFlags;
internal DateTime GregorianDate;
}
@@ -37,7 +37,7 @@ namespace System.Globalization
short[] rawData = new short[]
{
//These data is taken from Tables/Excel/UmAlQura.xls please make sure that the two places are in sync
- /* DaysPerM GY GM GD D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12
+ /* DaysPerM GY GM GD D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12
1318*/0x02EA, 1900, 4, 30,/* 0 1 0 1 0 1 1 1 0 1 0 0 4/30/1900
1319*/0x06E9, 1901, 4, 19,/* 1 0 0 1 0 1 1 1 0 1 1 0 4/19/1901
1320*/0x0ED2, 1902, 4, 9,/* 0 1 0 0 1 0 1 1 0 1 1 1 4/9/1902
@@ -236,60 +236,27 @@ namespace System.Globalization
public const int UmAlQuraEra = 1;
- internal const int DateCycle = 30;
- internal const int DatePartYear = 0;
- internal const int DatePartDayOfYear = 1;
- internal const int DatePartMonth = 2;
- internal const int DatePartDay = 3;
+ private const int DatePartYear = 0;
+ private const int DatePartDayOfYear = 1;
+ private const int DatePartMonth = 2;
+ private const int DatePartDay = 3;
+ private static readonly DateTime s_minDate = new DateTime(1900, 4, 30);
+ private static readonly DateTime s_maxDate = new DateTime((new DateTime(2077, 11, 16, 23, 59, 59, 999)).Ticks + 9999);
- // This is the minimal Gregorian date that we support in the UmAlQuraCalendar.
- internal static DateTime minDate = new DateTime(1900, 4, 30);
- internal static DateTime maxDate = new DateTime((new DateTime(2077, 11, 16, 23, 59, 59, 999)).Ticks + 9999);
-
- public override DateTime MinSupportedDateTime
- {
- get
- {
- return (minDate);
- }
- }
+ public override DateTime MinSupportedDateTime => s_minDate;
- public override DateTime MaxSupportedDateTime
- {
- get
- {
- return (maxDate);
- }
- }
+ public override DateTime MaxSupportedDateTime => s_maxDate;
- public override CalendarAlgorithmType AlgorithmType
- {
- get
- {
- return CalendarAlgorithmType.LunarCalendar;
- }
- }
+ public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.LunarCalendar;
public UmAlQuraCalendar()
{
}
- internal override CalendarId BaseCalendarID
- {
- get
- {
- return (CalendarId.HIJRI);
- }
- }
+ internal override CalendarId BaseCalendarID => CalendarId.HIJRI;
- internal override CalendarId ID
- {
- get
- {
- return (CalendarId.UMALQURA);
- }
- }
+ internal override CalendarId ID => CalendarId.UMALQURA;
protected override int DaysInYearBeforeMinSupportedYear
{
@@ -301,31 +268,21 @@ namespace System.Globalization
}
}
- /*==========================ConvertHijriToGregorian==========================
- ** Purpose: convert Hdate(year,month,day) to Gdate(year,month,day)
- ** Arguments:
- ** Input/Ouput: Hijrah date: year:yh, month:mh, day:dh
- ** Output: Gregorian date: year:yg, month:mg, day:dg , day of week:dayweek
- ** and returns flag found:1 not found:0
- =========================ConvertHijriToGregorian============================*/
private static void ConvertHijriToGregorian(int HijriYear, int HijriMonth, int HijriDay, ref int yg, ref int mg, ref int dg)
{
Debug.Assert((HijriYear >= MinCalendarYear) && (HijriYear <= MaxCalendarYear), "Hijri year is out of range.");
Debug.Assert(HijriMonth >= 1, "Hijri month is out of range.");
Debug.Assert(HijriDay >= 1, "Hijri day is out of range.");
- int index, b, nDays = HijriDay - 1;
- DateTime dt;
+ int nDays = HijriDay - 1;
-
- index = HijriYear - MinCalendarYear;
- dt = s_hijriYearInfo[index].GregorianDate;
-
-
- b = s_hijriYearInfo[index].HijriMonthsLengthFlags;
+ int index = HijriYear - MinCalendarYear;
+ DateTime dt = s_hijriYearInfo[index].GregorianDate;
+ int b = s_hijriYearInfo[index].HijriMonthsLengthFlags;
for (int m = 1; m < HijriMonth; m++)
{
- nDays = nDays + 29 + (b & 1); /* Add the months lengths before mh */
+ // Add the months lengths before mh
+ nDays = nDays + 29 + (b & 1);
b = b >> 1;
}
@@ -333,33 +290,27 @@ namespace System.Globalization
dt.GetDatePart(out yg, out mg, out dg);
}
- /*=================================GetAbsoluteDateUmAlQura==========================
- **Action: Gets the Absolute date for the given UmAlQura date. The absolute date means
- ** the number of days from January 1st, 1 A.D.
- **Returns:
- **Arguments:
- **Exceptions:
- ============================================================================*/
private static long GetAbsoluteDateUmAlQura(int year, int month, int day)
{
- //Caller should check the validaty of year, month and day.
-
- int yg = 0, mg = 0, dg = 0;
+ int yg = 0;
+ int mg = 0;
+ int dg = 0;
ConvertHijriToGregorian(year, month, day, ref yg, ref mg, ref dg);
return GregorianCalendar.GetAbsoluteDate(yg, mg, dg);
}
internal static void CheckTicksRange(long ticks)
{
- if (ticks < minDate.Ticks || ticks > maxDate.Ticks)
+ if (ticks < s_minDate.Ticks || ticks > s_maxDate.Ticks)
{
throw new ArgumentOutOfRangeException(
- "time",
- string.Format(
- CultureInfo.InvariantCulture,
- SR.ArgumentOutOfRange_CalendarRange,
- minDate,
- maxDate));
+ "time",
+ ticks,
+ string.Format(
+ CultureInfo.InvariantCulture,
+ SR.ArgumentOutOfRange_CalendarRange,
+ s_minDate,
+ s_maxDate));
}
}
@@ -367,7 +318,7 @@ namespace System.Globalization
{
if (era != CurrentEra && era != UmAlQuraEra)
{
- throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
+ throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
}
}
@@ -377,12 +328,9 @@ namespace System.Globalization
if (year < MinCalendarYear || year > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MinCalendarYear,
- MaxCalendarYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinCalendarYear, MaxCalendarYear));
}
}
@@ -391,29 +339,18 @@ namespace System.Globalization
CheckYearRange(year, era);
if (month < 1 || month > 12)
{
- throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month);
+ throw new ArgumentOutOfRangeException(nameof(month), month, SR.ArgumentOutOfRange_Month);
}
}
- /*========================ConvertGregorianToHijri============================
- ** Purpose: convert DateTime to Hdate(year,month,day)
- ** Arguments:
- ** Input: DateTime
- ** Output: Hijrah date: year:yh, month:mh, day:dh
- ============================================================================*/
private static void ConvertGregorianToHijri(DateTime time, ref int HijriYear, ref int HijriMonth, ref int HijriDay)
{
- int index, b, DaysPerThisMonth;
- double nDays;
- TimeSpan ts;
- int yh1 = 0, mh1 = 0, dh1 = 0;
-
- Debug.Assert((time.Ticks >= minDate.Ticks) && (time.Ticks <= maxDate.Ticks), "Gregorian date is out of range.");
+ Debug.Assert((time.Ticks >= s_minDate.Ticks) && (time.Ticks <= s_maxDate.Ticks), "Gregorian date is out of range.");
// Find the index where we should start our search by quessing the Hijri year that we will be in HijriYearInfo.
// A Hijri year is 354 or 355 days. Use 355 days so that we will search from a lower index.
- index = (int)((time.Ticks - minDate.Ticks) / Calendar.TicksPerDay) / 355;
+ int index = (int)((time.Ticks - s_minDate.Ticks) / Calendar.TicksPerDay) / 355;
do
{
} while (time.CompareTo(s_hijriYearInfo[++index].GregorianDate) > 0); //while greater
@@ -423,20 +360,19 @@ namespace System.Globalization
index--;
}
- ts = time.Subtract(s_hijriYearInfo[index].GregorianDate);
- yh1 = index + MinCalendarYear;
-
- mh1 = 1;
- dh1 = 1;
- nDays = ts.TotalDays;
- b = s_hijriYearInfo[index].HijriMonthsLengthFlags;
- DaysPerThisMonth = 29 + (b & 1);
+ TimeSpan ts = time.Subtract(s_hijriYearInfo[index].GregorianDate);
+ int yh1 = index + MinCalendarYear;
+ int mh1 = 1;
+ int dh1 = 1;
+ double nDays = ts.TotalDays;
+ int b = s_hijriYearInfo[index].HijriMonthsLengthFlags;
+ int daysPerThisMonth = 29 + (b & 1);
- while (nDays >= DaysPerThisMonth)
+ while (nDays >= daysPerThisMonth)
{
- nDays -= DaysPerThisMonth;
+ nDays -= daysPerThisMonth;
b = b >> 1;
- DaysPerThisMonth = 29 + (b & 1);
+ daysPerThisMonth = 29 + (b & 1);
mh1++;
}
dh1 += (int)nDays;
@@ -446,20 +382,13 @@ namespace System.Globalization
HijriYear = yh1;
}
- /*=================================GetDatePart==========================
- **Action: Returns a given date part of this <i>DateTime</i>. This method is used
- ** to compute the year, day-of-year, month, or day part.
- **Returns:
- **Arguments:
- **Exceptions: ArgumentException if part is incorrect.
- **Notes:
- ** First, we get the absolute date (the number of days from January 1st, 1 A.C) for the given ticks.
- ** Use the formula (((AbsoluteDate - 226894) * 33) / (33 * 365 + 8)) + 1, we can a rough value for the UmAlQura year.
- ** In order to get the exact UmAlQura year, we compare the exact absolute date for UmAlQuraYear and (UmAlQuraYear + 1).
- ** From here, we can get the correct UmAlQura year.
- ============================================================================*/
-
- internal virtual int GetDatePart(DateTime time, int part)
+ /// <summary>
+ /// First, we get the absolute date (the number of days from January 1st, 1 A.C) for the given ticks.
+ /// Use the formula (((AbsoluteDate - 226894) * 33) / (33 * 365 + 8)) + 1, we can a rough value for the UmAlQura year.
+ /// In order to get the exact UmAlQura year, we compare the exact absolute date for UmAlQuraYear and (UmAlQuraYear + 1).
+ /// From here, we can get the correct UmAlQura year.
+ /// </summary>
+ private int GetDatePart(DateTime time, int part)
{
int UmAlQuraYear = 0; // UmAlQura year
int UmAlQuraMonth = 0; // UmAlQura month
@@ -470,52 +399,36 @@ namespace System.Globalization
ConvertGregorianToHijri(time, ref UmAlQuraYear, ref UmAlQuraMonth, ref UmAlQuraDay);
if (part == DatePartYear)
- return (UmAlQuraYear);
-
+ {
+ return UmAlQuraYear;
+ }
if (part == DatePartMonth)
- return (UmAlQuraMonth);
-
+ {
+ return UmAlQuraMonth;
+ }
if (part == DatePartDay)
- return (UmAlQuraDay);
-
+ {
+ return UmAlQuraDay;
+ }
if (part == DatePartDayOfYear)
+ {
return (int)(GetAbsoluteDateUmAlQura(UmAlQuraYear, UmAlQuraMonth, UmAlQuraDay) - GetAbsoluteDateUmAlQura(UmAlQuraYear, 1, 1) + 1);
+ }
// Incorrect part value.
throw new InvalidOperationException(SR.InvalidOperation_DateTimeParsing);
}
- // Returns the DateTime resulting from adding the given number of
- // months to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year and month parts of the specified DateTime by
- // value months, and, if required, adjusting the day part of the
- // resulting date downwards to the last day of the resulting month in the
- // resulting year. The time-of-day part of the result is the same as the
- // time-of-day part of the specified DateTime.
- //
- // In more precise terms, considering the specified DateTime to be of the
- // form y / m / d + t, where y is the
- // year, m is the month, d is the day, and t is the
- // time-of-day, the result is y1 / m1 / d1 + t,
- // where y1 and m1 are computed by adding value months
- // to y and m, and d1 is the largest value less than
- // or equal to d that denotes a valid day in month m1 of year
- // y1.
- //
-
-
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException(
- nameof(months),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- -120000,
- 120000));
+ nameof(months),
+ months,
+ SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
}
+
// Get the date in UmAlQura calendar.
int y = GetDatePart(time, DatePartYear);
int m = GetDatePart(time, DatePartMonth);
@@ -541,167 +454,101 @@ namespace System.Globalization
d = days;
}
}
+
CheckYearRange(y, UmAlQuraEra);
DateTime dt = new DateTime(GetAbsoluteDateUmAlQura(y, m, d) * TicksPerDay + time.Ticks % TicksPerDay);
Calendar.CheckAddResult(dt.Ticks, MinSupportedDateTime, MaxSupportedDateTime);
- return (dt);
+ return dt;
}
- // Returns the DateTime resulting from adding the given number of
- // years to the specified DateTime. The result is computed by incrementing
- // (or decrementing) the year part of the specified DateTime by value
- // years. If the month and day of the specified DateTime is 2/29, and if the
- // resulting year is not a leap year, the month and day of the resulting
- // DateTime becomes 2/28. Otherwise, the month, day, and time-of-day
- // parts of the result are the same as those of the specified DateTime.
- //
-
-
public override DateTime AddYears(DateTime time, int years)
{
- return (AddMonths(time, years * 12));
+ return AddMonths(time, years * 12);
}
- // Returns the day-of-month part of the specified DateTime. The returned
- // value is an integer between 1 and 31.
- //
-
-
public override int GetDayOfMonth(DateTime time)
{
- return (GetDatePart(time, DatePartDay));
+ return GetDatePart(time, DatePartDay);
}
- // Returns the day-of-week part of the specified DateTime. The returned value
- // is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
- // Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
- // Thursday, 5 indicates Friday, and 6 indicates Saturday.
- //
-
-
public override DayOfWeek GetDayOfWeek(DateTime time)
{
- return ((DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7));
+ return (DayOfWeek)((int)(time.Ticks / TicksPerDay + 1) % 7);
}
- // Returns the day-of-year part of the specified DateTime. The returned value
- // is an integer between 1 and 354 or 355.
- //
-
-
public override int GetDayOfYear(DateTime time)
{
- return (GetDatePart(time, DatePartDayOfYear));
- }
-
- /*
- internal bool CouldBeLeapYear(int year)
- {
- return ((((year * 11) + 14) % 30) < 11);
+ return GetDatePart(time, DatePartDayOfYear);
}
- */
-
- // Returns the number of days in the month given by the year and
- // month arguments.
- //
-
public override int GetDaysInMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
if ((s_hijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags & (1 << month - 1)) == 0)
+ {
return 29;
+ }
else
+ {
return 30;
+ }
}
internal static int RealGetDaysInYear(int year)
{
- int days = 0, b;
+ int days = 0;
Debug.Assert((year >= MinCalendarYear) && (year <= MaxCalendarYear), "Hijri year is out of range.");
- b = s_hijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags;
+ int b = s_hijriYearInfo[year - MinCalendarYear].HijriMonthsLengthFlags;
for (int m = 1; m <= 12; m++)
{
days = days + 29 + (b & 1); /* Add the months lengths before mh */
b = b >> 1;
}
+
Debug.Assert((days == 354) || (days == 355), "Hijri year has to be 354 or 355 days.");
return days;
}
- // Returns the number of days in the year given by the year argument for the current era.
- //
-
-
public override int GetDaysInYear(int year, int era)
{
CheckYearRange(year, era);
- return (RealGetDaysInYear(year));
+ return RealGetDaysInYear(year);
}
- // Returns the era for the specified DateTime value.
-
-
public override int GetEra(DateTime time)
{
CheckTicksRange(time.Ticks);
- return (UmAlQuraEra);
- }
-
-
-
- public override int[] Eras
- {
- get
- {
- return (new int[] { UmAlQuraEra });
- }
+ return UmAlQuraEra;
}
- // Returns the month part of the specified DateTime. The returned value is an
- // integer between 1 and 12.
- //
-
+ public override int[] Eras => new int[] { UmAlQuraEra };
public override int GetMonth(DateTime time)
{
- return (GetDatePart(time, DatePartMonth));
+ return GetDatePart(time, DatePartMonth);
}
- // Returns the number of months in the specified year and era.
-
-
public override int GetMonthsInYear(int year, int era)
{
CheckYearRange(year, era);
- return (12);
+ return 12;
}
- // Returns the year part of the specified DateTime. The returned value is an
- // integer between MinCalendarYear and MaxCalendarYear.
- //
-
-
public override int GetYear(DateTime time)
{
- return (GetDatePart(time, DatePartYear));
+ return GetDatePart(time, DatePartYear);
}
- // Checks whether a given day in the specified era is a leap day. This method returns true if
- // the date is a leap day, or false if not.
- //
-
-
public override bool IsLeapDay(int year, int month, int day, int era)
{
if (day >= 1 && day <= 29)
{
CheckYearMonthRange(year, month, era);
- return (false);
+ return false;
}
// The year/month/era value checking is done in GetDaysInMonth().
@@ -709,56 +556,31 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Day,
- daysInMonth,
- month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
- return (false);
+ return false;
}
- // Returns the leap month in a calendar year of the specified era. This method returns 0
- // if this calendar does not have leap month, or this year is not a leap year.
- //
-
-
public override int GetLeapMonth(int year, int era)
{
CheckYearRange(year, era);
- return (0);
+ return 0;
}
- // Checks whether a given month in the specified era is a leap month. This method returns true if
- // month is a leap month, or false if not.
- //
-
-
public override bool IsLeapMonth(int year, int month, int era)
{
CheckYearMonthRange(year, month, era);
- return (false);
+ return false;
}
- // Checks whether a given year in the specified era is a leap year. This method returns true if
- // year is a leap year, or false if not.
- //
-
-
public override bool IsLeapYear(int year, int era)
{
CheckYearRange(year, era);
- if (RealGetDaysInYear(year) == 355)
- return true;
- else
- return false;
+ return RealGetDaysInYear(year) == 355;
}
- // Returns the date and time converted to a DateTime value. Throws an exception if the n-tuple is invalid.
- //
-
-
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
if (day >= 1 && day <= 29)
@@ -773,86 +595,70 @@ namespace System.Globalization
if (day < 1 || day > daysInMonth)
{
throw new ArgumentOutOfRangeException(
- nameof(day),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Day,
- daysInMonth,
- month));
+ nameof(day),
+ day,
+ SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
}
DayInRang:
long lDate = GetAbsoluteDateUmAlQura(year, month, day);
-
- if (lDate >= 0)
- {
- return (new DateTime(lDate * GregorianCalendar.TicksPerDay + TimeToTicks(hour, minute, second, millisecond)));
- }
- else
+ if (lDate < 0)
{
throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
}
- }
-
- private const int DEFAULT_TWO_DIGIT_YEAR_MAX = 1451;
+ return new DateTime(lDate * GregorianCalendar.TicksPerDay + TimeToTicks(hour, minute, second, millisecond));
+ }
+ private const int DefaultTwoDigitYearMax = 1451;
public override int TwoDigitYearMax
{
get
{
- if (twoDigitYearMax == -1)
+ if (_twoDigitYearMax == -1)
{
- twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DEFAULT_TWO_DIGIT_YEAR_MAX);
+ _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax);
}
- return (twoDigitYearMax);
- }
+ return _twoDigitYearMax;
+ }
set
{
if (value != 99 && (value < MinCalendarYear || value > MaxCalendarYear))
{
throw new ArgumentOutOfRangeException(
- nameof(value),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MinCalendarYear,
- MaxCalendarYear));
+ nameof(value),
+ value,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinCalendarYear, MaxCalendarYear));
}
+
VerifyWritable();
// We allow year 99 to be set so that one can make ToFourDigitYearMax a no-op by setting TwoDigitYearMax to 99.
- twoDigitYearMax = value;
+ _twoDigitYearMax = value;
}
}
-
-
public override int ToFourDigitYear(int year)
{
if (year < 0)
{
- throw new ArgumentOutOfRangeException(nameof(year),
- SR.ArgumentOutOfRange_NeedNonNegNum);
+ throw new ArgumentOutOfRangeException(nameof(year), year, SR.ArgumentOutOfRange_NeedNonNegNum);
}
if (year < 100)
{
- return (base.ToFourDigitYear(year));
+ return base.ToFourDigitYear(year);
}
- if ((year < MinCalendarYear) || (year > MaxCalendarYear))
+ if (year < MinCalendarYear || year > MaxCalendarYear)
{
throw new ArgumentOutOfRangeException(
- nameof(year),
- string.Format(
- CultureInfo.CurrentCulture,
- SR.ArgumentOutOfRange_Range,
- MinCalendarYear,
- MaxCalendarYear));
+ nameof(year),
+ year,
+ SR.Format(SR.ArgumentOutOfRange_Range, MinCalendarYear, MaxCalendarYear));
}
- return (year);
+
+ return year;
}
}
}
-