Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ GregorianToLunar()

void System.Globalization.EastAsianLunisolarCalendar.GregorianToLunar ( int solarYear,
int solarMonth,
int solarDate,
out int lunarYear,
out int lunarMonth,
out int lunarDate )
inlineprivateinherited

Definition at line 225 of file EastAsianLunisolarCalendar.cs.

226 {
227 int num = (GregorianIsLeapYear(solarYear) ? s_daysToMonth366[solarMonth - 1] : s_daysToMonth365[solarMonth - 1]);
228 num += solarDate;
229 int num2 = num;
230 lunarYear = solarYear;
231 int yearInfo;
232 int yearInfo2;
233 if (lunarYear == MaxCalendarYear + 1)
234 {
235 lunarYear--;
236 num2 += (GregorianIsLeapYear(lunarYear) ? 366 : 365);
237 yearInfo = GetYearInfo(lunarYear, 1);
238 yearInfo2 = GetYearInfo(lunarYear, 2);
239 }
240 else
241 {
242 yearInfo = GetYearInfo(lunarYear, 1);
243 yearInfo2 = GetYearInfo(lunarYear, 2);
244 if (solarMonth < yearInfo || (solarMonth == yearInfo && solarDate < yearInfo2))
245 {
246 lunarYear--;
247 num2 += (GregorianIsLeapYear(lunarYear) ? 366 : 365);
248 yearInfo = GetYearInfo(lunarYear, 1);
249 yearInfo2 = GetYearInfo(lunarYear, 2);
250 }
251 }
252 num2 -= s_daysToMonth365[yearInfo - 1];
253 num2 -= yearInfo2 - 1;
254 int num3 = 32768;
255 int yearInfo3 = GetYearInfo(lunarYear, 3);
256 int num4 = (((yearInfo3 & num3) != 0) ? 30 : 29);
257 lunarMonth = 1;
258 while (num2 > num4)
259 {
260 num2 -= num4;
261 lunarMonth++;
262 num3 >>= 1;
263 num4 = (((yearInfo3 & num3) != 0) ? 30 : 29);
264 }
265 lunarDate = num2;
266 }
int GetYearInfo(int LunarYear, int Index)

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

Referenced by System.Globalization.EastAsianLunisolarCalendar.TimeToLunar().