Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddMonths()

override DateTime System.Globalization.EastAsianLunisolarCalendar.AddMonths ( DateTime time,
int months )
inlineinherited

Definition at line 326 of file EastAsianLunisolarCalendar.cs.

327 {
328 if (months < -120000 || months > 120000)
329 {
330 throw new ArgumentOutOfRangeException("months", months, SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
331 }
332 CheckTicksRange(time.Ticks);
333 TimeToLunar(time, out var year, out var month, out var day);
334 int num = month + months;
335 if (num > 0)
336 {
337 int num2 = (InternalIsLeapYear(year) ? 13 : 12);
338 while (num - num2 > 0)
339 {
340 num -= num2;
341 year++;
342 num2 = (InternalIsLeapYear(year) ? 13 : 12);
343 }
344 month = num;
345 }
346 else
347 {
348 while (num <= 0)
349 {
350 int num3 = (InternalIsLeapYear(year - 1) ? 13 : 12);
351 num += num3;
352 year--;
353 }
354 month = num;
355 }
356 int num4 = InternalGetDaysInMonth(year, month);
357 if (day > num4)
358 {
359 day = num4;
360 }
361 DateTime result = LunarToTime(time, year, month, day);
362 Calendar.CheckAddResult(result.Ticks, MinSupportedDateTime, MaxSupportedDateTime);
363 return result;
364 }
virtual DateTime MaxSupportedDateTime
Definition Calendar.cs:15
virtual DateTime MinSupportedDateTime
Definition Calendar.cs:13
DateTime LunarToTime(DateTime time, int year, int month, int day)
void TimeToLunar(DateTime time, out int year, out int month, out int day)

References System.SR.ArgumentOutOfRange_Range, System.Globalization.Calendar.CheckAddResult(), System.Globalization.EastAsianLunisolarCalendar.CheckTicksRange(), System.SR.Format(), System.Globalization.EastAsianLunisolarCalendar.InternalGetDaysInMonth(), System.Globalization.EastAsianLunisolarCalendar.InternalIsLeapYear(), System.Globalization.EastAsianLunisolarCalendar.LunarToTime(), System.Globalization.Calendar.MaxSupportedDateTime, System.Globalization.Calendar.MinSupportedDateTime, System.DateTime.Ticks, System.Globalization.EastAsianLunisolarCalendar.TimeToLunar(), and System.year.