/// <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); }
/// <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)); }
/// <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))); }
/// <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))); }
/// <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))); }
public override DayOfWeek GetDayOfWeek(DateTime time) { int rd = CCFixed.FromDateTime(time); return((DayOfWeek)CCFixed.day_of_week(rd)); }