fixed_from_dmy() публичный статический Метод

The method returns the fixed day number of the given Islamic date.
public static fixed_from_dmy ( int day, int month, int year ) : int
day int An integer representing the day of the month, /// counting from 1. ///
month int An integer representing the month in the /// Islamic year. ///
year int An integer representing the Islamic year. /// Non-positive values are allowed also. ///
Результат int
        public static void my_from_fixed(out int month, out int year, int date)
        {
            year = CCHijriCalendar.year_from_fixed(date);
            int num = 1 + (int)Math.Ceiling((double)(date - 29 - CCHijriCalendar.fixed_from_dmy(1, 1, year)) / 29.5);

            month = ((num >= 12) ? 12 : num);
        }
Пример #2
0
        /// <summary>Returns a <see cref="T:System.DateTime" /> that is set to the specified date, time, and era.</summary>
        /// <returns>The <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</returns>
        /// <param name="year">A year. </param>
        /// <param name="month">An integer from 1 through 12 that represents a month. </param>
        /// <param name="day">An integer from 1 through 29 that represents a day. </param>
        /// <param name="hour">An integer from 0 through 23 that represents an hour. </param>
        /// <param name="minute">An integer from 0 through 59 that represents a minute. </param>
        /// <param name="second">An integer from 0 through 59 that represents a second. </param>
        /// <param name="millisecond">An integer from 0 through 999 that represents a millisecond. </param>
        /// <param name="era">An era. Specify UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra] or <see cref="F:System.Globalization.UmAlQuraCalendar.UmAlQuraEra" />.</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="year" />, <paramref name="month" />, <paramref name="day" />, or <paramref name="era" /> is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class.-or- <paramref name="hour" /> is less than zero or greater than 23.-or- <paramref name="minute" /> is less than zero or greater than 59.-or- <paramref name="second" /> is less than zero or greater than 59.-or- <paramref name="millisecond" /> is less than zero or greater than 999. </exception>
        public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
        {
            this.M_CheckYMDE(year, month, day, ref era);
            base.M_CheckHMSM(hour, minute, second, millisecond);
            int date = CCHijriCalendar.fixed_from_dmy(day, month, year);

            return(this.M_ToDateTime(date, hour, minute, second, millisecond));
        }
Пример #3
0
        /// <summary>Calculates the number of days in the specified year of the specified era.</summary>
        /// <returns>The number of days in the specified year and era. The number of days is 354 in a common year or 355 in a leap year.</returns>
        /// <param name="year">A year. </param>
        /// <param name="era">An era. Specify UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra] or <see cref="F:System.Globalization.UmAlQuraCalendar.UmAlQuraEra" />.</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="year" /> or <paramref name="era" /> is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class. </exception>
        public override int GetDaysInYear(int year, int era)
        {
            this.M_CheckYE(year, ref era);
            int num  = CCHijriCalendar.fixed_from_dmy(1, 1, year);
            int num2 = CCHijriCalendar.fixed_from_dmy(1, 1, year + 1);

            return(num2 - num);
        }
Пример #4
0
        /// <summary>Calculates the number of days in the specified month of the specified year and era.</summary>
        /// <returns>The number of days in the specified month in the specified year and era. The return value is 29 in a common year and 30 in a leap year.</returns>
        /// <param name="year">A year. </param>
        /// <param name="month">An integer from 1 through 12 that represents a month. </param>
        /// <param name="era">An era. Specify UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra] or <see cref="F:System.Globalization.UmAlQuraCalendar.UmAlQuraEra" />.</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="year" />, <paramref name="month" />, or <paramref name="era" /> is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class. </exception>
        public override int GetDaysInMonth(int year, int month, int era)
        {
            this.M_CheckYME(year, month, ref era);
            int num  = CCHijriCalendar.fixed_from_dmy(1, month, year);
            int num2 = CCHijriCalendar.fixed_from_dmy(1, month + 1, year);

            return(num2 - num);
        }
Пример #5
0
        /// <summary>
        /// Overridden. Gives the number of days in the specified month
        /// of the given year and era.
        /// </summary>
        /// <param name="year">An integer that gives the year.
        /// </param>
        /// <param name="month">An integer that gives the month, starting
        /// with 1.</param>
        /// <param name="era">An intger that gives the era of the specified
        /// year.</param>
        /// <returns>An integer that gives the number of days of the
        /// specified month.</returns>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        /// The exception is thrown, if <paramref name="month"/>,
        /// <paramref name="year"/> ,or <paramref name="era"/> is outside
        /// the allowed range.
        /// </exception>
        public override int GetDaysInMonth(int year, int month, int era)
        {
            M_CheckYME(year, month, ref era);
            int rd1 = CCHijriCalendar.fixed_from_dmy(1, month, year);
            int rd2 = CCHijriCalendar.fixed_from_dmy(1, month + 1, year);

            return(rd2 - rd1);
        }
