Beispiel #1
0
        /// <summary>
        /// The method gives the number of the day in the year.
        /// </summary>
        /// <param name="time">The
        /// <see cref="T:DateTime"/> that specifies a
        /// date.
        /// </param>
        /// <returns>An integer representing the day of the year,
        /// starting with 1.</returns>
        public static int GetDayOfYear(DateTime time)
        {
            int rd    = CCFixed.FromDateTime(time);
            int year  = year_from_fixed(rd);
            int rd1_1 = fixed_from_dmy(1, 1, year);

            return(rd - rd1_1 + 1);
        }
Beispiel #2
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 #3
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));
 }
Beispiel #4
0
 /// <summary>
 /// The method gives the number of the year of the specified
 /// date.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:DateTime"/> that specifies a
 /// date.
 /// </param>
 /// <returns>An integer representing the year.
 /// </returns>
 public static int GetYear(DateTime time)
 {
     return(year_from_fixed(CCFixed.FromDateTime(time)));
 }
Beispiel #5
0
 /// <summary>
 /// The method gives the number of the month of the specified
 /// date.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:DateTime"/> that specifies a
 /// date.
 /// </param>
 /// <returns>An integer representing the month,
 /// starting with 1.</returns>
 public static int GetMonth(DateTime time)
 {
     return(month_from_fixed(CCFixed.FromDateTime(time)));
 }
Beispiel #6
0
 /// <summary>
 /// Gets the of the month from <paramref name="time"/>.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:DateTime"/> that specifies a
 /// date.
 /// </param>
 /// <returns>An integer giving the day of months, starting with 1.
 /// </returns>
 public static int GetDayOfMonth(DateTime time)
 {
     return(day_from_fixed(CCFixed.FromDateTime(time)));
 }
Beispiel #7
0
        public override DayOfWeek GetDayOfWeek(DateTime time)
        {
            int rd = CCFixed.FromDateTime(time);

            return((DayOfWeek)CCFixed.day_of_week(rd));
        }