Beispiel #1
0
        /// <summary>
        /// Adds years to the given date.
        /// </summary>
        /// <param name="time">The
        /// <see cref="T:DateTime"/> to which to add
        /// months.
        /// </param>
        /// <param name="years">The number of years to add.</param>
        /// <returns>A new <see cref="T:DateTime"/> value, that
        /// results from adding <paramref name="years"/> to the specified
        /// DateTime.</returns>
        public static DateTime AddYears(DateTime time,
                                        int years)
        {
            int rd = CCFixed.FromDateTime(time);
            int day, month, year;

            dmy_from_fixed(out day, out month, out year, rd);
            year += years;
            int maxday = GetDaysInMonth(year, month);

            if (day > maxday)
            {
                day = maxday;
            }
            rd = fixed_from_dmy(day, month, year);
            DateTime t = CCFixed.ToDateTime(rd);

            return(t.Add(time.TimeOfDay));
        }
Beispiel #2
0
 /// <summary>
 /// A method that creates the
 /// <see cref="T:DateTime"/> from the parameters.
 /// </summary>
 /// <param name="year">An integer that gives the year
 /// </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>
 /// <returns>A
 /// <see cref="T:system.DateTime"/> representig the date and time.
 /// </returns>
 public static DateTime ToDateTime(int year, int month, int day,
                                   int hour, int minute, int second, int milliseconds)
 {
     return(CCFixed.ToDateTime(fixed_from_dmy(day, month, year),
                               hour, minute, second, milliseconds));
 }