GetAbsoluteDate() static private méthode

static private GetAbsoluteDate ( int year, int month, int day ) : long
year int
month int
day int
Résultat long
Exemple #1
0
        /*=================================GetAbsoluteDateUmAlQura==========================
        **Action: Gets the Absolute date for the given UmAlQura date.  The absolute date means
        **       the number of days from January 1st, 1 A.D.
        **Returns:
        **Arguments:
        **Exceptions:
        ============================================================================*/
        private static long GetAbsoluteDateUmAlQura(int year, int month, int day)
        {
            //Caller should check the validaty of year, month and day.

            int yg = 0, mg = 0, dg = 0;
            ConvertHijriToGregorian(year, month, day, ref yg, ref mg, ref dg);
            return GregorianCalendar.GetAbsoluteDate(yg, mg, dg);
        }
Exemple #2
0
        internal virtual int GetDatePart(long ticks, int part)
        {
            HebrewCalendar.CheckTicksRange(ticks);
            DateTime dateTime = new DateTime(ticks);
            int      year     = dateTime.Year;
            int      month    = dateTime.Month;
            int      day      = dateTime.Day;

            HebrewCalendar.__DateBuffer lunarDate = new HebrewCalendar.__DateBuffer();
            lunarDate.year = year + 3760;
            int index1 = HebrewCalendar.GetLunarMonthDay(year, lunarDate);

            HebrewCalendar.__DateBuffer result = new HebrewCalendar.__DateBuffer();
            result.year  = lunarDate.year;
            result.month = lunarDate.month;
            result.day   = lunarDate.day;
            long absoluteDate = GregorianCalendar.GetAbsoluteDate(year, month, day);

            if (month == 1 && day == 1)
            {
                return(HebrewCalendar.GetResult(result, part));
            }
            long num1 = absoluteDate - GregorianCalendar.GetAbsoluteDate(year, 1, 1);

            if (num1 + (long)lunarDate.day <= (long)HebrewCalendar.LunarMonthLen[index1, lunarDate.month])
            {
                result.day += (int)num1;
                return(HebrewCalendar.GetResult(result, part));
            }
            ++result.month;
            result.day = 1;
            long num2 = num1 - (long)(HebrewCalendar.LunarMonthLen[index1, lunarDate.month] - lunarDate.day);

            if (num2 > 1L)
            {
                while (num2 > (long)HebrewCalendar.LunarMonthLen[index1, result.month])
                {
                    long num3 = num2;
                    int[,] numArray = HebrewCalendar.LunarMonthLen;
                    int index2 = index1;
                    HebrewCalendar.__DateBuffer dateBuffer = result;
                    int num4 = dateBuffer.month;
                    int num5 = num4 + 1;
                    dateBuffer.month = num5;
                    int  index3 = num4;
                    long num6   = (long)numArray[index2, index3];
                    num2 = num3 - num6;
                    if (result.month > 13 || HebrewCalendar.LunarMonthLen[index1, result.month] == 0)
                    {
                        ++result.year;
                        index1       = HebrewCalendar.HebrewTable[(year + 1 - 1583) * 2 + 1];
                        result.month = 1;
                    }
                }
                result.day += (int)(num2 - 1L);
            }
            return(HebrewCalendar.GetResult(result, part));
        }
        // Token: 0x06002ED1 RID: 11985 RVA: 0x000B3BA4 File Offset: 0x000B1DA4
        private static long GetAbsoluteDateUmAlQura(int year, int month, int day)
        {
            int year2  = 0;
            int month2 = 0;
            int day2   = 0;

            UmAlQuraCalendar.ConvertHijriToGregorian(year, month, day, ref year2, ref month2, ref day2);
            return(GregorianCalendar.GetAbsoluteDate(year2, month2, day2));
        }
Exemple #4
0
        private static long GetAbsoluteDateUmAlQura(int year, int month, int day)
        {
            int yg = 0;
            int mg = 0;
            int dg = 0;

            ConvertHijriToGregorian(year, month, day, ref yg, ref mg, ref dg);
            return(GregorianCalendar.GetAbsoluteDate(yg, mg, dg));
        }
