A class encapsulating the functions of the Gregorian calendar as static methods.

This class is not compatible to T:Globalization.GregorianCalendar.

The fixed day number is also known as R.D. - rata die. Midnight at the onset of Monday, January 1, year 1 (Gregorian) is R.D. 1.

T:CCFixed
Beispiel #1
0
 /// <summary>
 /// Overridden. Gives the number of days of the specified
 /// year of the given era.
 /// </summary>
 /// <param name="year">An integer that specifies the year.
 /// </param>
 /// <param name="era">An ineger that specifies the era.
 /// </param>
 /// <returns>An integer that gives the number of days of the
 /// specified year.</returns>
 /// <exception cref="T:System.ArgumentOutOfRangeExceiption">
 /// The exception is thrown, if
 /// <paramref name="year"/> is outside the allowed range.
 /// </exception>
 public override int GetDaysInYear(int year, int era)
 {
     M_CheckYE(year, ref era);
     return(CCGregorianCalendar.GetDaysInYear(year));
 }
Beispiel #2
0
 /// <summary>
 /// Overridden. Adds years to a given date.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:System.DateTime"/> to which to add
 /// years.
 /// </param>
 /// <param name="years">The number of years to add.</param>
 /// <returns>A new <see cref="T:System.DateTime"/> value, that
 /// results from adding <paramref name="years"/> to the specified
 /// DateTime.</returns>
 public override DateTime AddYears(DateTime time, int years)
 {
     return(CCGregorianCalendar.AddYears(time, years));
 }
Beispiel #3
0
	/// <summary>
	/// Overridden. Tells whether the given day 
	/// is a leap day.
	/// </summary>
	/// <param name="year">An integer that specifies the year in the
	/// given era.
	/// </param>
	/// <param name="month">An integer that specifies the month.
	/// </param>
	/// <param name="day">An integer that specifies the day.
	/// </param>
	/// <param name="era">An integer that specifies the era.
	/// </param>
	/// <returns>A boolean that tells whether the given day is a leap
	/// day.
	/// </returns>
	/// <exception cref="T:System.ArgumentOutOfRangeException">
	/// The exception is thrown, if the year, month, day, or era is not
	/// valid.
	/// </exception>
	public override bool IsLeapDay(int year, int month, int day, int era)
	{
		int gregorianYear = M_CheckYMDEG(year, month, day, ref era);
		return CCGregorianCalendar.IsLeapDay(gregorianYear, month, day);
	}
Beispiel #4
0
	/// <summary>
	/// Static constructor, who creates and initializes
	/// <see cref="F:M_EraHandler"/>.
	/// </summary>
	static TaiwanCalendar() {
		M_EraHandler = new CCGregorianEraHandler();
		M_EraHandler.appendEra(1,
			CCGregorianCalendar.fixed_from_dmy(1, 1, 1912));
	}
Beispiel #5
0
	/// <summary>
	/// Overridden. Adds years to a given date.
	/// </summary>
	/// <param name="time">The
	/// <see cref="T:System.DateTime"/> to which to add
	/// years.
	/// </param>
	/// <param name="years">The number of years to add.</param>
	/// <returns>A new <see cref="T:System.DateTime"/> value, that
	/// results from adding <paramref name="years"/> to the specified
	/// DateTime.</returns>
	/// <exception cref="T:System.ArgumentOutOfRangeException">
	/// The exception is thrown if
	/// <see cref="T:System.DateTime"/> return value is outside all
	/// supported eras.
	/// </exception>
	public override DateTime AddYears(DateTime time, int years) {
		DateTime t = CCGregorianCalendar.AddYears(time, years);
		M_CheckDateTime(t);
		return t;
	}
Beispiel #6
0
	/// <summary>
	/// Overridden. Gives the number of days in the specified month
	/// of the given year and era.
	/// </summary>
	/// <param name="year">An integer that gives the year.
	/// </param>
	/// <param name="month">An integer that gives the month, starting
	/// with 1.</param>
	/// <param name="era">An integer that gives the era of the specified
	/// year.</param>
	/// <returns>An integer that gives the number of days of the
	/// specified month.</returns>
	/// <exception cref="T:System.ArgumentOutOfRangeException">
	/// The exception is thrown, if <paramref name="month"/>,
	/// <paramref name="year"/> ,or <paramref name="era"/> is outside
	/// the allowed range.
	/// </exception>
	public override int GetDaysInMonth(int year, int month, int era) {
		int gregorianYear = M_CheckYMEG(year, month, ref era);
		return CCGregorianCalendar.GetDaysInMonth(gregorianYear, month);
	}
