376 lines
19 KiB
C#
376 lines
19 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace System.Globalization
|
|
{
|
|
/// <summary>Represents the Julian calendar.</summary>
|
|
// Token: 0x0200018F RID: 399
|
|
[MonoTODO("Serialization format not compatible with .NET")]
|
|
[ComVisible(true)]
|
|
[Serializable]
|
|
public class JulianCalendar : Calendar
|
|
{
|
|
/// <summary>Initializes a new instance of the <see cref="T:System.Globalization.JulianCalendar" /> class.</summary>
|
|
// Token: 0x060013DF RID: 5087 RVA: 0x0004D30C File Offset: 0x0004B50C
|
|
public JulianCalendar()
|
|
{
|
|
this.M_AbbrEraNames = new string[] { "C.E." };
|
|
this.M_EraNames = new string[] { "Common Era" };
|
|
if (this.twoDigitYearMax == 99)
|
|
{
|
|
this.twoDigitYearMax = 2029;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the list of eras in the <see cref="T:System.Globalization.JulianCalendar" />.</summary>
|
|
/// <returns>An array of integers that represents the eras in the <see cref="T:System.Globalization.JulianCalendar" />.</returns>
|
|
// Token: 0x17000368 RID: 872
|
|
// (get) Token: 0x060013E1 RID: 5089 RVA: 0x0004D394 File Offset: 0x0004B594
|
|
public override int[] Eras
|
|
{
|
|
get
|
|
{
|
|
return new int[] { JulianCalendar.JulianEra };
|
|
}
|
|
}
|
|
|
|
/// <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>
|
|
// Token: 0x17000369 RID: 873
|
|
// (get) Token: 0x060013E2 RID: 5090 RVA: 0x0004D3A4 File Offset: 0x0004B5A4
|
|
// (set) Token: 0x060013E3 RID: 5091 RVA: 0x0004D3AC File Offset: 0x0004B5AC
|
|
public override int TwoDigitYearMax
|
|
{
|
|
get
|
|
{
|
|
return this.twoDigitYearMax;
|
|
}
|
|
set
|
|
{
|
|
base.CheckReadOnly();
|
|
base.M_ArgumentInRange("value", value, 100, this.M_MaxYear);
|
|
this.twoDigitYearMax = value;
|
|
}
|
|
}
|
|
|
|
// Token: 0x060013E4 RID: 5092 RVA: 0x0004D3DC File Offset: 0x0004B5DC
|
|
internal void M_CheckEra(ref int era)
|
|
{
|
|
if (era == 0)
|
|
{
|
|
era = JulianCalendar.JulianEra;
|
|
}
|
|
if (era != JulianCalendar.JulianEra)
|
|
{
|
|
throw new ArgumentException("Era value was not valid.");
|
|
}
|
|
}
|
|
|
|
// Token: 0x060013E5 RID: 5093 RVA: 0x0004D404 File Offset: 0x0004B604
|
|
internal override void M_CheckYE(int year, ref int era)
|
|
{
|
|
this.M_CheckEra(ref era);
|
|
base.M_ArgumentInRange("year", year, 1, 9999);
|
|
}
|
|
|
|
// Token: 0x060013E6 RID: 5094 RVA: 0x0004D42C File Offset: 0x0004B62C
|
|
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.");
|
|
}
|
|
}
|
|
|
|
// Token: 0x060013E7 RID: 5095 RVA: 0x0004D458 File Offset: 0x0004B658
|
|
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 == 9999 && ((month == 10 && day > 19) || month > 10))
|
|
{
|
|
throw new ArgumentOutOfRangeException("The maximum Julian date is 19. 10. 9999.");
|
|
}
|
|
}
|
|
|
|
/// <summary>Returns a <see cref="T:System.DateTime" /> that is the specified number of months away from the specified <see cref="T:System.DateTime" />.</summary>
|
|
/// <returns>The <see cref="T:System.DateTime" /> that results from adding the specified number of months to the specified <see cref="T:System.DateTime" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to which to add months. </param>
|
|
/// <param name="months">The 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 -120000.-or- <paramref name="months" /> is greater than 120000. </exception>
|
|
// Token: 0x060013E8 RID: 5096 RVA: 0x0004D4B8 File Offset: 0x0004B6B8
|
|
public override DateTime AddMonths(DateTime time, int months)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
int num2;
|
|
int num3;
|
|
int num4;
|
|
CCJulianCalendar.dmy_from_fixed(out num2, out num3, out num4, num);
|
|
num3 += months;
|
|
num4 += CCMath.div_mod(out num3, num3, 12);
|
|
num = CCJulianCalendar.fixed_from_dmy(num2, num3, num4);
|
|
return CCFixed.ToDateTime(num).Add(time.TimeOfDay);
|
|
}
|
|
|
|
/// <summary>Returns a <see cref="T:System.DateTime" /> that is the specified number of years away from the specified <see cref="T:System.DateTime" />.</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" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to which to add years. </param>
|
|
/// <param name="years">The number of years to add. </param>
|
|
/// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception>
|
|
// Token: 0x060013E9 RID: 5097 RVA: 0x0004D508 File Offset: 0x0004B708
|
|
public override DateTime AddYears(DateTime time, int years)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
int num2;
|
|
int num3;
|
|
int num4;
|
|
CCJulianCalendar.dmy_from_fixed(out num2, out num3, out num4, num);
|
|
num4 += years;
|
|
num = CCJulianCalendar.fixed_from_dmy(num2, num3, num4);
|
|
return CCFixed.ToDateTime(num).Add(time.TimeOfDay);
|
|
}
|
|
|
|
/// <summary>Returns the day of the month in the specified <see cref="T:System.DateTime" />.</summary>
|
|
/// <returns>An integer from 1 to 31 that represents the day of the month in <paramref name="time" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
|
|
// Token: 0x060013EA RID: 5098 RVA: 0x0004D54C File Offset: 0x0004B74C
|
|
public override int GetDayOfMonth(DateTime time)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
return CCJulianCalendar.day_from_fixed(num);
|
|
}
|
|
|
|
/// <summary>Returns the day of the week in the specified <see cref="T:System.DateTime" />.</summary>
|
|
/// <returns>A <see cref="T:System.DayOfWeek" /> value that represents the day of the week in <paramref name="time" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
|
|
// Token: 0x060013EB RID: 5099 RVA: 0x0004D568 File Offset: 0x0004B768
|
|
public override DayOfWeek GetDayOfWeek(DateTime 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" />.</summary>
|
|
/// <returns>An integer from 1 to 366 that represents the day of the year in <paramref name="time" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
|
|
// Token: 0x060013EC RID: 5100 RVA: 0x0004D584 File Offset: 0x0004B784
|
|
public override int GetDayOfYear(DateTime time)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
int num2 = CCJulianCalendar.year_from_fixed(num);
|
|
int num3 = CCJulianCalendar.fixed_from_dmy(1, 1, num2);
|
|
return num - num3 + 1;
|
|
}
|
|
|
|
/// <summary>Returns the number of days in the specified month in the specified year in the specified era.</summary>
|
|
/// <returns>The number of days in the specified month in the specified year in the specified era.</returns>
|
|
/// <param name="year">An integer that represents the year. </param>
|
|
/// <param name="month">An integer from 1 to 12 that represents the month. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="era" /> is outside the range supported by the calendar. -or- <paramref name="year" /> is outside the range supported by the calendar.-or- <paramref name="month" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013ED RID: 5101 RVA: 0x0004D5B0 File Offset: 0x0004B7B0
|
|
public override int GetDaysInMonth(int year, int month, int era)
|
|
{
|
|
this.M_CheckYME(year, month, ref era);
|
|
int num = CCJulianCalendar.fixed_from_dmy(1, month, year);
|
|
int num2 = CCJulianCalendar.fixed_from_dmy(1, month + 1, year);
|
|
return num2 - num;
|
|
}
|
|
|
|
/// <summary>Returns the number of days in the specified year in the specified era.</summary>
|
|
/// <returns>The number of days in the specified year in the specified era.</returns>
|
|
/// <param name="year">An integer that represents the year. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="era" /> is outside the range supported by the calendar. -or- <paramref name="year" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013EE RID: 5102 RVA: 0x0004D5E0 File Offset: 0x0004B7E0
|
|
public override int GetDaysInYear(int year, int era)
|
|
{
|
|
this.M_CheckYE(year, ref era);
|
|
int num = CCJulianCalendar.fixed_from_dmy(1, 1, year);
|
|
int num2 = CCJulianCalendar.fixed_from_dmy(1, 1, year + 1);
|
|
return num2 - num;
|
|
}
|
|
|
|
/// <summary>Returns the era in the specified <see cref="T:System.DateTime" />.</summary>
|
|
/// <returns>An integer that represents the era in <paramref name="time" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
|
|
// Token: 0x060013EF RID: 5103 RVA: 0x0004D610 File Offset: 0x0004B810
|
|
public override int GetEra(DateTime time)
|
|
{
|
|
return JulianCalendar.JulianEra;
|
|
}
|
|
|
|
/// <summary>Calculates the leap month for a specified year and era.</summary>
|
|
/// <returns>A positive integer that indicates the leap month in the specified year and era. Alternatively, this method returns zero if the calendar does not support a leap month, or if <paramref name="year" /> and <paramref name="era" /> do not specify a leap year.</returns>
|
|
/// <param name="year">An integer that represents the year.</param>
|
|
/// <param name="era">An integer that represents the era.</param>
|
|
// Token: 0x060013F0 RID: 5104 RVA: 0x0004D618 File Offset: 0x0004B818
|
|
[ComVisible(false)]
|
|
public override int GetLeapMonth(int year, int era)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>Returns the month in the specified <see cref="T:System.DateTime" />.</summary>
|
|
/// <returns>An integer from 1 to 12 that represents the month in <paramref name="time" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
|
|
// Token: 0x060013F1 RID: 5105 RVA: 0x0004D61C File Offset: 0x0004B81C
|
|
public override int GetMonth(DateTime time)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
return CCJulianCalendar.month_from_fixed(num);
|
|
}
|
|
|
|
/// <summary>Returns the number of months in the specified year in the specified era.</summary>
|
|
/// <returns>The number of months in the specified year in the specified era.</returns>
|
|
/// <param name="year">An integer that represents the year. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="era" /> is outside the range supported by the calendar. -or- <paramref name="year" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013F2 RID: 5106 RVA: 0x0004D638 File Offset: 0x0004B838
|
|
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" />.</summary>
|
|
/// <returns>An integer that represents the year in <paramref name="time" />.</returns>
|
|
/// <param name="time">The <see cref="T:System.DateTime" /> to read. </param>
|
|
// Token: 0x060013F3 RID: 5107 RVA: 0x0004D648 File Offset: 0x0004B848
|
|
public override int GetYear(DateTime time)
|
|
{
|
|
int num = CCFixed.FromDateTime(time);
|
|
return CCJulianCalendar.year_from_fixed(num);
|
|
}
|
|
|
|
/// <summary>Determines whether the specified date in the specified era is a leap day.</summary>
|
|
/// <returns>true if the specified day is a leap day; otherwise, false.</returns>
|
|
/// <param name="year">An integer that represents the year. </param>
|
|
/// <param name="month">An integer from 1 to 12 that represents the month. </param>
|
|
/// <param name="day">An integer from 1 to 31 that represents the day. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="year" /> is outside the range supported by the calendar.-or- <paramref name="month" /> is outside the range supported by the calendar.-or- <paramref name="day" /> is outside the range supported by the calendar. -or- <paramref name="era" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013F4 RID: 5108 RVA: 0x0004D664 File Offset: 0x0004B864
|
|
public override bool IsLeapDay(int year, int month, int day, int era)
|
|
{
|
|
this.M_CheckYMDE(year, month, day, ref era);
|
|
return this.IsLeapYear(year) && month == 2 && day == 29;
|
|
}
|
|
|
|
/// <summary>Determines whether the specified month in the specified year in the specified era is a leap month.</summary>
|
|
/// <returns>This method always returns false, unless overridden by a derived class.</returns>
|
|
/// <param name="year">An integer that represents the year. </param>
|
|
/// <param name="month">An integer from 1 to 12 that represents the month. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="year" /> is outside the range supported by the calendar.-or- <paramref name="month" /> is outside the range supported by the calendar. -or- <paramref name="era" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013F5 RID: 5109 RVA: 0x0004D698 File Offset: 0x0004B898
|
|
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 that represents the year. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="year" /> is outside the range supported by the calendar. -or- <paramref name="era" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013F6 RID: 5110 RVA: 0x0004D6A8 File Offset: 0x0004B8A8
|
|
public override bool IsLeapYear(int year, int era)
|
|
{
|
|
this.M_CheckYE(year, ref era);
|
|
return CCJulianCalendar.is_leap_year(year);
|
|
}
|
|
|
|
/// <summary>Returns a <see cref="T:System.DateTime" /> that is set to the specified date and time in the specified era.</summary>
|
|
/// <returns>The <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</returns>
|
|
/// <param name="year">An integer that represents the year. </param>
|
|
/// <param name="month">An integer from 1 to 12 that represents the month. </param>
|
|
/// <param name="day">An integer from 1 to 31 that represents the day. </param>
|
|
/// <param name="hour">An integer from 0 to 23 that represents the hour. </param>
|
|
/// <param name="minute">An integer from 0 to 59 that represents the minute. </param>
|
|
/// <param name="second">An integer from 0 to 59 that represents the second. </param>
|
|
/// <param name="millisecond">An integer from 0 to 999 that represents the millisecond. </param>
|
|
/// <param name="era">An integer that represents the era. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="year" /> is outside the range supported by the calendar.-or- <paramref name="month" /> is outside the range supported by the calendar.-or- <paramref name="day" /> is outside the range supported by the calendar.-or- <paramref name="hour" /> is less than zero or greater than 23.-or- <paramref name="minute" /> is less than zero or greater than 59.-or- <paramref name="second" /> is less than zero or greater than 59.-or- <paramref name="millisecond" /> is less than zero or greater than 999. -or- <paramref name="era" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013F7 RID: 5111 RVA: 0x0004D6BC File Offset: 0x0004B8BC
|
|
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 = CCJulianCalendar.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 by using the <see cref="P:System.Globalization.JulianCalendar.TwoDigitYearMax" /> property to determine the appropriate century.</summary>
|
|
/// <returns>An integer that contains the four-digit representation of <paramref name="year" />.</returns>
|
|
/// <param name="year">A two-digit or four-digit integer that represents the year to convert. </param>
|
|
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
|
/// <paramref name="year" /> is outside the range supported by the calendar. </exception>
|
|
// Token: 0x060013F8 RID: 5112 RVA: 0x0004D6FC File Offset: 0x0004B8FC
|
|
public override int ToFourDigitYear(int year)
|
|
{
|
|
return base.ToFourDigitYear(year);
|
|
}
|
|
|
|
/// <summary>Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both.</summary>
|
|
/// <returns>Always returns the <see cref="F:System.Globalization.CalendarAlgorithmType.SolarCalendar" /> type.</returns>
|
|
// Token: 0x1700036A RID: 874
|
|
// (get) Token: 0x060013F9 RID: 5113 RVA: 0x0004D708 File Offset: 0x0004B908
|
|
[ComVisible(false)]
|
|
public override CalendarAlgorithmType AlgorithmType
|
|
{
|
|
get
|
|
{
|
|
return CalendarAlgorithmType.SolarCalendar;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the earliest date and time supported by the <see cref="T:System.Globalization.JulianCalendar" /> class.</summary>
|
|
/// <returns>The earliest date and time supported by the <see cref="T:System.Globalization.JulianCalendar" /> class, which is equivalent to the first moment of January 1, 0001 C.E. in the Gregorian calendar.</returns>
|
|
// Token: 0x1700036B RID: 875
|
|
// (get) Token: 0x060013FA RID: 5114 RVA: 0x0004D70C File Offset: 0x0004B90C
|
|
[ComVisible(false)]
|
|
public override DateTime MinSupportedDateTime
|
|
{
|
|
get
|
|
{
|
|
return JulianCalendar.JulianMin;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the latest date and time supported by the <see cref="T:System.Globalization.JulianCalendar" /> class.</summary>
|
|
/// <returns>The latest date and time supported by the <see cref="T:System.Globalization.JulianCalendar" /> class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar.</returns>
|
|
// Token: 0x1700036C RID: 876
|
|
// (get) Token: 0x060013FB RID: 5115 RVA: 0x0004D714 File Offset: 0x0004B914
|
|
[ComVisible(false)]
|
|
public override DateTime MaxSupportedDateTime
|
|
{
|
|
get
|
|
{
|
|
return JulianCalendar.JulianMax;
|
|
}
|
|
}
|
|
|
|
/// <summary>Represents the current era. This field is constant.</summary>
|
|
// Token: 0x04000583 RID: 1411
|
|
public static readonly int JulianEra = 1;
|
|
|
|
// Token: 0x04000584 RID: 1412
|
|
private static DateTime JulianMin = new DateTime(1, 1, 1, 0, 0, 0);
|
|
|
|
// Token: 0x04000585 RID: 1413
|
|
private static DateTime JulianMax = new DateTime(9999, 12, 31, 11, 59, 59);
|
|
}
|
|
}
|