Beispiel #1
0
        // Token: 0x06002F16 RID: 12054 RVA: 0x000B4884 File Offset: 0x000B2A84
        internal void GregorianToLunar(int nSYear, int nSMonth, int nSDate, ref int nLYear, ref int nLMonth, ref int nLDate)
        {
            int num  = EastAsianLunisolarCalendar.GregorianIsLeapYear(nSYear);
            int num2 = (num == 1) ? EastAsianLunisolarCalendar.DaysToMonth366[nSMonth - 1] : EastAsianLunisolarCalendar.DaysToMonth365[nSMonth - 1];

            num2 += nSDate;
            int i = num2;

            nLYear = nSYear;
            int yearInfo;
            int yearInfo2;

            if (nLYear == this.MaxCalendarYear + 1)
            {
                nLYear--;
                i        += ((EastAsianLunisolarCalendar.GregorianIsLeapYear(nLYear) == 1) ? 366 : 365);
                yearInfo  = this.GetYearInfo(nLYear, 1);
                yearInfo2 = this.GetYearInfo(nLYear, 2);
            }
            else
            {
                yearInfo  = this.GetYearInfo(nLYear, 1);
                yearInfo2 = this.GetYearInfo(nLYear, 2);
                if (nSMonth < yearInfo || (nSMonth == yearInfo && nSDate < yearInfo2))
                {
                    nLYear--;
                    i        += ((EastAsianLunisolarCalendar.GregorianIsLeapYear(nLYear) == 1) ? 366 : 365);
                    yearInfo  = this.GetYearInfo(nLYear, 1);
                    yearInfo2 = this.GetYearInfo(nLYear, 2);
                }
            }
            i -= EastAsianLunisolarCalendar.DaysToMonth365[yearInfo - 1];
            i -= yearInfo2 - 1;
            int num3      = 32768;
            int yearInfo3 = this.GetYearInfo(nLYear, 3);
            int num4      = ((yearInfo3 & num3) != 0) ? 30 : 29;

            nLMonth = 1;
            while (i > num4)
            {
                i -= num4;
                nLMonth++;
                num3 >>= 1;
                num4   = (((yearInfo3 & num3) != 0) ? 30 : 29);
            }
            nLDate = i;
        }
        internal void GregorianToLunar(int nSYear, int nSMonth, int nSDate, ref int nLYear, ref int nLMonth, ref int nLDate)
        {
            int num1 = (EastAsianLunisolarCalendar.GregorianIsLeapYear(nSYear) == 1 ? EastAsianLunisolarCalendar.DaysToMonth366[nSMonth - 1] : EastAsianLunisolarCalendar.DaysToMonth365[nSMonth - 1]) + nSDate;

            nLYear = nSYear;
            int yearInfo1;
            int yearInfo2;

            if (nLYear == this.MaxCalendarYear + 1)
            {
                --nLYear;
                num1     += EastAsianLunisolarCalendar.GregorianIsLeapYear(nLYear) == 1 ? 366 : 365;
                yearInfo1 = this.GetYearInfo(nLYear, 1);
                yearInfo2 = this.GetYearInfo(nLYear, 2);
            }
            else
            {
                yearInfo1 = this.GetYearInfo(nLYear, 1);
                yearInfo2 = this.GetYearInfo(nLYear, 2);
                if (nSMonth < yearInfo1 || nSMonth == yearInfo1 && nSDate < yearInfo2)
                {
                    --nLYear;
                    num1     += EastAsianLunisolarCalendar.GregorianIsLeapYear(nLYear) == 1 ? 366 : 365;
                    yearInfo1 = this.GetYearInfo(nLYear, 1);
                    yearInfo2 = this.GetYearInfo(nLYear, 2);
                }
            }
            int num2      = num1 - EastAsianLunisolarCalendar.DaysToMonth365[yearInfo1 - 1] - (yearInfo2 - 1);
            int num3      = 32768;
            int yearInfo3 = this.GetYearInfo(nLYear, 3);
            int num4      = (yearInfo3 & num3) != 0 ? 30 : 29;

            nLMonth = 1;
            for (; num2 > num4; num4 = (yearInfo3 & num3) != 0 ? 30 : 29)
            {
                num2 -= num4;
                ++nLMonth;
                num3 >>= 1;
            }
            nLDate = num2;
        }
Beispiel #3
0
        // Token: 0x06002F17 RID: 12055 RVA: 0x000B49CC File Offset: 0x000B2BCC
        internal bool LunarToGregorian(int nLYear, int nLMonth, int nLDate, ref int nSolarYear, ref int nSolarMonth, ref int nSolarDay)
        {
            if (nLDate < 1 || nLDate > 30)
            {
                return(false);
            }
            int num = nLDate - 1;

            for (int i = 1; i < nLMonth; i++)
            {
                num += this.InternalGetDaysInMonth(nLYear, i);
            }
            int yearInfo  = this.GetYearInfo(nLYear, 1);
            int yearInfo2 = this.GetYearInfo(nLYear, 2);
            int num2      = EastAsianLunisolarCalendar.GregorianIsLeapYear(nLYear);

            int[] array = (num2 == 1) ? EastAsianLunisolarCalendar.DaysToMonth366 : EastAsianLunisolarCalendar.DaysToMonth365;
            nSolarDay = yearInfo2;
            if (yearInfo > 1)
            {
                nSolarDay += array[yearInfo - 1];
            }
            nSolarDay += num;
            if (nSolarDay > num2 + 365)
            {
                nSolarYear = nLYear + 1;
                nSolarDay -= num2 + 365;
            }
            else
            {
                nSolarYear = nLYear;
            }
            nSolarMonth = 1;
            while (nSolarMonth < 12 && array[nSolarMonth] < nSolarDay)
            {
                nSolarMonth++;
            }
            nSolarDay -= array[nSolarMonth - 1];
            return(true);
        }
        internal bool LunarToGregorian(int nLYear, int nLMonth, int nLDate, ref int nSolarYear, ref int nSolarMonth, ref int nSolarDay)
        {
            if (nLDate < 1 || nLDate > 30)
            {
                return(false);
            }
            int num1 = nLDate - 1;

            for (int month = 1; month < nLMonth; ++month)
            {
                num1 += this.InternalGetDaysInMonth(nLYear, month);
            }
            int yearInfo1 = this.GetYearInfo(nLYear, 1);
            int yearInfo2 = this.GetYearInfo(nLYear, 2);
            int num2      = EastAsianLunisolarCalendar.GregorianIsLeapYear(nLYear);

            int[] numArray = num2 == 1 ? EastAsianLunisolarCalendar.DaysToMonth366 : EastAsianLunisolarCalendar.DaysToMonth365;
            nSolarDay = yearInfo2;
            if (yearInfo1 > 1)
            {
                nSolarDay += numArray[yearInfo1 - 1];
            }
            nSolarDay += num1;
            if (nSolarDay > num2 + 365)
            {
                nSolarYear = nLYear + 1;
                nSolarDay -= num2 + 365;
            }
            else
            {
                nSolarYear = nLYear;
            }
            nSolarMonth = 1;
            while (nSolarMonth < 12 && numArray[nSolarMonth] < nSolarDay)
            {
                ++nSolarMonth;
            }
            nSolarDay -= numArray[nSolarMonth - 1];
            return(true);
        }