Exemple #5
0
        internal virtual int GetDatePart(long ticks, int part)
        {
            this.CheckTicksRange(ticks);
            DateTime     time      = new DateTime(ticks);
            int          year      = time.Year;
            int          month     = time.Month;
            int          day       = time.Day;
            __DateBuffer lunarDate = new __DateBuffer {
                year = year + 0xeb0
            };
            int          lunarMonthDay = this.GetLunarMonthDay(year, lunarDate);
            __DateBuffer result        = new __DateBuffer {
                year  = lunarDate.year,
                month = lunarDate.month,
                day   = lunarDate.day
            };
            long num5 = GregorianCalendar.GetAbsoluteDate(year, month, day);

            if ((month != 1) || (day != 1))
            {
                long num6 = num5 - GregorianCalendar.GetAbsoluteDate(year, 1, 1);
                if ((num6 + lunarDate.day) <= m_lunarMonthLen[lunarMonthDay, lunarDate.month])
                {
                    result.day += (int)num6;
                    return(this.GetResult(result, part));
                }
                result.month++;
                result.day = 1;
                num6      -= m_lunarMonthLen[lunarMonthDay, lunarDate.month] - lunarDate.day;
                if (num6 > 1L)
                {
                    while (num6 > m_lunarMonthLen[lunarMonthDay, result.month])
                    {
                        num6 -= m_lunarMonthLen[lunarMonthDay, result.month++];
                        if ((result.month > 13) || (m_lunarMonthLen[lunarMonthDay, result.month] == 0))
                        {
                            result.year++;
                            lunarMonthDay = m_HebrewTable[(((year + 1) - 0x62f) * 2) + 1];
                            result.month  = 1;
                        }
                    }
                    result.day += (int)(num6 - 1L);
                }
            }
            return(this.GetResult(result, part));
        }
Exemple #6
0
        // Returns a given date part of this DateTime. This method is used
        // to compute the year, day-of-year, month, or day part.

        internal virtual int GetDatePart(long ticks, int part)
        {
            // The Gregorian year, month, day value for ticks.
            int  gregorianYear, gregorianMonth, gregorianDay;
            int  hebrewYearType;              // lunar year type
            long AbsoluteDate;                // absolute date - absolute date 1/1/1600

            //
            //  Make sure we have a valid Gregorian date that will fit into our
            //  Hebrew conversion limits.
            //
            CheckTicksRange(ticks);

            DateTime time = new DateTime(ticks);

            //
            //  Save the Gregorian date values.
            //
            time.GetDatePart(out gregorianYear, out gregorianMonth, out gregorianDay);

            __DateBuffer lunarDate = new __DateBuffer();    // lunar month and day for Jan 1

            // From the table looking-up value of HebrewTable[index] (stored in lunarDate.day), we get the the
            // lunar month and lunar day where the Gregorian date 1/1 falls.
            lunarDate.year = gregorianYear + HebrewYearOf1AD;
            hebrewYearType = GetLunarMonthDay(gregorianYear, lunarDate);

            // This is the buffer used to store the result Hebrew date.
            __DateBuffer result = new __DateBuffer();

            //
            //  Store the values for the start of the new year - 1/1.
            //
            result.year  = lunarDate.year;
            result.month = lunarDate.month;
            result.day   = lunarDate.day;

            //
            //  Get the absolute date from 1/1/1600.
            //
            AbsoluteDate = GregorianCalendar.GetAbsoluteDate(gregorianYear, gregorianMonth, gregorianDay);

            //
            //  If the requested date was 1/1, then we're done.
            //
            if ((gregorianMonth == 1) && (gregorianDay == 1))
            {
                return(GetResult(result, part));
            }

            //
            //  Calculate the number of days between 1/1 and the requested date.
            //
            long NumDays;                      // number of days since 1/1

            NumDays = AbsoluteDate - GregorianCalendar.GetAbsoluteDate(gregorianYear, 1, 1);

            //
            //  If the requested date is within the current lunar month, then
            //  we're done.
            //
            if ((NumDays + (long)lunarDate.day) <= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month]))
            {
                result.day += (int)NumDays;
                return(GetResult(result, part));
            }

            //
            //  Adjust for the current partial month.
            //
            result.month++;
            result.day = 1;

            //
            //  Adjust the Lunar Month and Year (if necessary) based on the number
            //  of days between 1/1 and the requested date.
            //
            //  Assumes Jan 1 can never translate to the last Lunar month, which
            //  is true.
            //
            NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + lunarDate.month] - lunarDate.day);
            Debug.Assert(NumDays >= 1, "NumDays >= 1");

            // If NumDays is 1, then we are done.  Otherwise, find the correct Hebrew month
            // and day.
            if (NumDays > 1)
            {
                //
                //  See if we're on the correct Lunar month.
                //
                while (NumDays > (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month]))
                {
                    //
                    //  Adjust the number of days and move to the next month.
                    //
                    NumDays -= (long)(s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month++]);

                    //
                    //  See if we need to adjust the Year.
                    //  Must handle both 12 and 13 month years.
                    //
                    if ((result.month > 13) || (s_lunarMonthLen[hebrewYearType * MaxMonthPlusOne + result.month] == 0))
                    {
                        //
                        //  Adjust the Year.
                        //
                        result.year++;
                        hebrewYearType = s_hebrewTable[(gregorianYear + 1 - FirstGregorianTableYear) * 2 + 1];

                        //
                        //  Adjust the Month.
                        //
                        result.month = 1;
                    }
                }
                //
                //  Found the right Lunar month.
                //
                result.day += (int)(NumDays - 1);
            }
            return(GetResult(result, part));
        }
 internal virtual long DateToTicks(int year, int month, int day)
 {
     return(GregorianCalendar.GetAbsoluteDate(year, month, day) * 864000000000L);
 }