This class is not compatible to T:System.Globalization.HebrewCalendar.
/// <summary>Returns the year in the specified <see cref="T:System.DateTime" /> value.</summary> /// <returns>An integer that represents the year in the specified <see cref="T:System.DateTime" /> value.</returns> /// <param name="time">The <see cref="T:System.DateTime" /> to read. </param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="time" /> is outside the range supported by the current <see cref="T:System.Globalization.HebrewCalendar" /> object. </exception> public override int GetYear(DateTime time) { this.M_CheckDateTime(time); int date = CCFixed.FromDateTime(time); return(CCHebrewCalendar.year_from_fixed(date)); }
public static int fixed_from_dmy(int day, int month, int year) { int num = -1373428; num += CCHebrewCalendar.elapsed_days(year); num += CCHebrewCalendar.new_year_delay(year); if (month < 7) { int num2 = CCHebrewCalendar.last_month_of_year(year); for (int i = 7; i <= num2; i++) { num += CCHebrewCalendar.last_day_of_month(i, year); } for (int i = 1; i < month; i++) { num += CCHebrewCalendar.last_day_of_month(i, year); } } else { for (int i = 7; i < month; i++) { num += CCHebrewCalendar.last_day_of_month(i, year); } } return(num + day); }
/// <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) { M_CheckYME(year, month, ref era); int ccmonth = M_CCMonth(month, year); return(CCHebrewCalendar.last_day_of_month(ccmonth, year)); }
/// <summary> /// Overridden. Gives the number of the year of the specified /// date. /// </summary> /// <param name="time">The /// <see cref="T:System.DateTime"/> that specifies a /// date. /// </param> /// <returns>An integer representing the year, /// starting with 1.</returns> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// The exception is thrown if the /// <see cref="T:System.DateTime"/> parameter is not in the years /// between 5343 A.M. and 6000 A.M., inclusive. /// </exception> public override int GetYear(DateTime time) { M_CheckDateTime(time); int rd = CCFixed.FromDateTime(time); return(CCHebrewCalendar.year_from_fixed(rd)); }
/// <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 not in the years /// between 5343 A.M. and 6000 A.M., inclusive. /// </exception> public override int GetDayOfMonth(DateTime time) { M_CheckDateTime(time); int rd = CCFixed.FromDateTime(time); return(CCHebrewCalendar.day_from_fixed(rd)); }
public static int month_from_fixed(int date) { int result; int num; CCHebrewCalendar.my_from_fixed(out result, out num, date); return(result); }
/// <summary>Returns the number of days in the specified year in the specified era.</summary> /// <returns>The number of days in the specified year in the specified era.</returns> /// <param name="year">An integer that represents the year. </param> /// <param name="era">An integer that represents the era. Specify either <see cref="F:System.Globalization.HebrewCalendar.HebrewEra" /> or <see cref="F:System.Globalization.Calendar.CurrentEra" />.</param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="year" /> or <paramref name="era" /> is outside the range supported by the current <see cref="T:System.Globalization.HebrewCalendar" /> object. </exception> public override int GetDaysInYear(int year, int era) { this.M_CheckYE(year, ref era); int num = CCHebrewCalendar.fixed_from_dmy(1, 7, year); int num2 = CCHebrewCalendar.fixed_from_dmy(1, 7, year + 1); return(num2 - num); }
/// <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) { M_CheckYE(year, ref era); int rd1 = CCHebrewCalendar.fixed_from_dmy(1, 7, year); int rd2 = CCHebrewCalendar.fixed_from_dmy(1, 7, year + 1); return(rd2 - rd1); }
/// <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 not in the years /// between 5343 A.M. and 6000 A.M., inclusive. /// </exception> public override int GetDayOfYear(DateTime time) { M_CheckDateTime(time); int rd = CCFixed.FromDateTime(time); int year = CCHebrewCalendar.year_from_fixed(rd); int rd1_7 = CCHebrewCalendar.fixed_from_dmy(1, 7, year); return(rd - rd1_7 + 1); }
/// <summary>Returns the day of the year in the specified <see cref="T:System.DateTime" />.</summary> /// <returns>An integer from 1 to 385 that represents the day of the year in the specified <see cref="T:System.DateTime" />.</returns> /// <param name="time">The <see cref="T:System.DateTime" /> to read. </param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="time" /> is earlier than September 17, 1583 in the Gregorian calendar, or greater than <see cref="P:System.Globalization.HebrewCalendar.MaxSupportedDateTime" />. </exception> public override int GetDayOfYear(DateTime time) { this.M_CheckDateTime(time); int num = CCFixed.FromDateTime(time); int year = CCHebrewCalendar.year_from_fixed(num); int num2 = CCHebrewCalendar.fixed_from_dmy(1, 7, year); return(num - num2 + 1); }
/// <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> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// The exception is thrown if the /// <see cref="T:System.DateTime"/> parameter is not in the years /// between 5343 A.M. and 6000 A.M., inclusive. /// </exception> public override int GetMonth(DateTime time) { M_CheckDateTime(time); int rd = CCFixed.FromDateTime(time); int ccmonth, year; CCHebrewCalendar.my_from_fixed(out ccmonth, out year, rd); return(M_Month(ccmonth, year)); }
public static int day_from_fixed(int date) { int result; int num; int num2; CCHebrewCalendar.dmy_from_fixed(out result, out num, out num2, date); return(result); }
/// <summary>Returns a <see cref="T:System.DateTime" /> that is set to the specified date and time in the specified era.</summary> /// <returns>The <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</returns> /// <param name="year">An integer that represents the year. </param> /// <param name="month">An integer from 1 to 13 that represents the month. </param> /// <param name="day">An integer from 1 to 30 that represents the day. </param> /// <param name="hour">An integer from 0 to 23 that represents the hour. </param> /// <param name="minute">An integer from 0 to 59 that represents the minute. </param> /// <param name="second">An integer from 0 to 59 that represents the second. </param> /// <param name="millisecond">An integer from 0 to 999 that represents the millisecond. </param> /// <param name="era">An integer that represents the era. Specify either <see cref="F:System.Globalization.HebrewCalendar.HebrewEra" /> or <see cref="F:System.Globalization.Calendar.CurrentEra" />.</param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="year" />, <paramref name="month" />, <paramref name="day" /> or <paramref name="era" /> is outside the range supported by the current <see cref="T:System.Globalization.HebrewCalendar" /> object.-or- <paramref name="hour" /> is less than 0 or greater than 23.-or- <paramref name="minute" /> is less than 0 or greater than 59.-or- <paramref name="second" /> is less than 0 or greater than 59.-or- <paramref name="millisecond" /> is less than 0 or greater than 999. </exception> public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era) { this.M_CheckYMDE(year, month, day, ref era); base.M_CheckHMSM(hour, minute, second, millisecond); int month2 = this.M_CCMonth(month, year); int date = CCHebrewCalendar.fixed_from_dmy(day, month2, year); return(CCFixed.ToDateTime(date, hour, minute, second, (double)millisecond)); }
/// <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 the /// <see cref="T:System.DateTime"/> return value is not in the years /// between 5343 A.M. and 6000 A.M., inclusive. /// </exception> public override DateTime AddMonths(DateTime time, int months) { int y, m, d; DateTime t; if (months == 0) { t = time; } else { int rd = CCFixed.FromDateTime(time); CCHebrewCalendar.dmy_from_fixed( out d, out m, out y, rd); m = M_Month(m, y); if (months < 0) { while (months < 0) { if (m + months > 0) { m += months; months = 0; } else { months += m; y -= 1; m = GetMonthsInYear(y); } } } else { while (months > 0) { int my = GetMonthsInYear(y); if (m + months <= my) { m += months; months = 0; } else { months -= my - m + 1; m = 1; y += 1; } } } t = ToDateTime(y, m, d, 0, 0, 0, 0); t = t.Add(time.TimeOfDay); } M_CheckDateTime(t); return(t); }
/// <summary>Returns a <see cref="T:System.DateTime" /> that is the specified number of months away from the specified <see cref="T:System.DateTime" />.</summary> /// <returns>The <see cref="T:System.DateTime" /> that results from adding the specified number of months to the specified <see cref="T:System.DateTime" />.</returns> /// <param name="time">The <see cref="T:System.DateTime" /> to which to add <paramref name="months" />. </param> /// <param name="months">The number of months to add. </param> /// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="months" /> is less than -120,000 or greater than 120,000. </exception> public override DateTime AddMonths(DateTime time, int months) { DateTime dateTime; if (months == 0) { dateTime = time; } else { int date = CCFixed.FromDateTime(time); int day; int num; int num2; CCHebrewCalendar.dmy_from_fixed(out day, out num, out num2, date); num = this.M_Month(num, num2); if (months < 0) { while (months < 0) { if (num + months > 0) { num += months; months = 0; } else { months += num; num2--; num = this.GetMonthsInYear(num2); } } } else { while (months > 0) { int monthsInYear = this.GetMonthsInYear(num2); if (num + months <= monthsInYear) { num += months; months = 0; } else { months -= monthsInYear - num + 1; num = 1; num2++; } } } dateTime = this.ToDateTime(num2, num, day, 0, 0, 0, 0).Add(time.TimeOfDay); } this.M_CheckDateTime(dateTime); return(dateTime); }
/// <summary>Returns the month in the specified <see cref="T:System.DateTime" />.</summary> /// <returns>An integer from 1 to 13 that represents the month in the specified <see cref="T:System.DateTime" />.</returns> /// <param name="time">The <see cref="T:System.DateTime" /> to read. </param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="time" /> is less than <see cref="P:System.Globalization.HebrewCalendar.MinSupportedDateTime" /> or greater than <see cref="P:System.Globalization.HebrewCalendar.MaxSupportedDateTime" />.</exception> public override int GetMonth(DateTime time) { this.M_CheckDateTime(time); int date = CCFixed.FromDateTime(time); int ccmonth; int year; CCHebrewCalendar.my_from_fixed(out ccmonth, out year, date); return(this.M_Month(ccmonth, year)); }
internal int M_Month(int ccmonth, int year) { if (ccmonth >= 7) { return(ccmonth - 6); } int num = CCHebrewCalendar.last_month_of_year(year); return(ccmonth + ((num != 12) ? 7 : 6)); }
public static int year_from_fixed(int date) { int num = (int)Math.Floor((double)(date - -1373427) / 365.24682220597794); int num2 = num; while (date >= CCHebrewCalendar.fixed_from_dmy(1, 7, num2)) { num2++; } return(num2 - 1); }
public static void my_from_fixed(out int month, out int year, int date) { year = CCHebrewCalendar.year_from_fixed(date); int num = (date >= CCHebrewCalendar.fixed_from_dmy(1, 1, year)) ? 1 : 7; month = num; while (date > CCHebrewCalendar.fixed_from_dmy(CCHebrewCalendar.last_day_of_month(month, year), month, year)) { month++; } }
internal void M_CheckYME(int year, int month, ref int era) { this.M_CheckYE(year, ref era); int num = CCHebrewCalendar.last_month_of_year(year); if (month < 1 || month > num) { StringWriter stringWriter = new StringWriter(); stringWriter.Write("Month must be between 1 and {0}.", num); throw new ArgumentOutOfRangeException("month", stringWriter.ToString()); } }
/// <summary> /// Overridden. Creates the /// <see cref="T:System.DateTime"/> from the parameters. /// </summary> /// <param name="year">An integer that gives the year in the /// <paramref name="era"/>. /// </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> /// <param name="era">An integer that specifies the era. /// </param> /// <returns>A /// <see cref="T:system.DateTime"/> representig the date and time. /// </returns> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// The exception is thrown, if at least one of the parameters /// is out of range. /// </exception> public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int milliseconds, int era) { M_CheckYMDE(year, month, day, ref era); M_CheckHMSM(hour, minute, second, milliseconds); int ccm = M_CCMonth(month, year); int rd = CCHebrewCalendar.fixed_from_dmy(day, ccm, year); return(CCFixed.ToDateTime(rd, hour, minute, second, milliseconds)); }
/// <summary> /// The method maps a Calendrical Calculations Hebrew month /// to a .NET Hebrew month. /// </summary> /// <param name="ccmonth">An integer representing a month in /// Calendrical Calculations counting, starting with Nisan. /// </param> /// <param name="year">An integer representing the Hebrew year. /// </param> /// <returns>The Hebrew month in .NET counting, /// staring with the Hebrew month Tishri. /// </returns> /// <remarks> /// <para> /// In .NET the month counting starts with the Hebrew month Tishri. /// Calendrical Calculations starts with the month Tisan. So we must /// map here. /// </para> /// </remarks> internal int M_Month(int ccmonth, int year) { if (ccmonth >= 7) { return(ccmonth - 6); } else { int l = CCHebrewCalendar.last_month_of_year(year); return(ccmonth + (l == 12 ? 6 : 7)); } }
internal int M_CCMonth(int month, int year) { if (month <= 6) { return(6 + month); } int num = CCHebrewCalendar.last_month_of_year(year); if (num == 12) { return(month - 6); } return((month > 7) ? (month - 7) : (6 + month)); }
/// <summary>Returns a <see cref="T:System.DateTime" /> that is the specified number of years away from the specified <see cref="T:System.DateTime" />.</summary> /// <returns>The <see cref="T:System.DateTime" /> that results from adding the specified number of years to the specified <see cref="T:System.DateTime" />.</returns> /// <param name="time">The <see cref="T:System.DateTime" /> to which to add <paramref name="years" />. </param> /// <param name="years">The number of years to add. </param> /// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception> public override DateTime AddYears(DateTime time, int years) { int date = CCFixed.FromDateTime(time); int day; int month; int num; CCHebrewCalendar.dmy_from_fixed(out day, out month, out num, date); num += years; date = CCHebrewCalendar.fixed_from_dmy(day, month, num); DateTime dateTime = CCFixed.ToDateTime(date).Add(time.TimeOfDay); this.M_CheckDateTime(dateTime); return(dateTime); }
/// <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 the /// <see cref="T:System.DateTime"/> return value is not in the years /// between 5343 A.M. and 6000 A.M., inclusive. /// </exception> public override DateTime AddYears(DateTime time, int years) { int rd = CCFixed.FromDateTime(time); int day, month, year; CCHebrewCalendar.dmy_from_fixed( out day, out month, out year, rd); year += years; rd = CCHebrewCalendar.fixed_from_dmy(day, month, year); DateTime t = CCFixed.ToDateTime(rd); t = t.Add(time.TimeOfDay); M_CheckDateTime(t); return(t); }
public static int new_year_delay(int year) { int num = CCHebrewCalendar.elapsed_days(year); int num2 = CCHebrewCalendar.elapsed_days(year + 1); if (num2 - num == 356) { return(2); } int num3 = CCHebrewCalendar.elapsed_days(year - 1); if (num - num3 == 382) { return(1); } return(0); }
public static int last_day_of_month(int month, int year) { if (month < 1 || month > 13) { throw new ArgumentOutOfRangeException("month", "Month should be between One and Thirteen."); } switch (month) { case 2: return(29); case 4: return(29); case 6: return(29); case 8: if (!CCHebrewCalendar.long_heshvan(year)) { return(29); } break; case 9: if (CCHebrewCalendar.short_kislev(year)) { return(29); } break; case 10: return(29); case 12: if (!CCHebrewCalendar.is_leap_year(year)) { return(29); } break; case 13: return(29); } return(30); }
/// <summary> /// The method maps a .NET Hebrew month to a Calencdrical /// Calculations Hebrew month. /// </summary> /// <param name="month">An integer representing a month in .NET /// counting (starting with Tishri). /// </param> /// <param name="year">An integer representing the Hebrew year. /// </param> /// <returns>The Hebrew month in Calendrical Calculations counting, /// staring with the Hebrew month Nisan. /// </returns> /// <remarks> /// <para> /// In .NET the month counting starts with the Hebrew month Tishri. /// Calendrical Calculations starts with the month Nisan. So we must /// map here. /// </para> /// </remarks> internal int M_CCMonth(int month, int year) { if (month <= 6) { return(6 + month); } else { int l = CCHebrewCalendar.last_month_of_year(year); if (l == 12) { return(month - 6); } else { return(month <= 7 ? 6 + month : month - 7); } } }
/// <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(CCHebrewCalendar.is_leap_year(year)); }
/// <summary> /// Overridden. Gives the number of months in the specified year /// and era. /// </summary> /// <param name="year">An integer that specifies the year. /// </param> /// <param name="era">An integer that specifies the era. /// </param> /// <returns>An integer that gives the number of the months in the /// specified year.</returns> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// The exception is thrown, if the year or the era are not valid. /// </exception> public override int GetMonthsInYear(int year, int era) { M_CheckYE(year, ref era); return(CCHebrewCalendar.last_month_of_year(year)); }