Пример #1
0
        /// <summary>
        ///  Shift a date by a given number of months
        /// </summary>
        /// <param name="dateInYear">Original date value</param>
        /// <param name="months">Months to increment by</param>
        private static void MonthShift(ref DMY dateInYear, int months)
        {
            int totalMonths;

            if ((dateInYear.Y != 0) && (dateInYear.M != 0))
            {
                totalMonths  = 12 * dateInYear.Y + dateInYear.M + months - 13;               // Months from 1 Jan 0001
                dateInYear.Y = 1 + totalMonths / 12;
                dateInYear.M = 1 + totalMonths % 12;
            }
            else if (dateInYear.Y != 0)
            {
                dateInYear.Y += months / 12;
            }
            else if (dateInYear.M != 0)
            {
                dateInYear.M = 1 + (dateInYear.M + months - 12 * (months / 12) + 11) % 12;
            }
        }
Пример #2
0
        /// <summary>
        ///  Shift a date by a given number of months
        /// </summary>
        /// <param name="aDate">Original date value</param>
        /// <param name="Months">Months to increment by</param>
        static private void MonthShift(ref DMY aDate, int Months)
        {
            int TotalMonths;

            if ((aDate.Y != 0) && (aDate.M != 0))
            {
                TotalMonths = 12 * aDate.Y + aDate.M + Months - 13;                // Months from 1 Jan 0001
                aDate.Y     = 1 + TotalMonths / 12;
                aDate.M     = 1 + TotalMonths % 12;
            }
            else if (aDate.Y != 0)
            {
                aDate.Y += Months / 12;
            }
            else if (aDate.M != 0)
            {
                aDate.M = 1 + (aDate.M + Months - 12 * (Months / 12) + 11) % 12;
            }
        }
Пример #3
0
        /// <summary>
        ///  Shift a date by a given number of months                              
        /// </summary>
        /// <param name="aDate">Original date value</param>
        /// <param name="Months">Months to increment by</param>
        private static void MonthShift(ref DMY aDate, int Months)
        {
            int TotalMonths;

            if ((aDate.Y != 0) && (aDate.M != 0))
            {
                TotalMonths = 12 * aDate.Y + aDate.M + Months - 13;                // Months from 1 Jan 0001
                aDate.Y = 1 + TotalMonths / 12;
                aDate.M = 1 + TotalMonths % 12;
            }
            else if (aDate.Y != 0)
                aDate.Y += Months / 12;
            else if (aDate.M != 0)
                aDate.M = 1 + (aDate.M + Months - 12 * (Months / 12) + 11) % 12;
        }