div_mod() public static method

A static method that combines integer division and remainder computation.
public static div_mod ( int &remainder, int x, int y ) : int
remainder int Remainder integer output value. ///
x int Integer to be divided.
y int Divisor integer value.
return int
コード例 #1
0
        public static int year_from_fixed(int date)
        {
            int x    = date - 1;
            int num  = CCMath.div_mod(out x, x, 146097);
            int num2 = CCMath.div_mod(out x, x, 36524);
            int num3 = CCMath.div_mod(out x, x, 1461);
            int num4 = CCMath.div(x, 365);
            int num5 = 400 * num + 100 * num2 + 4 * num3 + num4;

            return((num2 != 4 && num4 != 4) ? (num5 + 1) : num5);
        }
コード例 #2
0
        /// <summary>Returns a <see cref="T:System.DateTime" /> that is the specified number of months away from the specified <see cref="T:System.DateTime" />.</summary>
        /// <returns>The <see cref="T:System.DateTime" /> that results from adding the specified number of months to the specified <see cref="T:System.DateTime" />.</returns>
        /// <param name="time">The <see cref="T:System.DateTime" /> to which to add months. </param>
        /// <param name="months">The number of months to add. </param>
        /// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="months" /> is less than -120000.-or- <paramref name="months" /> is greater than 120000. </exception>
        public override DateTime AddMonths(DateTime time, int months)
        {
            int date = CCFixed.FromDateTime(time);
            int day;
            int num;
            int num2;

            CCJulianCalendar.dmy_from_fixed(out day, out num, out num2, date);
            num  += months;
            num2 += CCMath.div_mod(out num, num, 12);
            date  = CCJulianCalendar.fixed_from_dmy(day, num, num2);
            return(CCFixed.ToDateTime(date).Add(time.TimeOfDay));
        }
コード例 #3
0
        /// <summary>
        /// Overridden. Adds months to a given date.
        /// </summary>
        /// <param name="time">The
        /// <see cref="T:System.DateTime"/> to which to add
        /// months.
        /// </param>
        /// <param name="months">The number of months to add.</param>
        /// <returns>A new <see cref="T:System.DateTime"/> value, that
        /// results from adding <paramref name="months"/> to the specified
        /// DateTime.</returns>
        public override DateTime AddMonths(DateTime time, int months)
        {
            int rd = CCFixed.FromDateTime(time);
            int day, month, year;

            CCJulianCalendar.dmy_from_fixed(
                out day, out month, out year, rd);
            month += months;
            year  += CCMath.div_mod(out month, month, 12);
            rd     = CCJulianCalendar.fixed_from_dmy(day, month, year);
            DateTime t = CCFixed.ToDateTime(rd);

            return(t.Add(time.TimeOfDay));
        }
コード例 #4
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));
        }
コード例 #5
0
ファイル: HijriCalendar.cs プロジェクト: zgramana/mono
        /// <summary>
        /// Overrideden. Adds months to a given date.
        /// </summary>
        /// <param name="time">The
        /// <see cref="T:System.DateTime"/> to which to add
        /// months.
        /// </param>
        /// <param name="months">The number of months to add.</param>
        /// <returns>A new <see cref="T:System.DateTime"/> value, that
        /// results from adding <paramref name="months"/> 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 AddMonths(DateTime time, int months)
        {
            int rd = M_FromDateTime(time);
            int day, month, year;

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

            return(t.Add(time.TimeOfDay));
        }
コード例 #6
0
        public static int elapsed_days(int year)
        {
            int num = CCMath.div(235 * year - 234, 19);
            int num3;
            int num2 = CCMath.div_mod(out num3, num, 1080);
            int x    = 204 + 793 * num3;
            int x2   = 11 + 12 * num + 793 * num2 + CCMath.div(x, 1080);
            int num4 = 29 * num + CCMath.div(x2, 24);

            if (CCMath.mod(3 * (num4 + 1), 7) < 3)
            {
                num4++;
            }
            return(num4);
        }
コード例 #7
0
        /// <summary>Returns a <see cref="T:System.DateTime" /> that is offset the specified number of months from the specified <see cref="T:System.DateTime" />.</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. </param>
        /// <param name="months">The positive or negative number of months to add. </param>
        /// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///   <paramref name="months" /> is less than -120,000 or greater than 120,000. </exception>
        public override DateTime AddMonths(DateTime time, int months)
        {
            int date = CCFixed.FromDateTime(time);
            int day;
            int num;
            int num2;

            this.dmy_from_fixed(out day, out num, out num2, date);
            num  += months;
            num2 += CCMath.div_mod(out num, num, 12);
            date  = this.fixed_from_dmy(day, num, num2);
            DateTime dateTime = CCFixed.ToDateTime(date).Add(time.TimeOfDay);

            this.M_CheckDateTime(dateTime);
            return(dateTime);
        }
コード例 #8
0
        public static DateTime AddMonths(DateTime time, int months)
        {
            int date = CCFixed.FromDateTime(time);
            int num;
            int num2;
            int num3;

            CCGregorianCalendar.dmy_from_fixed(out num, out num2, out num3, date);
            num2 += months;
            num3 += CCMath.div_mod(out num2, num2, 12);
            int daysInMonth = CCGregorianCalendar.GetDaysInMonth(num3, num2);

            if (num > daysInMonth)
            {
                num = daysInMonth;
            }
            date = CCGregorianCalendar.fixed_from_dmy(num, num2, num3);
            return(CCFixed.ToDateTime(date).Add(time.TimeOfDay));
        }