Пример #6
0
        /// <summary>
        /// Overridden. Gives the number of days of the specified
        /// year of the given era.
        /// </summary>
        /// <param name="year">An integer that specifies the year.
        /// </param>
        /// <param name="era">An ineger that specifies the era.
        /// </param>
        /// <returns>An integer that gives the number of days of the
        /// specified year.</returns>
        /// <exception cref="T:System.ArgumentOutOfRangeExceiption">
        /// The exception is thrown, if
        /// <paramref name="year"/> is outside the allowed range.
        /// </exception>
        public override int GetDaysInYear(int year, int era)
        {
            M_CheckYE(year, ref era);
            int rd1 = CCHijriCalendar.fixed_from_dmy(1, 1, year);
            int rd2 = CCHijriCalendar.fixed_from_dmy(1, 1, year + 1);

            return(rd2 - rd1);
        }
Пример #7
0
 internal void M_CheckYMDE(int year, int month, int day, ref int era)
 {
     this.M_CheckYME(year, month, ref era);
     base.M_ArgumentInRange("day", day, 1, this.GetDaysInMonth(year, month, 1));
     if (year == 9666)
     {
         int rdHijri = CCHijriCalendar.fixed_from_dmy(day, month, year);
         this.M_CheckFixedHijri("day", rdHijri);
     }
 }
Пример #8
0
        /// <summary>Calculates on which day of the year a specified date occurs.</summary>
        /// <returns>An integer from 1 through 355 that represents the day of the year specified by the <paramref name="time" /> parameter.</returns>
        /// <param name="time">The <see cref="T:System.DateTime" /> to read. The <see cref="T:System.Globalization.UmAlQuraCalendar" /> class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 05/13/2029 23:59:59 (Gregorian date).</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="time" /> is outside the range supported by this calendar. </exception>
        public override int GetDayOfYear(DateTime time)
        {
            int num = this.M_FromDateTime(time);

            this.M_CheckFixedHijri("time", num);
            int year = CCHijriCalendar.year_from_fixed(num);
            int num2 = CCHijriCalendar.fixed_from_dmy(1, 1, year);

            return(num - num2 + 1);
        }
Пример #9
0
        /// <summary>
        /// Overridden. Gives the number of the day in the year.
        /// </summary>
        /// <param name="time">The
        /// <see cref="T:System.DateTime"/> that specifies a
        /// date.
        /// </param>
        /// <returns>An integer representing the day of the year,
        /// starting with 1.</returns>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        /// The exception is thrown if the
        /// <see cref="T:System.DateTime"/> parameter is not in the
        /// supported range of the Hijri calendar.
        /// </exception>
        public override int GetDayOfYear(DateTime time)
        {
            int rd = M_FromDateTime(time);

            M_CheckFixedHijri("time", rd);
            int year  = CCHijriCalendar.year_from_fixed(rd);
            int rd1_1 = CCHijriCalendar.fixed_from_dmy(1, 1, year);

            return(rd - rd1_1 + 1);
        }
Пример #10
0
        /// <summary>
        /// Overridden. Creates the
        /// <see cref="T:System.DateTime"/> from the parameters.
        /// </summary>
        /// <param name="year">An integer that gives the year in the
        /// <paramref name="era"/>.
        /// </param>
        /// <param name="month">An integer that specifies the month.
        /// </param>
        /// <param name="day">An integer that specifies the day.
        /// </param>
        /// <param name="hour">An integer that specifies the hour.
        /// </param>
        /// <param name="minute">An integer that specifies the minute.
        /// </param>
        /// <param name="second">An integer that gives the second.
        /// </param>
        /// <param name="milliseconds">An integer that gives the
        /// milliseconds.
        /// </param>
        /// <param name="era">An integer that specifies the era.
        /// </param>
        /// <returns>A
        /// <see cref="T:system.DateTime"/> representig the date and time.
        /// </returns>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        /// The exception is thrown, if at least one of the parameters
        /// is out of range.
        /// </exception>
        public override DateTime ToDateTime(int year, int month, int day,
                                            int hour, int minute, int second, int milliseconds,
                                            int era)
        {
            M_CheckYMDE(year, month, day, ref era);
            M_CheckHMSM(hour, minute, second, milliseconds);
            int rd = CCHijriCalendar.fixed_from_dmy(day, month, year);

            return(M_ToDateTime(rd,
                                hour, minute, second, milliseconds));
        }
Пример #11
0
 /// <summary>
 /// A protected method checking the calendar day, month, and year
 /// and the era number.
 /// </summary>
 /// <param name="year">An integer representing the calendar year.
 /// </param>
 /// <param name="month">An integer giving the calendar month.
 /// </param>
 /// <param name="day">An integer giving the calendar day.
 /// </param>
 /// <param name="era">The era number.</param>
 /// <exception cref="T:System.ArgumentException">
 /// The exception is thrown if the era is not equal
 /// <see cref="F:HijriEra"/>.
 /// </exception>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 /// The exception is thrown if the calendar year, month, or day is
 /// outside of the allowed range.
 /// </exception>
 internal void M_CheckYMDE(int year, int month, int day, ref int era)
 {
     M_CheckYME(year, month, ref era);
     M_ArgumentInRange("day", day, 1,
                       GetDaysInMonth(year, month, HijriEra));
     if (year == 9666)
     {
         int rd = CCHijriCalendar.fixed_from_dmy(day, month,
                                                 year);
         M_CheckFixedHijri("day", rd);
     }
 }
