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

◆ LunarToGregorian()

bool System.Globalization.EastAsianLunisolarCalendar.LunarToGregorian ( int lunarYear,
int lunarMonth,
int lunarDate,
out int solarYear,
out int solarMonth,
out int solarDay )
inlineprivateinherited

Definition at line 268 of file EastAsianLunisolarCalendar.cs.

269 {
270 if (lunarDate < 1 || lunarDate > 30)
271 {
272 solarYear = 0;
273 solarMonth = 0;
274 solarDay = 0;
275 return false;
276 }
277 int num = lunarDate - 1;
278 for (int i = 1; i < lunarMonth; i++)
279 {
280 num += InternalGetDaysInMonth(lunarYear, i);
281 }
282 int yearInfo = GetYearInfo(lunarYear, 1);
283 int yearInfo2 = GetYearInfo(lunarYear, 2);
284 bool flag = GregorianIsLeapYear(lunarYear);
285 int[] array = (flag ? s_daysToMonth366 : s_daysToMonth365);
286 solarDay = yearInfo2;
287 if (yearInfo > 1)
288 {
289 solarDay += array[yearInfo - 1];
290 }
291 solarDay += num;
292 if (solarDay > 365 + (flag ? 1 : 0))
293 {
294 solarYear = lunarYear + 1;
295 solarDay -= 365 + (flag ? 1 : 0);
296 }
297 else
298 {
299 solarYear = lunarYear;
300 }
301 solarMonth = 1;
302 while (solarMonth < 12 && array[solarMonth] < solarDay)
303 {
304 solarMonth++;
305 }
306 solarDay -= array[solarMonth - 1];
307 return true;
308 }
int GetYearInfo(int LunarYear, int Index)

References System.array, System.Globalization.EastAsianLunisolarCalendar.GetYearInfo(), System.Globalization.EastAsianLunisolarCalendar.GregorianIsLeapYear(), System.Globalization.EastAsianLunisolarCalendar.InternalGetDaysInMonth(), System.Globalization.EastAsianLunisolarCalendar.s_daysToMonth365, and System.Globalization.EastAsianLunisolarCalendar.s_daysToMonth366.

Referenced by System.Globalization.EastAsianLunisolarCalendar.LunarToTime(), and System.Globalization.EastAsianLunisolarCalendar.ToDateTime().