13 private const int DatePartYear = 0;
15 private const int DatePartDayOfYear = 1;
17 private const int DatePartMonth = 2;
19 private const int DatePartDay = 3;
21 private const int JulianDaysPerYear = 365;
23 private const int JulianDaysPer4Years = 1461;
25 private static readonly
int[] DaysToMonth365 =
new int[13]
42 private static readonly
int[] DaysToMonth366 =
new int[13]
59 internal int MaxYear = 9999;
94 internal override int ID => 13;
98 public override int[]
Eras =>
new int[1]
111 return twoDigitYearMax;
116 if (value < 99 || value > MaxYear)
120 twoDigitYearMax = value;
127 twoDigitYearMax = 2029;
130 internal static void CheckEraRange(
int era)
138 internal void CheckYearEraRange(
int year,
int era)
141 if (year <= 0 || year > MaxYear)
143 throw new ArgumentOutOfRangeException(
"year",
string.
Format(CultureInfo.CurrentCulture, Environment.GetResourceString(
"ArgumentOutOfRange_Range"), 1, MaxYear));
147 internal static void CheckMonthRange(
int month)
149 if (month < 1 || month > 12)
151 throw new ArgumentOutOfRangeException(
"month", Environment.GetResourceString(
"ArgumentOutOfRange_Month"));
155 internal static void CheckDayRange(
int year,
int month,
int day)
157 if (year == 1 && month == 1 && day < 3)
159 throw new ArgumentOutOfRangeException(
null, Environment.GetResourceString(
"ArgumentOutOfRange_BadYearMonthDay"));
161 int[] array = (year % 4 == 0) ? DaysToMonth366 : DaysToMonth365;
162 int num = array[month] - array[month - 1];
163 if (day < 1 || day > num)
165 throw new ArgumentOutOfRangeException(
"day",
string.
Format(CultureInfo.CurrentCulture, Environment.GetResourceString(
"ArgumentOutOfRange_Range"), 1, num));
169 internal static int GetDatePart(
long ticks,
int part)
171 long num = ticks + 1728000000000
L;
172 int num2 = (int)(num / 864000000000L);
173 int num3 = num2 / 1461;
175 int num4 = num2 / 365;
182 return num3 * 4 + num4 + 1;
189 int[] array = (num4 == 3) ? DaysToMonth366 : DaysToMonth365;
191 for (i = num2 >> 6; num2 >= array[i]; i++)
198 return num2 - array[i - 1] + 1;
201 internal static long DateToTicks(
int year,
int month,
int day)
203 int[] array = (year % 4 == 0) ? DaysToMonth366 : DaysToMonth365;
205 int num2 = num * 365 + num / 4 + array[month - 1] + day - 1;
206 return (num2 - 2) * 864000000000
L;
219 if (months < -120000 || months > 120000)
223 int datePart = GetDatePart(time.
Ticks, 0);
224 int datePart2 = GetDatePart(time.
Ticks, 2);
225 int num = GetDatePart(time.
Ticks, 3);
226 int num2 = datePart2 - 1 + months;
229 datePart2 = num2 % 12 + 1;
230 datePart += num2 / 12;
234 datePart2 = 12 + (num2 + 1) % 12;
235 datePart += (num2 - 11) / 12;
237 int[] array = (datePart % 4 == 0 && (datePart % 100 != 0 || datePart % 400 == 0)) ? DaysToMonth366 : DaysToMonth365;
238 int num3 = array[datePart2] - array[datePart2 - 1];
243 long ticks = DateToTicks(datePart, datePart2, num) + time.
Ticks % 864000000000
L;
263 return GetDatePart(time.
Ticks, 3);
279 return GetDatePart(time.
Ticks, 1);
293 CheckYearEraRange(year, era);
294 CheckMonthRange(month);
295 int[] array = (year % 4 == 0) ? DaysToMonth366 : DaysToMonth365;
296 return array[month] - array[month - 1];
328 return GetDatePart(time.
Ticks, 2);
340 CheckYearEraRange(year, era);
349 return GetDatePart(time.
Ticks, 0);
364 public override bool IsLeapDay(
int year,
int month,
int day,
int era)
366 CheckMonthRange(month);
369 CheckDayRange(year, month, day);
376 CheckDayRange(year, month, day);
387 CheckYearEraRange(year, era);
402 CheckYearEraRange(year, era);
403 CheckMonthRange(month);
417 CheckYearEraRange(year, era);
418 return year % 4 == 0;
440 public override DateTime ToDateTime(
int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond,
int era)
442 CheckYearEraRange(year, era);
443 CheckMonthRange(month);
444 CheckDayRange(year, month, day);
445 if (millisecond < 0 || millisecond >= 1000)
449 if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60 && second >= 0 && second < 60)
451 return new DateTime(DateToTicks(year, month, day) +
new TimeSpan(0, hour, minute, second, millisecond).Ticks);
471 return base.ToFourDigitYear(year);
override int GetDaysInYear(int year, int era)
Returns the number of days in the specified year in the specified era.
override int GetDayOfMonth(DateTime time)
Returns the day of the month in the specified T:System.DateTime.
override int GetDayOfYear(DateTime time)
Returns the day of the year in the specified T:System.DateTime.
Represents time in divisions, such as weeks, months, and years.
override bool IsLeapMonth(int year, int month, int era)
Determines whether the specified month in the specified year in the specified era is a leap month.
override bool IsLeapDay(int year, int month, int day, int era)
Determines whether the specified date in the specified era is a leap day.
override DateTime MinSupportedDateTime
Gets the earliest date and time supported by the T:System.Globalization.JulianCalendar class.
static readonly DateTime MinValue
Represents the smallest possible value of T:System.DateTime. This field is read-only.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
override int [] Eras
Gets the list of eras in the T:System.Globalization.JulianCalendar.
override DateTime AddYears(DateTime time, int years)
Returns a T:System.DateTime that is the specified number of years away from the specified T:System....
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
override bool IsLeapYear(int year, int era)
Determines whether the specified year in the specified era is a leap year.
override DateTime AddMonths(DateTime time, int months)
Returns a T:System.DateTime that is the specified number of months away from the specified T:System....
override int ToFourDigitYear(int year)
Converts the specified year to a four-digit year by using the P:System.Globalization....
Provides information about, and means to manipulate, the current environment and platform....
override DayOfWeek GetDayOfWeek(DateTime time)
Returns the day of the week in the specified T:System.DateTime.
static readonly DateTime MaxValue
Represents the largest possible value of T:System.DateTime. This field is read-only.
override int GetLeapMonth(int year, int era)
Calculates the leap month for a specified year and era.
override int GetMonthsInYear(int year, int era)
Returns the number of months in the specified year in the specified era.
Format character that affects the layout of text or the operation of text processes,...
override int GetEra(DateTime time)
Returns the era in the specified T:System.DateTime.
override int TwoDigitYearMax
Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.
override int GetYear(DateTime time)
Returns the year in the specified T:System.DateTime.
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
static readonly int JulianEra
Represents the current era. This field is constant.
Represents the Julian calendar.
CalendarAlgorithmType
Specifies whether a calendar is solar-based, lunar-based, or lunisolar-based.
override CalendarAlgorithmType AlgorithmType
Gets a value that indicates whether the current calendar is solar-based, lunar-based,...
Represents a time interval.To browse the .NET Framework source code for this type,...
Specifies that the class can be serialized.
override int GetMonth(DateTime time)
Returns the month in the specified T:System.DateTime.
JulianCalendar()
Initializes a new instance of the T:System.Globalization.JulianCalendar class.
Provides information about a specific culture (called a locale for unmanaged code development)....
override DateTime MaxSupportedDateTime
Gets the latest date and time supported by the T:System.Globalization.JulianCalendar class.
DayOfWeek
Specifies the day of the week.
long Ticks
Gets the number of ticks that represent the date and time of this instance.
override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
Returns a T:System.DateTime that is set to the specified date and time in the specified era.
override int GetDaysInMonth(int year, int month, int era)
Returns the number of days in the specified month in the specified year in the specified era.