Beispiel #7
0
 public static int GetYear(DateTime time)
 {
     return(CCGregorianCalendar.year_from_fixed(CCFixed.FromDateTime(time)));
 }
Beispiel #8
0
 /// <summary>
 /// Static constructor, who creates and initializes
 /// <see cref="F:M_EraHandler"/>.
 /// </summary>
 static ThaiBuddhistCalendar()
 {
     M_EraHandler = new CCGregorianEraHandler();
     M_EraHandler.appendEra(ThaiBuddhistEra,
                            CCGregorianCalendar.fixed_from_dmy(1, 1, -542));
 }
Beispiel #9
0
 public static int days_remaining(int day, int month, int year)
 {
     return(CCGregorianCalendar.date_difference(day, month, year, 31, 12, year));
 }
Beispiel #10
0
 public static int GetMonth(DateTime time)
 {
     return(CCGregorianCalendar.month_from_fixed(CCFixed.FromDateTime(time)));
 }
Beispiel #11
0
 /// <summary>
 /// Static constructor, who creates and initializes
 /// <see cref="F:M_EraHandler"/>.
 /// </summary>
 static KoreanCalendar()
 {
     M_EraHandler = new CCGregorianEraHandler();
     M_EraHandler.appendEra(KoreanEra,
                            CCGregorianCalendar.fixed_from_dmy(1, 1, -2332));
 }
Beispiel #12
0
 /// <summary>
 /// Overridden. Tells whether the given year
 /// is a leap year.
 /// </summary>
 /// <param name="year">An integer that specifies the year in the
 /// given era.
 /// </param>
 /// <param name="era">An integer that specifies the era.
 /// </param>
 /// <returns>A boolean that tells whether the given year is a leap
 /// year.
 /// </returns>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 /// The exception is thrown, if the year or era is not
 /// valid.
 /// </exception>
 public override bool IsLeapYear(int year, int era)
 {
     M_CheckYE(year, ref era);
     return(CCGregorianCalendar.is_leap_year(year));
 }
Beispiel #13
0
 /// <summary>
 /// Overridden. Tells whether the given day
 /// is a leap day.
 /// </summary>
 /// <param name="year">An integer that specifies the year in the
 /// given era.
 /// </param>
 /// <param name="month">An integer that specifies the month.
 /// </param>
 /// <param name="day">An integer that specifies the day.
 /// </param>
 /// <param name="era">An integer that specifies the era.
 /// </param>
 /// <returns>A boolean that tells whether the given day is a leap
 /// day.
 /// </returns>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 /// The exception is thrown, if the year, month, day, or era is not
 /// valid.
 /// </exception>
 public override bool IsLeapDay(int year, int month, int day, int era)
 {
     M_CheckYMDE(year, month, day, ref era);
     return(CCGregorianCalendar.IsLeapDay(year, month, day));
 }
Beispiel #14
0
 /// <summary>
 /// Overridden. Gives the number of the day in the year.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:System.DateTime"/> that specifies a
 /// date.
 /// </param>
 /// <returns>An integer representing the day of the year,
 /// starting with 1.</returns>
 public override int GetDayOfYear(DateTime time)
 {
     return(CCGregorianCalendar.GetDayOfYear(time));
 }
Beispiel #15
0
 public static bool IsLeapDay(int year, int month, int day)
 {
     return(CCGregorianCalendar.is_leap_year(year) && month == 2 && day == 29);
 }
Beispiel #16
0
 /// <summary>
 /// Overridden. Gives the number of the month of the specified
 /// date.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:System.DateTime"/> that specifies a
 /// date.
 /// </param>
 /// <returns>An integer representing the month,
 /// starting with 1.</returns>
 public override int GetMonth(DateTime time)
 {
     return(CCGregorianCalendar.GetMonth(time));
 }
Beispiel #17
0
 public static DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int milliseconds)
 {
     return(CCFixed.ToDateTime(CCGregorianCalendar.fixed_from_dmy(day, month, year), hour, minute, second, (double)milliseconds));
 }
Beispiel #18
0
	/// <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
	/// <see cref="T:System.DateTime"/> return value is outside all
	/// supported eras.
	/// </exception>
	public override DateTime AddMonths(DateTime time, int months) {
		DateTime t = CCGregorianCalendar.AddMonths(time, months);
		M_CheckDateTime(t);
		return t;
	}
Beispiel #19
0
 public static void dmy_from_fixed(out int day, out int month, out int year, int date)
 {
     CCGregorianCalendar.my_from_fixed(out month, out year, date);
     day = date - CCGregorianCalendar.fixed_from_dmy(1, month, year) + 1;
 }
