Files
2026-06-04 11:42:34 +02:00

494 lines
24 KiB
C#

using System;
namespace System.Globalization
{
/// <summary>Represents the Persian calendar.</summary>
// Token: 0x02000194 RID: 404
[Serializable]
public class PersianCalendar : Calendar
{
/// <summary>Initializes a new instance of the <see cref="T:System.Globalization.PersianCalendar" /> class. </summary>
// Token: 0x06001464 RID: 5220 RVA: 0x0004EDE4 File Offset: 0x0004CFE4
public PersianCalendar()
{
this.M_AbbrEraNames = new string[] { "A.P." };
this.M_EraNames = new string[] { "Anno Persico" };
if (this.twoDigitYearMax == 99)
{
this.twoDigitYearMax = 1410;
}
}
/// <summary>Gets the list of eras in a <see cref="T:System.Globalization.PersianCalendar" /> object.</summary>
/// <returns>An array of integers that represents the eras in a <see cref="T:System.Globalization.PersianCalendar" /> object. The array consists of a single element having a value of <see cref="F:System.Globalization.PersianCalendar.PersianEra" />.</returns>
// Token: 0x17000393 RID: 915
// (get) Token: 0x06001466 RID: 5222 RVA: 0x0004EE7C File Offset: 0x0004D07C
public override int[] Eras
{
get
{
return new int[] { PersianCalendar.PersianEra };
}
}
/// <summary>Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.</summary>
/// <returns>The last year of a 100-year range that can be represented by a 2-digit year.</returns>
/// <exception cref="T:System.InvalidOperationException">This calendar is read-only.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">The value in a set operation is less than 100 or greater than 9378.</exception>
// Token: 0x17000394 RID: 916
// (get) Token: 0x06001467 RID: 5223 RVA: 0x0004EE8C File Offset: 0x0004D08C
// (set) Token: 0x06001468 RID: 5224 RVA: 0x0004EE94 File Offset: 0x0004D094
public override int TwoDigitYearMax
{
get
{
return this.twoDigitYearMax;
}
set
{
base.CheckReadOnly();
base.M_ArgumentInRange("value", value, 100, this.M_MaxYear);
this.twoDigitYearMax = value;
}
}
// Token: 0x06001469 RID: 5225 RVA: 0x0004EEC4 File Offset: 0x0004D0C4
internal void M_CheckDateTime(DateTime time)
{
if (time.Ticks < 196036416000000000L)
{
throw new ArgumentOutOfRangeException("time", "Only positive Persian years are supported.");
}
}
// Token: 0x0600146A RID: 5226 RVA: 0x0004EEEC File Offset: 0x0004D0EC
internal void M_CheckEra(ref int era)
{
if (era == 0)
{
era = PersianCalendar.PersianEra;
}
if (era != PersianCalendar.PersianEra)
{
throw new ArgumentException("Era value was not valid.");
}
}
// Token: 0x0600146B RID: 5227 RVA: 0x0004EF14 File Offset: 0x0004D114
internal override void M_CheckYE(int year, ref int era)
{
this.M_CheckEra(ref era);
if (year < 1 || year > this.M_MaxYear)
{
throw new ArgumentOutOfRangeException("year", "Only Persian years between 1 and 9378, inclusive, are supported.");
}
}
// Token: 0x0600146C RID: 5228 RVA: 0x0004EF4C File Offset: 0x0004D14C
internal void M_CheckYME(int year, int month, ref int era)
{
this.M_CheckYE(year, ref era);
if (month < 1 || month > 12)
{
throw new ArgumentOutOfRangeException("month", "Month must be between one and twelve.");
}
if (year == this.M_MaxYear && month > 10)
{
throw new ArgumentOutOfRangeException("month", "Months in year 9378 must be between one and ten.");
}
}
// Token: 0x0600146D RID: 5229 RVA: 0x0004EFA4 File Offset: 0x0004D1A4
internal void M_CheckYMDE(int year, int month, int day, ref int era)
{
this.M_CheckYME(year, month, ref era);
base.M_ArgumentInRange("day", day, 1, this.GetDaysInMonth(year, month, era));
if (year == this.M_MaxYear && month == 10 && day > 10)
{
throw new ArgumentOutOfRangeException("day", "Days in month 10 of year 9378 must be between one and ten.");
}
}
// Token: 0x0600146E RID: 5230 RVA: 0x0004F000 File Offset: 0x0004D200
internal int fixed_from_dmy(int day, int month, int year)
{
int num = 226894;
num += 365 * (year - 1);
num += (8 * year + 21) / 33;
if (month <= 7)
{
num += 31 * (month - 1);
}
else
{
num += 30 * (month - 1) + 6;
}
return num + day;
}
// Token: 0x0600146F RID: 5231 RVA: 0x0004F050 File Offset: 0x0004D250
internal int year_from_fixed(int date)
{
return (33 * (date - 226895) + 3) / 12053 + 1;
}
// Token: 0x06001470 RID: 5232 RVA: 0x0004F068 File Offset: 0x0004D268
internal void my_from_fixed(out int month, out int year, int date)
{
year = this.year_from_fixed(date);
int num = date - this.fixed_from_dmy(1, 1, year);
if (num < 216)
{
month = num / 31 + 1;
}
else
{
month = (num - 6) / 30 + 1;
}
}
// Token: 0x06001471 RID: 5233 RVA: 0x0004F0B0 File Offset: 0x0004D2B0
internal void dmy_from_fixed(out int day, out int month, out int year, int date)
{
year = this.year_from_fixed(date);
day = date - this.fixed_from_dmy(1, 1, year);
if (day < 216)
{
month = day / 31 + 1;
day = day % 31 + 1;
}
else
{
month = (day - 6) / 30 + 1;
day = (day - 6) % 30 + 1;
}
}
// Token: 0x06001472 RID: 5234 RVA: 0x0004F110 File Offset: 0x0004D310
internal bool is_leap_year(int year)
{
return (25 * year + 11) % 33 < 8;
}
/// <summary>Returns a <see cref="T:System.DateTime" /> that is offset the specified number of months from the specified <see cref="T:System.DateTime" />.</summary>
/// <returns>A <see cref="T:System.DateTime" /> that represents the date yielded by adding the number of months specified by the <paramref name="months" /> parameter to the date specified by the <paramref name="time" /> parameter.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to which to add months. </param>
/// <param name="months">The positive or negative number of months to add. </param>
/// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="months" /> is less than -120,000 or greater than 120,000. </exception>
// Token: 0x06001473 RID: 5235 RVA: 0x0004F120 File Offset: 0x0004D320
public override DateTime AddMonths(DateTime time, int months)
{
int num = CCFixed.FromDateTime(time);
int num2;
int num3;
int num4;
this.dmy_from_fixed(out num2, out num3, out num4, num);
num3 += months;
num4 += CCMath.div_mod(out num3, num3, 12);
num = this.fixed_from_dmy(num2, num3, num4);
DateTime dateTime = CCFixed.ToDateTime(num).Add(time.TimeOfDay);
this.M_CheckDateTime(dateTime);
return dateTime;
}
/// <summary>Returns a <see cref="T:System.DateTime" /> that is offset the specified number of years from the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>The <see cref="T:System.DateTime" /> that results from adding the specified number of years to the specified <see cref="T:System.DateTime" /> object.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to which to add years. </param>
/// <param name="years">The positive or negative number of years to add. </param>
/// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="years" /> is less than -10,000 or greater than 10,000. </exception>
// Token: 0x06001474 RID: 5236 RVA: 0x0004F180 File Offset: 0x0004D380
public override DateTime AddYears(DateTime time, int years)
{
int num = CCFixed.FromDateTime(time);
int num2;
int num3;
int num4;
this.dmy_from_fixed(out num2, out num3, out num4, num);
num4 += years;
num = this.fixed_from_dmy(num2, num3, num4);
DateTime dateTime = CCFixed.ToDateTime(num).Add(time.TimeOfDay);
this.M_CheckDateTime(dateTime);
return dateTime;
}
/// <summary>Returns the day of the month in the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>An integer from 1 through 31 that represents the day of the month in the specified <see cref="T:System.DateTime" /> object.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="time" /> parameter represents a date less than <see cref="P:System.Globalization.PersianCalendar.MinSupportedDateTime" /> or greater than <see cref="P:System.Globalization.PersianCalendar.MaxSupportedDateTime" />.</exception>
// Token: 0x06001475 RID: 5237 RVA: 0x0004F1D4 File Offset: 0x0004D3D4
public override int GetDayOfMonth(DateTime time)
{
this.M_CheckDateTime(time);
int num = CCFixed.FromDateTime(time);
int num2;
int num3;
int num4;
this.dmy_from_fixed(out num2, out num3, out num4, num);
return num2;
}
/// <summary>Returns the day of the week in the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>A <see cref="T:System.DayOfWeek" /> value that represents the day of the week in the specified <see cref="T:System.DateTime" /> object.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
// Token: 0x06001476 RID: 5238 RVA: 0x0004F200 File Offset: 0x0004D400
public override DayOfWeek GetDayOfWeek(DateTime time)
{
this.M_CheckDateTime(time);
int num = CCFixed.FromDateTime(time);
return CCFixed.day_of_week(num);
}
/// <summary>Returns the day of the year in the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>An integer from 1 through 366 that represents the day of the year in the specified <see cref="T:System.DateTime" /> object.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="time" /> parameter represents a date less than <see cref="P:System.Globalization.PersianCalendar.MinSupportedDateTime" /> or greater than <see cref="P:System.Globalization.PersianCalendar.MaxSupportedDateTime" />.</exception>
// Token: 0x06001477 RID: 5239 RVA: 0x0004F224 File Offset: 0x0004D424
public override int GetDayOfYear(DateTime time)
{
this.M_CheckDateTime(time);
int num = CCFixed.FromDateTime(time);
int num2 = this.year_from_fixed(num);
int num3 = this.fixed_from_dmy(1, 1, num2);
return num - num3 + 1;
}
/// <summary>Returns the number of days in the specified month of the specified year and era.</summary>
/// <returns>The number of days in the specified month of the specified year and era.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="month">An integer that represents the month, and ranges from 1 through 12 if <paramref name="year" /> is not 9378, or 1 through 10 if <paramref name="year" /> is 9378.</param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" />, <paramref name="month" />, or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x06001478 RID: 5240 RVA: 0x0004F258 File Offset: 0x0004D458
public override int GetDaysInMonth(int year, int month, int era)
{
this.M_CheckYME(year, month, ref era);
if (month <= 6)
{
return 31;
}
if (month == 12 && !this.is_leap_year(year))
{
return 29;
}
return 30;
}
/// <summary>Returns the number of days in the specified year of the specified era.</summary>
/// <returns>The number of days in the specified year and era. The number of days is 365 in a common year or 366 in a leap year.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" /> or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x06001479 RID: 5241 RVA: 0x0004F288 File Offset: 0x0004D488
public override int GetDaysInYear(int year, int era)
{
this.M_CheckYE(year, ref era);
return (!this.is_leap_year(year)) ? 365 : 366;
}
/// <summary>Returns the era in the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>Always returns <see cref="F:System.Globalization.PersianCalendar.PersianEra" />.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="time" /> parameter represents a date less than <see cref="P:System.Globalization.PersianCalendar.MinSupportedDateTime" /> or greater than <see cref="P:System.Globalization.PersianCalendar.MaxSupportedDateTime" />.</exception>
// Token: 0x0600147A RID: 5242 RVA: 0x0004F2BC File Offset: 0x0004D4BC
public override int GetEra(DateTime time)
{
this.M_CheckDateTime(time);
return PersianCalendar.PersianEra;
}
/// <summary>Returns the leap month for a specified year and era.</summary>
/// <returns>The return value is always 0.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year to convert. </param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" /> or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x0600147B RID: 5243 RVA: 0x0004F2CC File Offset: 0x0004D4CC
public override int GetLeapMonth(int year, int era)
{
return 0;
}
/// <summary>Returns the month in the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>An integer from 1 through 12 that represents the month in the specified <see cref="T:System.DateTime" /> object.</returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="time" /> parameter represents a date less than <see cref="P:System.Globalization.PersianCalendar.MinSupportedDateTime" /> or greater than <see cref="P:System.Globalization.PersianCalendar.MaxSupportedDateTime" />.</exception>
// Token: 0x0600147C RID: 5244 RVA: 0x0004F2D0 File Offset: 0x0004D4D0
public override int GetMonth(DateTime time)
{
this.M_CheckDateTime(time);
int num = CCFixed.FromDateTime(time);
int num2;
int num3;
this.my_from_fixed(out num2, out num3, num);
return num2;
}
/// <summary>Returns the number of months in the specified year of the specified era.</summary>
/// <returns>Returns 10 if the <paramref name="year" /> parameter is 9378; otherwise, always returns 12.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" /> or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x0600147D RID: 5245 RVA: 0x0004F2F8 File Offset: 0x0004D4F8
public override int GetMonthsInYear(int year, int era)
{
this.M_CheckYE(year, ref era);
return 12;
}
/// <summary>Returns the year in the specified <see cref="T:System.DateTime" /> object.</summary>
/// <returns>An integer from 1 through 9378 that represents the year in the specified <see cref="T:System.DateTime" />. </returns>
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="time" /> parameter represents a date less than <see cref="P:System.Globalization.PersianCalendar.MinSupportedDateTime" /> or greater than <see cref="P:System.Globalization.PersianCalendar.MaxSupportedDateTime" />.</exception>
// Token: 0x0600147E RID: 5246 RVA: 0x0004F308 File Offset: 0x0004D508
public override int GetYear(DateTime time)
{
this.M_CheckDateTime(time);
int num = CCFixed.FromDateTime(time);
return this.year_from_fixed(num);
}
/// <summary>Determines whether the specified date is a leap day.</summary>
/// <returns>true if the specified day is a leap day; otherwise, false.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="month">An integer that represents the month and ranges from 1 through 12 if <paramref name="year" /> is not 9378, or 1 through 10 if <paramref name="year" /> is 9378.</param>
/// <param name="day">An integer from 1 through 31 that represents the day. </param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" />, <paramref name="month" />, <paramref name="day" />, or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x0600147F RID: 5247 RVA: 0x0004F32C File Offset: 0x0004D52C
public override bool IsLeapDay(int year, int month, int day, int era)
{
this.M_CheckYMDE(year, month, day, ref era);
return this.is_leap_year(year) && month == 12 && day == 30;
}
/// <summary>Determines whether the specified month in the specified year and era is a leap month.</summary>
/// <returns>Always returns false because the <see cref="T:System.Globalization.PersianCalendar" /> class does not support the notion of a leap month.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="month">An integer that represents the month and ranges from 1 through 12 if <paramref name="year" /> is not 9378, or 1 through 10 if <paramref name="year" /> is 9378.</param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" />, <paramref name="month" />, or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x06001480 RID: 5248 RVA: 0x0004F358 File Offset: 0x0004D558
public override bool IsLeapMonth(int year, int month, int era)
{
this.M_CheckYME(year, month, ref era);
return false;
}
/// <summary>Determines whether the specified year in the specified era is a leap year.</summary>
/// <returns>true if the specified year is a leap year; otherwise, false.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" /> or <paramref name="era" /> is outside the range supported by this calendar. </exception>
// Token: 0x06001481 RID: 5249 RVA: 0x0004F368 File Offset: 0x0004D568
public override bool IsLeapYear(int year, int era)
{
this.M_CheckYE(year, ref era);
return this.is_leap_year(year);
}
/// <summary>Returns a <see cref="T:System.DateTime" /> that is set to the specified date, time, and era.</summary>
/// <returns>A <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year. </param>
/// <param name="month">An integer from 1 through 12 that represents the month. </param>
/// <param name="day">An integer from 1 through 31 that represents the day. </param>
/// <param name="hour">An integer from 0 through 23 that represents the hour. </param>
/// <param name="minute">An integer from 0 through 59 that represents the minute. </param>
/// <param name="second">An integer from 0 through 59 that represents the second. </param>
/// <param name="millisecond">An integer from 0 through 999 that represents the millisecond. </param>
/// <param name="era">An integer from 0 through 1 that represents the era. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" />, <paramref name="month" />, <paramref name="day" />, <paramref name="hour" />, <paramref name="minute" />, <paramref name="second" />, <paramref name="millisecond" />, or <paramref name="era" /> is outside the range supported by this calendar.</exception>
// Token: 0x06001482 RID: 5250 RVA: 0x0004F37C File Offset: 0x0004D57C
public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
{
this.M_CheckYMDE(year, month, day, ref era);
base.M_CheckHMSM(hour, minute, second, millisecond);
int num = this.fixed_from_dmy(day, month, year);
return CCFixed.ToDateTime(num, hour, minute, second, (double)millisecond);
}
/// <summary>Converts the specified year to a four-digit year representation.</summary>
/// <returns>An integer that contains the four-digit representation of <paramref name="year" />.</returns>
/// <param name="year">An integer from 1 through 9378 that represents the year to convert. </param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="year" /> is less than 0 or greater than 9378. </exception>
// Token: 0x06001483 RID: 5251 RVA: 0x0004F3BC File Offset: 0x0004D5BC
public override int ToFourDigitYear(int year)
{
base.M_ArgumentInRange("year", year, 0, 99);
int num = this.twoDigitYearMax % 100;
int num2 = this.twoDigitYearMax - num;
if (year <= num)
{
return num2 + year;
}
return num2 + year - 100;
}
/// <summary>Gets a value indicating whether the current calendar is solar-based, lunar-based, or lunisolar-based.</summary>
/// <returns>Always returns <see cref="F:System.Globalization.CalendarAlgorithmType.SolarCalendar" />.</returns>
// Token: 0x17000395 RID: 917
// (get) Token: 0x06001484 RID: 5252 RVA: 0x0004F3FC File Offset: 0x0004D5FC
public override CalendarAlgorithmType AlgorithmType
{
get
{
return CalendarAlgorithmType.SolarCalendar;
}
}
/// <summary>Gets the earliest date and time supported by the <see cref="T:System.Globalization.PersianCalendar" /> class.</summary>
/// <returns>The earliest date and time supported by the <see cref="T:System.Globalization.PersianCalendar" /> class, which is equivalent to the first moment of March 21, 622 C.E. in the Gregorian calendar.</returns>
// Token: 0x17000396 RID: 918
// (get) Token: 0x06001485 RID: 5253 RVA: 0x0004F400 File Offset: 0x0004D600
public override DateTime MinSupportedDateTime
{
get
{
return PersianCalendar.PersianMin;
}
}
/// <summary>Gets the latest date and time supported by the <see cref="T:System.Globalization.PersianCalendar" /> class.</summary>
/// <returns>The latest date and time supported by the <see cref="T:System.Globalization.PersianCalendar" /> class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar.</returns>
// Token: 0x17000397 RID: 919
// (get) Token: 0x06001486 RID: 5254 RVA: 0x0004F408 File Offset: 0x0004D608
public override DateTime MaxSupportedDateTime
{
get
{
return PersianCalendar.PersianMax;
}
}
// Token: 0x040005C7 RID: 1479
internal const long M_MinTicks = 196036416000000000L;
// Token: 0x040005C8 RID: 1480
internal const int M_MinYear = 1;
// Token: 0x040005C9 RID: 1481
internal const int epoch = 226895;
/// <summary>Represents the current era. This field is constant.</summary>
// Token: 0x040005CA RID: 1482
public static readonly int PersianEra = 1;
// Token: 0x040005CB RID: 1483
private static DateTime PersianMin = new DateTime(622, 3, 21, 0, 0, 0);
// Token: 0x040005CC RID: 1484
private static DateTime PersianMax = new DateTime(9999, 12, 31, 11, 59, 59);
}
}