using System;
namespace System.Globalization
{
/// Represents the Persian calendar.
// Token: 0x02000194 RID: 404
[Serializable]
public class PersianCalendar : Calendar
{
/// Initializes a new instance of the class.
// 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;
}
}
/// Gets the list of eras in a object.
/// An array of integers that represents the eras in a object. The array consists of a single element having a value of .
// Token: 0x17000393 RID: 915
// (get) Token: 0x06001466 RID: 5222 RVA: 0x0004EE7C File Offset: 0x0004D07C
public override int[] Eras
{
get
{
return new int[] { PersianCalendar.PersianEra };
}
}
/// Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.
/// The last year of a 100-year range that can be represented by a 2-digit year.
/// This calendar is read-only.
/// The value in a set operation is less than 100 or greater than 9378.
// 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;
}
/// Returns a that is offset the specified number of months from the specified .
/// A that represents the date yielded by adding the number of months specified by the parameter to the date specified by the parameter.
/// The to which to add months.
/// The positive or negative number of months to add.
/// The resulting is outside the supported range.
///
/// is less than -120,000 or greater than 120,000.
// 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;
}
/// Returns a that is offset the specified number of years from the specified object.
/// The that results from adding the specified number of years to the specified object.
/// The to which to add years.
/// The positive or negative number of years to add.
/// The resulting is outside the supported range.
///
/// is less than -10,000 or greater than 10,000.
// 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;
}
/// Returns the day of the month in the specified object.
/// An integer from 1 through 31 that represents the day of the month in the specified object.
/// The to read.
/// The parameter represents a date less than or greater than .
// 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;
}
/// Returns the day of the week in the specified object.
/// A value that represents the day of the week in the specified object.
/// The to read.
// 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);
}
/// Returns the day of the year in the specified object.
/// An integer from 1 through 366 that represents the day of the year in the specified object.
/// The to read.
/// The parameter represents a date less than or greater than .
// 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;
}
/// Returns the number of days in the specified month of the specified year and era.
/// The number of days in the specified month of the specified year and era.
/// An integer from 1 through 9378 that represents the year.
/// An integer that represents the month, and ranges from 1 through 12 if is not 9378, or 1 through 10 if is 9378.
/// An integer from 0 through 1 that represents the era.
///
/// , , or is outside the range supported by this calendar.
// 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;
}
/// Returns the number of days in the specified year of the specified era.
/// 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.
/// An integer from 1 through 9378 that represents the year.
/// An integer from 0 through 1 that represents the era.
///
/// or is outside the range supported by this calendar.
// 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;
}
/// Returns the era in the specified object.
/// Always returns .
/// The to read.
/// The parameter represents a date less than or greater than .
// Token: 0x0600147A RID: 5242 RVA: 0x0004F2BC File Offset: 0x0004D4BC
public override int GetEra(DateTime time)
{
this.M_CheckDateTime(time);
return PersianCalendar.PersianEra;
}
/// Returns the leap month for a specified year and era.
/// The return value is always 0.
/// An integer from 1 through 9378 that represents the year to convert.
/// An integer from 0 through 1 that represents the era.
///
/// or is outside the range supported by this calendar.
// Token: 0x0600147B RID: 5243 RVA: 0x0004F2CC File Offset: 0x0004D4CC
public override int GetLeapMonth(int year, int era)
{
return 0;
}
/// Returns the month in the specified object.
/// An integer from 1 through 12 that represents the month in the specified object.
/// The to read.
/// The parameter represents a date less than or greater than .
// 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;
}
/// Returns the number of months in the specified year of the specified era.
/// Returns 10 if the parameter is 9378; otherwise, always returns 12.
/// An integer from 1 through 9378 that represents the year.
/// An integer from 0 through 1 that represents the era.
///
/// or is outside the range supported by this calendar.
// 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;
}
/// Returns the year in the specified object.
/// An integer from 1 through 9378 that represents the year in the specified .
/// The to read.
/// The parameter represents a date less than or greater than .
// 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);
}
/// Determines whether the specified date is a leap day.
/// true if the specified day is a leap day; otherwise, false.
/// An integer from 1 through 9378 that represents the year.
/// An integer that represents the month and ranges from 1 through 12 if is not 9378, or 1 through 10 if is 9378.
/// An integer from 1 through 31 that represents the day.
/// An integer from 0 through 1 that represents the era.
///
/// , , , or is outside the range supported by this calendar.
// 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;
}
/// Determines whether the specified month in the specified year and era is a leap month.
/// Always returns false because the class does not support the notion of a leap month.
/// An integer from 1 through 9378 that represents the year.
/// An integer that represents the month and ranges from 1 through 12 if is not 9378, or 1 through 10 if is 9378.
/// An integer from 0 through 1 that represents the era.
///
/// , , or is outside the range supported by this calendar.
// 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;
}
/// Determines whether the specified year in the specified era is a leap year.
/// true if the specified year is a leap year; otherwise, false.
/// An integer from 1 through 9378 that represents the year.
/// An integer from 0 through 1 that represents the era.
///
/// or is outside the range supported by this calendar.
// 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);
}
/// Returns a that is set to the specified date, time, and era.
/// A that is set to the specified date and time in the current era.
/// An integer from 1 through 9378 that represents the year.
/// An integer from 1 through 12 that represents the month.
/// An integer from 1 through 31 that represents the day.
/// An integer from 0 through 23 that represents the hour.
/// An integer from 0 through 59 that represents the minute.
/// An integer from 0 through 59 that represents the second.
/// An integer from 0 through 999 that represents the millisecond.
/// An integer from 0 through 1 that represents the era.
///
/// , , , , , , , or is outside the range supported by this calendar.
// 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);
}
/// Converts the specified year to a four-digit year representation.
/// An integer that contains the four-digit representation of .
/// An integer from 1 through 9378 that represents the year to convert.
///
/// is less than 0 or greater than 9378.
// 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;
}
/// Gets a value indicating whether the current calendar is solar-based, lunar-based, or lunisolar-based.
/// Always returns .
// Token: 0x17000395 RID: 917
// (get) Token: 0x06001484 RID: 5252 RVA: 0x0004F3FC File Offset: 0x0004D5FC
public override CalendarAlgorithmType AlgorithmType
{
get
{
return CalendarAlgorithmType.SolarCalendar;
}
}
/// Gets the earliest date and time supported by the class.
/// The earliest date and time supported by the class, which is equivalent to the first moment of March 21, 622 C.E. in the Gregorian calendar.
// Token: 0x17000396 RID: 918
// (get) Token: 0x06001485 RID: 5253 RVA: 0x0004F400 File Offset: 0x0004D600
public override DateTime MinSupportedDateTime
{
get
{
return PersianCalendar.PersianMin;
}
}
/// Gets the latest date and time supported by the class.
/// The latest date and time supported by the class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar.
// 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;
/// Represents the current era. This field is constant.
// 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);
}
}