| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Globalization |
| | | 5 | | { |
| | | 6 | | /// <remarks> |
| | | 7 | | /// Rules for the Hijri calendar: |
| | | 8 | | /// - The Hijri calendar is a strictly Lunar calendar. |
| | | 9 | | /// - Days begin at sunset. |
| | | 10 | | /// - Islamic Year 1 (Muharram 1, 1 A.H.) is equivalent to absolute date |
| | | 11 | | /// 227015 (Friday, July 16, 622 C.E. - Julian). |
| | | 12 | | /// - Leap Years occur in the 2, 5, 7, 10, 13, 16, 18, 21, 24, 26, & 29th |
| | | 13 | | /// years of a 30-year cycle. Year = leap iff ((11y+14) mod 30 < 11). |
| | | 14 | | /// - There are 12 months which contain alternately 30 and 29 days. |
| | | 15 | | /// - The 12th month, Dhu al-Hijjah, contains 30 days instead of 29 days |
| | | 16 | | /// in a leap year. |
| | | 17 | | /// - Common years have 354 days. Leap years have 355 days. |
| | | 18 | | /// - There are 10,631 days in a 30-year cycle. |
| | | 19 | | /// - The Islamic months are: |
| | | 20 | | /// 1. Muharram (30 days) 7. Rajab (30 days) |
| | | 21 | | /// 2. Safar (29 days) 8. Sha'ban (29 days) |
| | | 22 | | /// 3. Rabi I (30 days) 9. Ramadan (30 days) |
| | | 23 | | /// 4. Rabi II (29 days) 10. Shawwal (29 days) |
| | | 24 | | /// 5. Jumada I (30 days) 11. Dhu al-Qada (30 days) |
| | | 25 | | /// 6. Jumada II (29 days) 12. Dhu al-Hijjah (29 days) {30} |
| | | 26 | | /// |
| | | 27 | | /// NOTENOTE |
| | | 28 | | /// The calculation of the HijriCalendar is based on the absolute date. And the |
| | | 29 | | /// absolute date means the number of days from January 1st, 1 A.D. |
| | | 30 | | /// Therefore, we do not support the days before the January 1st, 1 A.D. |
| | | 31 | | /// |
| | | 32 | | /// Calendar support range: |
| | | 33 | | /// Calendar Minimum Maximum |
| | | 34 | | /// ========== ========== ========== |
| | | 35 | | /// Gregorian 0622/07/18 9999/12/31 |
| | | 36 | | /// Hijri 0001/01/01 9666/04/03 |
| | | 37 | | /// </remarks> |
| | | 38 | | |
| | | 39 | | public partial class HijriCalendar : Calendar |
| | | 40 | | { |
| | 0 | 41 | | public static readonly int HijriEra = 1; |
| | | 42 | | |
| | | 43 | | private const int DatePartYear = 0; |
| | | 44 | | private const int DatePartDayOfYear = 1; |
| | | 45 | | private const int DatePartMonth = 2; |
| | | 46 | | private const int DatePartDay = 3; |
| | | 47 | | |
| | | 48 | | private const int MinAdvancedHijri = -2; |
| | | 49 | | private const int MaxAdvancedHijri = 2; |
| | | 50 | | |
| | 0 | 51 | | private static ReadOnlySpan<int> HijriMonthDays => [0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325, 355]; |
| | | 52 | | |
| | 0 | 53 | | private int _hijriAdvance = int.MinValue; |
| | | 54 | | |
| | | 55 | | // DateTime.MaxValue = Hijri calendar (year:9666, month: 4, day: 3). |
| | | 56 | | private const int MaxCalendarYear = 9666; |
| | | 57 | | private const int MaxCalendarMonth = 4; |
| | | 58 | | |
| | | 59 | | // Hijri calendar (year: 1, month: 1, day:1 ) = Gregorian (year: 622, month: 7, day: 18) |
| | | 60 | | // This is the minimal Gregorian date that we support in the HijriCalendar. |
| | 0 | 61 | | private static readonly DateTime s_calendarMinValue = new DateTime(622, 7, 18); |
| | 0 | 62 | | private static readonly DateTime s_calendarMaxValue = DateTime.MaxValue; |
| | | 63 | | |
| | 0 | 64 | | public override DateTime MinSupportedDateTime => s_calendarMinValue; |
| | | 65 | | |
| | 0 | 66 | | public override DateTime MaxSupportedDateTime => s_calendarMaxValue; |
| | | 67 | | |
| | 0 | 68 | | public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.LunarCalendar; |
| | | 69 | | |
| | 0 | 70 | | public HijriCalendar() |
| | | 71 | | { |
| | 0 | 72 | | } |
| | | 73 | | |
| | 0 | 74 | | internal override CalendarId ID => CalendarId.HIJRI; |
| | | 75 | | |
| | | 76 | | protected override int DaysInYearBeforeMinSupportedYear => |
| | | 77 | | // the year before the 1st year of the cycle would have been the 30th year |
| | | 78 | | // of the previous cycle which is not a leap year. Common years have 354 days. |
| | 0 | 79 | | 354; |
| | | 80 | | |
| | | 81 | | private long GetAbsoluteDateHijri(int y, int m, int d) |
| | | 82 | | { |
| | 0 | 83 | | return (long)(DaysUpToHijriYear(y) + HijriMonthDays[m - 1] + d - 1 - HijriAdjustment); |
| | | 84 | | } |
| | | 85 | | |
| | | 86 | | private long DaysUpToHijriYear(int HijriYear) |
| | | 87 | | { |
| | | 88 | | // Compute the number of years up to the current 30 year cycle. |
| | 0 | 89 | | int numYear30 = ((HijriYear - 1) / 30) * 30; |
| | | 90 | | |
| | | 91 | | // Compute the number of years left. This is the number of years |
| | | 92 | | // into the 30 year cycle for the given year. |
| | 0 | 93 | | int numYearsLeft = HijriYear - numYear30 - 1; |
| | | 94 | | |
| | | 95 | | // Compute the number of absolute days up to the given year. |
| | 0 | 96 | | long numDays = ((numYear30 * 10631L) / 30L) + 227013L; |
| | 0 | 97 | | while (numYearsLeft > 0) |
| | | 98 | | { |
| | | 99 | | // Common year is 354 days, and leap year is 355 days. |
| | 0 | 100 | | numDays += 354 + (IsLeapYear(numYearsLeft, CurrentEra) ? 1 : 0); |
| | 0 | 101 | | numYearsLeft--; |
| | | 102 | | } |
| | | 103 | | |
| | 0 | 104 | | return numDays; |
| | | 105 | | } |
| | | 106 | | |
| | | 107 | | public int HijriAdjustment |
| | | 108 | | { |
| | | 109 | | get |
| | | 110 | | { |
| | 0 | 111 | | if (_hijriAdvance == int.MinValue) |
| | | 112 | | { |
| | | 113 | | // Never been set before. Use the system value from registry. |
| | 0 | 114 | | _hijriAdvance = GetHijriDateAdjustment(); |
| | | 115 | | } |
| | | 116 | | |
| | 0 | 117 | | return _hijriAdvance; |
| | | 118 | | } |
| | | 119 | | |
| | | 120 | | set |
| | | 121 | | { |
| | 0 | 122 | | if (value < MinAdvancedHijri || value > MaxAdvancedHijri) |
| | | 123 | | { |
| | 0 | 124 | | throw new ArgumentOutOfRangeException( |
| | 0 | 125 | | nameof(value), |
| | 0 | 126 | | value, |
| | 0 | 127 | | SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, MinAdvancedHijri, MaxAdvancedHijri)); |
| | | 128 | | } |
| | | 129 | | |
| | 0 | 130 | | VerifyWritable(); |
| | 0 | 131 | | _hijriAdvance = value; |
| | 0 | 132 | | } |
| | | 133 | | } |
| | | 134 | | |
| | | 135 | | internal static void CheckTicksRange(long ticks) |
| | | 136 | | { |
| | 0 | 137 | | if (ticks < s_calendarMinValue.Ticks || ticks > s_calendarMaxValue.Ticks) |
| | | 138 | | { |
| | 0 | 139 | | throw new ArgumentOutOfRangeException( |
| | 0 | 140 | | "time", |
| | 0 | 141 | | ticks, |
| | 0 | 142 | | SR.Format( |
| | 0 | 143 | | CultureInfo.InvariantCulture, |
| | 0 | 144 | | SR.ArgumentOutOfRange_CalendarRange, |
| | 0 | 145 | | s_calendarMinValue, |
| | 0 | 146 | | s_calendarMaxValue)); |
| | | 147 | | } |
| | 0 | 148 | | } |
| | | 149 | | |
| | | 150 | | internal static void CheckEraRange(int era) |
| | | 151 | | { |
| | 0 | 152 | | if (era != CurrentEra && era != HijriEra) |
| | | 153 | | { |
| | 0 | 154 | | throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue); |
| | | 155 | | } |
| | 0 | 156 | | } |
| | | 157 | | |
| | | 158 | | internal static void CheckYearRange(int year, int era) |
| | | 159 | | { |
| | 0 | 160 | | CheckEraRange(era); |
| | 0 | 161 | | if (year < 1 || year > MaxCalendarYear) |
| | | 162 | | { |
| | 0 | 163 | | throw new ArgumentOutOfRangeException( |
| | 0 | 164 | | nameof(year), |
| | 0 | 165 | | SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarYear)); |
| | | 166 | | } |
| | 0 | 167 | | } |
| | | 168 | | |
| | | 169 | | internal static void CheckYearMonthRange(int year, int month, int era) |
| | | 170 | | { |
| | 0 | 171 | | CheckYearRange(year, era); |
| | 0 | 172 | | if (year == MaxCalendarYear) |
| | | 173 | | { |
| | 0 | 174 | | if (month > MaxCalendarMonth) |
| | | 175 | | { |
| | 0 | 176 | | throw new ArgumentOutOfRangeException( |
| | 0 | 177 | | nameof(month), |
| | 0 | 178 | | month, |
| | 0 | 179 | | SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarMonth)); |
| | | 180 | | } |
| | | 181 | | } |
| | | 182 | | |
| | 0 | 183 | | if (month < 1 || month > 12) |
| | | 184 | | { |
| | 0 | 185 | | ThrowHelper.ThrowArgumentOutOfRange_Month(month); |
| | | 186 | | } |
| | 0 | 187 | | } |
| | | 188 | | |
| | | 189 | | /// <summary> |
| | | 190 | | /// First, we get the absolute date (the number of days from January 1st, 1 A.C) for the given ticks. |
| | | 191 | | /// Use the formula (((AbsoluteDate - 227013) * 30) / 10631) + 1, we can a rough value for the Hijri year. |
| | | 192 | | /// In order to get the exact Hijri year, we compare the exact absolute date for HijriYear and (HijriYear + 1). |
| | | 193 | | /// From here, we can get the correct Hijri year. |
| | | 194 | | /// </summary> |
| | | 195 | | private int GetDatePart(long ticks, int part) |
| | | 196 | | { |
| | 0 | 197 | | CheckTicksRange(ticks); |
| | | 198 | | |
| | | 199 | | // Get the absolute date. The absolute date is the number of days from January 1st, 1 A.D. |
| | | 200 | | // 1/1/0001 is absolute date 1. |
| | 0 | 201 | | long numDays = ticks / TimeSpan.TicksPerDay + 1; |
| | | 202 | | |
| | | 203 | | // See how much we need to backup or advance |
| | 0 | 204 | | numDays += HijriAdjustment; |
| | | 205 | | |
| | | 206 | | // Calculate the appromixate Hijri Year from this magic formula. |
| | 0 | 207 | | int hijriYear = (int)(((numDays - 227013) * 30) / 10631) + 1; |
| | | 208 | | |
| | 0 | 209 | | long daysToHijriYear = DaysUpToHijriYear(hijriYear); // The absolute date for HijriYear |
| | 0 | 210 | | long daysOfHijriYear = GetDaysInYear(hijriYear, CurrentEra); // The number of days for (HijriYear+1) year |
| | | 211 | | |
| | 0 | 212 | | if (numDays < daysToHijriYear) |
| | | 213 | | { |
| | 0 | 214 | | daysToHijriYear -= daysOfHijriYear; |
| | 0 | 215 | | hijriYear--; |
| | | 216 | | } |
| | 0 | 217 | | else if (numDays == daysToHijriYear) |
| | | 218 | | { |
| | 0 | 219 | | hijriYear--; |
| | 0 | 220 | | daysToHijriYear -= GetDaysInYear(hijriYear, CurrentEra); |
| | | 221 | | } |
| | | 222 | | else |
| | | 223 | | { |
| | 0 | 224 | | if (numDays > daysToHijriYear + daysOfHijriYear) |
| | | 225 | | { |
| | 0 | 226 | | daysToHijriYear += daysOfHijriYear; |
| | 0 | 227 | | hijriYear++; |
| | | 228 | | } |
| | | 229 | | } |
| | 0 | 230 | | if (part == DatePartYear) |
| | | 231 | | { |
| | 0 | 232 | | return hijriYear; |
| | | 233 | | } |
| | | 234 | | |
| | | 235 | | // Calculate the Hijri Month. |
| | 0 | 236 | | int hijriMonth = 1; |
| | 0 | 237 | | numDays -= daysToHijriYear; |
| | | 238 | | |
| | 0 | 239 | | if (part == DatePartDayOfYear) |
| | | 240 | | { |
| | 0 | 241 | | return (int)numDays; |
| | | 242 | | } |
| | | 243 | | |
| | 0 | 244 | | while ((hijriMonth <= 12) && (numDays > HijriMonthDays[hijriMonth - 1])) |
| | | 245 | | { |
| | 0 | 246 | | hijriMonth++; |
| | | 247 | | } |
| | 0 | 248 | | hijriMonth--; |
| | | 249 | | |
| | 0 | 250 | | if (part == DatePartMonth) |
| | | 251 | | { |
| | 0 | 252 | | return hijriMonth; |
| | | 253 | | } |
| | | 254 | | |
| | | 255 | | // Calculate the Hijri Day. |
| | 0 | 256 | | int hijriDay = (int)(numDays - HijriMonthDays[hijriMonth - 1]); |
| | | 257 | | |
| | 0 | 258 | | if (part == DatePartDay) |
| | | 259 | | { |
| | 0 | 260 | | return hijriDay; |
| | | 261 | | } |
| | | 262 | | |
| | | 263 | | // Incorrect part value. |
| | 0 | 264 | | throw new InvalidOperationException(SR.InvalidOperation_DateTimeParsing); |
| | | 265 | | } |
| | | 266 | | |
| | | 267 | | public override DateTime AddMonths(DateTime time, int months) |
| | | 268 | | { |
| | 0 | 269 | | if (months < -120000 || months > 120000) |
| | | 270 | | { |
| | 0 | 271 | | throw new ArgumentOutOfRangeException( |
| | 0 | 272 | | nameof(months), |
| | 0 | 273 | | months, |
| | 0 | 274 | | SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000)); |
| | | 275 | | } |
| | | 276 | | |
| | | 277 | | // Get the date in Hijri calendar. |
| | 0 | 278 | | int y = GetDatePart(time.Ticks, DatePartYear); |
| | 0 | 279 | | int m = GetDatePart(time.Ticks, DatePartMonth); |
| | 0 | 280 | | int d = GetDatePart(time.Ticks, DatePartDay); |
| | 0 | 281 | | int i = m - 1 + months; |
| | 0 | 282 | | if (i >= 0) |
| | | 283 | | { |
| | 0 | 284 | | m = i % 12 + 1; |
| | 0 | 285 | | y += i / 12; |
| | | 286 | | } |
| | | 287 | | else |
| | | 288 | | { |
| | 0 | 289 | | m = 12 + (i + 1) % 12; |
| | 0 | 290 | | y += (i - 11) / 12; |
| | | 291 | | } |
| | | 292 | | |
| | 0 | 293 | | int days = GetDaysInMonth(y, m); |
| | 0 | 294 | | if (d > days) |
| | | 295 | | { |
| | 0 | 296 | | d = days; |
| | | 297 | | } |
| | | 298 | | |
| | 0 | 299 | | long ticks = GetAbsoluteDateHijri(y, m, d) * TimeSpan.TicksPerDay + (time.Ticks % TimeSpan.TicksPerDay); |
| | 0 | 300 | | CheckAddResult(ticks, MinSupportedDateTime, MaxSupportedDateTime); |
| | 0 | 301 | | return new DateTime(ticks); |
| | | 302 | | } |
| | | 303 | | |
| | | 304 | | public override DateTime AddYears(DateTime time, int years) |
| | | 305 | | { |
| | 0 | 306 | | return AddMonths(time, years * 12); |
| | | 307 | | } |
| | | 308 | | |
| | | 309 | | public override int GetDayOfMonth(DateTime time) |
| | | 310 | | { |
| | 0 | 311 | | return GetDatePart(time.Ticks, DatePartDay); |
| | | 312 | | } |
| | | 313 | | |
| | 0 | 314 | | public override DayOfWeek GetDayOfWeek(DateTime time) => time.DayOfWeek; |
| | | 315 | | |
| | | 316 | | public override int GetDayOfYear(DateTime time) |
| | | 317 | | { |
| | 0 | 318 | | return GetDatePart(time.Ticks, DatePartDayOfYear); |
| | | 319 | | } |
| | | 320 | | |
| | | 321 | | public override int GetDaysInMonth(int year, int month, int era) |
| | | 322 | | { |
| | 0 | 323 | | CheckYearMonthRange(year, month, era); |
| | 0 | 324 | | if (month == 12) |
| | | 325 | | { |
| | | 326 | | // For the 12th month, leap year has 30 days, and common year has 29 days. |
| | 0 | 327 | | return IsLeapYear(year, CurrentEra) ? 30 : 29; |
| | | 328 | | } |
| | | 329 | | |
| | | 330 | | // Other months contain 30 and 29 days alternatively. The 1st month has 30 days. |
| | 0 | 331 | | return ((month % 2) == 1) ? 30 : 29; |
| | | 332 | | } |
| | | 333 | | |
| | | 334 | | public override int GetDaysInYear(int year, int era) |
| | | 335 | | { |
| | 0 | 336 | | CheckYearRange(year, era); |
| | | 337 | | // Common years have 354 days. Leap years have 355 days. |
| | 0 | 338 | | return IsLeapYear(year, CurrentEra) ? 355 : 354; |
| | | 339 | | } |
| | | 340 | | |
| | | 341 | | public override int GetEra(DateTime time) |
| | | 342 | | { |
| | 0 | 343 | | CheckTicksRange(time.Ticks); |
| | 0 | 344 | | return HijriEra; |
| | | 345 | | } |
| | | 346 | | |
| | 0 | 347 | | public override int[] Eras => [HijriEra]; |
| | | 348 | | |
| | | 349 | | public override int GetMonth(DateTime time) |
| | | 350 | | { |
| | 0 | 351 | | return GetDatePart(time.Ticks, DatePartMonth); |
| | | 352 | | } |
| | | 353 | | |
| | | 354 | | public override int GetMonthsInYear(int year, int era) |
| | | 355 | | { |
| | 0 | 356 | | CheckYearRange(year, era); |
| | 0 | 357 | | return 12; |
| | | 358 | | } |
| | | 359 | | |
| | | 360 | | public override int GetYear(DateTime time) |
| | | 361 | | { |
| | 0 | 362 | | return GetDatePart(time.Ticks, DatePartYear); |
| | | 363 | | } |
| | | 364 | | |
| | | 365 | | public override bool IsLeapDay(int year, int month, int day, int era) |
| | | 366 | | { |
| | | 367 | | // The year/month/era value checking is done in GetDaysInMonth(). |
| | 0 | 368 | | int daysInMonth = GetDaysInMonth(year, month, era); |
| | 0 | 369 | | if (day < 1 || day > daysInMonth) |
| | | 370 | | { |
| | 0 | 371 | | throw new ArgumentOutOfRangeException( |
| | 0 | 372 | | nameof(day), |
| | 0 | 373 | | day, |
| | 0 | 374 | | SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month)); |
| | | 375 | | } |
| | | 376 | | |
| | 0 | 377 | | return IsLeapYear(year, era) && month == 12 && day == 30; |
| | | 378 | | } |
| | | 379 | | |
| | | 380 | | public override int GetLeapMonth(int year, int era) |
| | | 381 | | { |
| | 0 | 382 | | CheckYearRange(year, era); |
| | 0 | 383 | | return 0; |
| | | 384 | | } |
| | | 385 | | |
| | | 386 | | public override bool IsLeapMonth(int year, int month, int era) |
| | | 387 | | { |
| | 0 | 388 | | CheckYearMonthRange(year, month, era); |
| | 0 | 389 | | return false; |
| | | 390 | | } |
| | | 391 | | |
| | | 392 | | public override bool IsLeapYear(int year, int era) |
| | | 393 | | { |
| | 0 | 394 | | CheckYearRange(year, era); |
| | 0 | 395 | | return (((year * 11) + 14) % 30) < 11; |
| | | 396 | | } |
| | | 397 | | |
| | | 398 | | public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisec |
| | | 399 | | { |
| | | 400 | | // The year/month/era checking is done in GetDaysInMonth(). |
| | 0 | 401 | | int daysInMonth = GetDaysInMonth(year, month, era); |
| | 0 | 402 | | if (day < 1 || day > daysInMonth) |
| | | 403 | | { |
| | 0 | 404 | | throw new ArgumentOutOfRangeException( |
| | 0 | 405 | | nameof(day), |
| | 0 | 406 | | day, |
| | 0 | 407 | | SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month)); |
| | | 408 | | } |
| | | 409 | | |
| | 0 | 410 | | long lDate = GetAbsoluteDateHijri(year, month, day); |
| | 0 | 411 | | if (lDate < 0) |
| | | 412 | | { |
| | 0 | 413 | | throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay); |
| | | 414 | | } |
| | | 415 | | |
| | 0 | 416 | | return new DateTime(lDate * TimeSpan.TicksPerDay + TimeToTicks(hour, minute, second, millisecond)); |
| | | 417 | | } |
| | | 418 | | |
| | | 419 | | private const int DefaultTwoDigitYearMax = 1451; |
| | | 420 | | |
| | | 421 | | public override int TwoDigitYearMax |
| | | 422 | | { |
| | | 423 | | get |
| | | 424 | | { |
| | 0 | 425 | | if (_twoDigitYearMax == -1) |
| | | 426 | | { |
| | 0 | 427 | | _twoDigitYearMax = GetSystemTwoDigitYearSetting(ID, DefaultTwoDigitYearMax); |
| | | 428 | | } |
| | | 429 | | |
| | 0 | 430 | | return _twoDigitYearMax; |
| | | 431 | | } |
| | | 432 | | set |
| | | 433 | | { |
| | 0 | 434 | | VerifyWritable(); |
| | 0 | 435 | | if (value < 99 || value > MaxCalendarYear) |
| | | 436 | | { |
| | 0 | 437 | | throw new ArgumentOutOfRangeException( |
| | 0 | 438 | | nameof(value), |
| | 0 | 439 | | value, |
| | 0 | 440 | | SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxCalendarYear)); |
| | | 441 | | } |
| | | 442 | | |
| | 0 | 443 | | _twoDigitYearMax = value; |
| | 0 | 444 | | } |
| | | 445 | | } |
| | | 446 | | |
| | | 447 | | public override int ToFourDigitYear(int year) |
| | | 448 | | { |
| | 0 | 449 | | ArgumentOutOfRangeException.ThrowIfNegative(year); |
| | | 450 | | |
| | 0 | 451 | | if (year < 100) |
| | | 452 | | { |
| | 0 | 453 | | return base.ToFourDigitYear(year); |
| | | 454 | | } |
| | | 455 | | |
| | 0 | 456 | | if (year > MaxCalendarYear) |
| | | 457 | | { |
| | 0 | 458 | | throw new ArgumentOutOfRangeException( |
| | 0 | 459 | | nameof(year), |
| | 0 | 460 | | year, |
| | 0 | 461 | | SR.Format(SR.ArgumentOutOfRange_Range, 1, MaxCalendarYear)); |
| | | 462 | | } |
| | 0 | 463 | | return year; |
| | | 464 | | } |
| | | 465 | | } |
| | | 466 | | } |
| | | 467 | | |