Пример #12
0
 internal void M_CheckYME(int year, int month, ref int era)
 {
     this.M_CheckYE(year, ref era);
     if (month < 1 || month > 12)
     {
         throw new ArgumentOutOfRangeException("month", "Month must be between one and twelve.");
     }
     if (year == 9666)
     {
         int rdHijri = CCHijriCalendar.fixed_from_dmy(1, month, year);
         this.M_CheckFixedHijri("month", rdHijri);
     }
 }
Пример #13
0
        /// <summary>Calculates a date that is a specified number of years away from a specified initial date.</summary>
        /// <returns>A <see cref="T:System.DateTime" /> that represents the date yielded by adding the number of years specified by the <paramref name="years" /> parameter to the date specified by the <paramref name="time" /> parameter.</returns>
        /// <param name="time">The <see cref="T:System.DateTime" /> to which to add years. The <see cref="T:System.Globalization.UmAlQuraCalendar" /> class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 05/13/2029 23:59:59 (Gregorian date).</param>
        /// <param name="years">The positive or negative number of years to add. </param>
        /// <exception cref="T:System.ArgumentException">The resulting date is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class. </exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="years" /> is less than -10,000 or greater than 10,000. -or-<paramref name="time" /> is outside the range supported by this calendar.</exception>
        public override DateTime AddYears(DateTime time, int years)
        {
            int num = this.M_FromDateTime(time);
            int day;
            int month;
            int num2;

            CCHijriCalendar.dmy_from_fixed(out day, out month, out num2, num);
            num2 += years;
            num   = CCHijriCalendar.fixed_from_dmy(day, month, num2);
            this.M_CheckFixedHijri("time", num);
            return(this.M_ToDateTime(num).Add(time.TimeOfDay));
        }
Пример #14
0
        /// <summary>Calculates a date that is a specified number of months away from a specified initial date.</summary>
        /// <returns>A <see cref="T:System.DateTime" /> that represents the date yielded by adding the number of months specified by the <paramref name="months" /> parameter to the date specified by the <paramref name="time" /> parameter.</returns>
        /// <param name="time">The <see cref="T:System.DateTime" /> to which to add months. The <see cref="T:System.Globalization.UmAlQuraCalendar" /> class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 05/13/2029 23:59:59 (Gregorian date).</param>
        /// <param name="months">The positive or negative number of months to add. </param>
        /// <exception cref="T:System.ArgumentException">The resulting date is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class. </exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="months" /> is less than -120,000 or greater than 120,000. -or-<paramref name="time" /> is outside the range supported by this calendar.</exception>
        public override DateTime AddMonths(DateTime time, int months)
        {
            int num = this.M_FromDateTime(time);
            int day;
            int num2;
            int num3;

            CCHijriCalendar.dmy_from_fixed(out day, out num2, out num3, num);
            num2 += months;
            num3 += CCMath.div_mod(out num2, num2, 12);
            num   = CCHijriCalendar.fixed_from_dmy(day, num2, num3);
            this.M_CheckFixedHijri("time", num);
            return(this.M_ToDateTime(num).Add(time.TimeOfDay));
        }
Пример #15
0
        /// <summary>
        /// Overrideden. Adds years to a given date.
        /// </summary>
        /// <param name="time">The
        /// <see cref="T:System.DateTime"/> to which to add
        /// years.
        /// </param>
        /// <param name="years">The number of years to add.</param>
        /// <returns>A new <see cref="T:System.DateTime"/> value, that
        /// results from adding <paramref name="years"/> to the specified
        /// DateTime.</returns>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        /// The exception is thrown if the
        /// <see cref="T:System.DateTime"/> return value is not in the
        /// supported range of the Hijri calendar.
        /// </exception>
        public override DateTime AddYears(DateTime time, int years)
        {
            int rd = M_FromDateTime(time);
            int day, month, year;

            CCHijriCalendar.dmy_from_fixed(
                out day, out month, out year, rd);
            year += years;
            rd    = CCHijriCalendar.fixed_from_dmy(day, month, year);
            M_CheckFixedHijri("time", rd);
            DateTime t = M_ToDateTime(rd);

            return(t.Add(time.TimeOfDay));
        }
Пример #16
0
 public static int date_difference(int dayA, int monthA, int yearA, int dayB, int monthB, int yearB)
 {
     return(CCHijriCalendar.fixed_from_dmy(dayB, monthB, yearB) - CCHijriCalendar.fixed_from_dmy(dayA, monthA, yearA));
 }
Пример #17
0
 public static void dmy_from_fixed(out int day, out int month, out int year, int date)
 {
     CCHijriCalendar.my_from_fixed(out month, out year, date);
     day = date - CCHijriCalendar.fixed_from_dmy(1, month, year) + 1;
 }