Beispiel #20
0
	/// <summary>
	/// Overridden. Gives the number of the day in the year.
	/// </summary>
	/// <param name="time">The
	/// <see cref="T:System.DateTime"/> that specifies a
	/// date.
	/// </param>
	/// <returns>An integer representing the day of the year,
	/// starting with 1.</returns>
	/// <exception cref="T:System.ArgumentOutOfRangeException">
	/// The exception is thrown if the
	/// <see cref="T:System.DateTime"/> parameter is outside all
	/// supported eras.
	/// </exception>
	public override int GetDayOfYear(DateTime time) {
		M_CheckDateTime(time);
		return CCGregorianCalendar.GetDayOfYear(time);
	}
Beispiel #21
0
 public static int date_difference(int dayA, int monthA, int yearA, int dayB, int monthB, int yearB)
 {
     return(CCGregorianCalendar.fixed_from_dmy(dayB, monthB, yearB) - CCGregorianCalendar.fixed_from_dmy(dayA, monthA, yearA));
 }
Beispiel #22
0
	/// <summary>
	/// Overridden. Gives the number of days of the specified
	/// year of the given era. 
	/// </summary>
	/// <param name="year">An integer that specifies the year. 
	/// </param>
	/// <param name="era">An ineger that specifies the era.
	/// </param>
	/// <returns>An integer that gives the number of days of the
	/// specified year.</returns>
	/// <exception cref="T:System.ArgumentOutOfRangeExceiption">
	/// The exception is thrown, if
	/// <paramref name="year"/> or <paramref name="era"/> are outside the
	/// allowed range.
	/// </exception>
	public override int GetDaysInYear(int year, int era) {
		int gregorianYear = M_CheckYEG(year, ref era);
		return CCGregorianCalendar.GetDaysInYear(gregorianYear);
	}
Beispiel #23
0
 public static int day_number(int day, int month, int year)
 {
     return(CCGregorianCalendar.date_difference(31, 12, year - 1, day, month, year));
 }
Beispiel #24
0
	/// <summary>
	/// Overridden. Tells whether the given year
	/// is a leap year.
	/// </summary>
	/// <param name="year">An integer that specifies the year in the
	/// given era.
	/// </param>
	/// <param name="era">An integer that specifies the era.
	/// </param>
	/// <returns>A boolean that tells whether the given year is a leap
	/// year.
	/// </returns>
	/// <exception cref="T:System.ArgumentOutOfRangeException">
	/// The exception is thrown, if the year or era is not
	/// valid.
	/// </exception>
	public override bool IsLeapYear(int year, int era) {
		int gregorianYear = M_CheckYEG(year, ref era);
		return CCGregorianCalendar.is_leap_year(gregorianYear);
	}
Beispiel #25
0
 /// <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>
 public override DateTime AddMonths(DateTime time, int months)
 {
     return(CCGregorianCalendar.AddMonths(time, months));
 }
Beispiel #26
0
 /// <summary>
 /// Overriden. Gets the day of the month from
 /// <paramref name="time"/>.
 /// </summary>
 /// <param name="time">The
 /// <see cref="T:System.DateTime"/> that specifies a
 /// date.
 /// </param>
 /// <returns>An integer giving the day of months, starting with 1.
 /// </returns>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 /// The exception is thrown if the
 /// <see cref="T:System.DateTime"/> parameter is outside all
 /// supported eras.
 /// </exception>
 public override int GetDayOfMonth(DateTime time)
 {
     M_CheckDateTime(time);
     return(CCGregorianCalendar.GetDayOfMonth(time));
 }
Beispiel #27
0
 /// <summary>
 /// Overridden. Gives the number of days in the specified month
 /// of the given year and era.
 /// </summary>
 /// <param name="year">An integer that gives the year.
 /// </param>
 /// <param name="month">An integer that gives the month, starting
 /// with 1.</param>
 /// <param name="era">An intger that gives the era of the specified
 /// year.</param>
 /// <returns>An integer that gives the number of days of the
 /// specified month.</returns>
 /// <exception cref="T:System.ArgumentOutOfRangeException">
 /// The exception is thrown, if <paramref name="month"/>,
 /// <paramref name="year"/> ,or <paramref name="era"/> is outside
 /// the allowed range.
 /// </exception>
 public override int GetDaysInMonth(int year, int month, int era)
 {
     // mscorlib doesn't check year, probably a bug; we do
     M_CheckYME(year, month, ref era);
     return(CCGregorianCalendar.GetDaysInMonth(year, month));
 }