/// <summary> /// Gets the "proper" name in Hebrew for the given Jewish Month. /// This means for a leap year, labeling each of the the 2 Adars. /// </summary> /// <param name="jYear"></param> /// <param name="jMonth"></param> /// <returns></returns> public static string GetProperMonthNameHeb(int jYear, int jMonth) { if (jMonth == 12 && JewishDateCalculations.IsJewishLeapYear(jYear)) { return("אדר ראשון"); } else { return(JewishMonthNamesHebrew[jMonth]); } }
/// <summary> /// Gets the "proper" name for the given Jewish Month. /// This means for a leap year, labeling each of the the 2 Adars. /// </summary> /// <param name="jYear"></param> /// <param name="jMonth"></param> /// <returns></returns> public static string GetProperMonthName(int jYear, int jMonth) { if (jMonth == 12 && JewishDateCalculations.IsJewishLeapYear(jYear)) { return("Adar Rishon"); } else { return(JewishMonthNamesEnglish[jMonth]); } }
/// <summary> /// Adds the given number of years to the current date and returns the new Jewish Date /// </summary> /// <param name="years"></param> /// <returns></returns> /// <remarks>If the current month is Adar Sheini and the new year is not a leap year, the month is set to Adar. /// If the current Day is the 30th of Cheshvan or Kislev and in the new year that month only has 29 days, /// the day is set to the 1st of the following month. /// </remarks> public JewishDate AddYears(int years) { int year = this._year + years, month = this._month, day = this._day; if (month == 13 && !JewishDateCalculations.IsJewishLeapYear(year)) { month = 12; } else if (month == 8 && day == 30 && !JewishDateCalculations.IsLongCheshvan(year)) { month = 9; day = 1; } else if (month == 9 && day == 30 && JewishDateCalculations.IsShortKislev(year)) { month = 10; day = 1; } return(new JewishDate(year, month, day)); }
private Sedra(int year, bool inIsrael) { //If the last call is within the same year as this one, we reuse the data. //If memory is an issue, remove these next few lines if (_lastSedraCalculated != null && _lastSedraCalculated._year == year && _lastSedraCalculated._inIsrael == inIsrael) { this._firstSatInYear = _lastSedraCalculated._firstSatInYear; this._sedraArray = _lastSedraCalculated._sedraArray; return; } //Save the data in case the next call is for the same year _lastSedraCalculated = this; bool longCheshvon = JewishDateCalculations.IsLongCheshvan(year); bool shortKislev = JewishDateCalculations.IsShortKislev(year); int roshHashana = JewishDateCalculations.GetAbsoluteFromJewishDate(year, 7, 1); DayOfWeek roshHashanaDOW = (DayOfWeek)Math.Abs(roshHashana % 7); YearType yearType; if (longCheshvon && !shortKislev) { yearType = YearType.Complete; } else if (!longCheshvon && shortKislev) { yearType = YearType.Incomplete; } else { yearType = YearType.Regular; } this._year = year; this._inIsrael = inIsrael; /* find and save the first shabbos on or after Rosh Hashana */ this._firstSatInYear = GetDayOnOrBefore(6, roshHashana + 6); if (!JewishDateCalculations.IsJewishLeapYear(year)) { switch (roshHashanaDOW) { case DayOfWeek.Saturday: if (yearType == YearType.Incomplete) { this._sedraArray = shabbos_short; } else if (yearType == YearType.Complete) { this._sedraArray = shabbos_long; } break; case DayOfWeek.Monday: if (yearType == YearType.Incomplete) { this._sedraArray = mon_short; } else if (yearType == YearType.Complete) { this._sedraArray = this._inIsrael ? mon_short : mon_long; } break; case DayOfWeek.Tuesday: if (yearType == YearType.Regular) { this._sedraArray = this._inIsrael ? mon_short : mon_long; } break; case DayOfWeek.Thursday: if (yearType == YearType.Regular) { this._sedraArray = this._inIsrael ? thu_normal_Israel : thu_normal; } else if (yearType == YearType.Complete) { this._sedraArray = thu_long; } break; default: throw new Exception("improper sedra year type calculated."); } } else /* leap year */ { switch (roshHashanaDOW) { case DayOfWeek.Saturday: if (yearType == YearType.Incomplete) { this._sedraArray = shabbos_short_leap; } else if (yearType == YearType.Complete) { this._sedraArray = this._inIsrael ? shabbos_short_leap : shabbos_long_leap; } break; case DayOfWeek.Monday: if (yearType == YearType.Incomplete) { this._sedraArray = this._inIsrael ? mon_short_leap_Israel : mon_short_leap; } else if (yearType == YearType.Complete) { this._sedraArray = this._inIsrael ? mon_long_leap_Israel : mon_long_leap; } break; case DayOfWeek.Tuesday: if (yearType == YearType.Regular) { this._sedraArray = this._inIsrael ? mon_long_leap_Israel : mon_long_leap; } break; case DayOfWeek.Thursday: if (yearType == YearType.Incomplete) { this._sedraArray = thu_short_leap; } else if (yearType == YearType.Complete) { this._sedraArray = thu_long_leap; } break; default: throw new Exception("improper sedra year type calculated."); } } }
/// <summary> /// Returns true if the given day is a special day or a fast day, /// but not Shabbos or a major Yom Tov in the given location. /// </summary> /// <param name="jd"></param> /// <param name="location"></param> /// <returns></returns> public static bool IsMinorYomTovOrFast(JewishDate jd, Location location) { DayOfWeek dow = jd.DayOfWeek; int day = jd.Day, month = jd.Month, year = jd.Year; if (dow == DayOfWeek.Saturday || IsMajorYomTov(jd, location)) { return(false); } if (day.In(30, 1)) { return(true); } switch (month) { case 1: return(day == 14); case 2: return(day.In(14, 18)); case 4: return((day == 17 && dow != DayOfWeek.Saturday) || (day == 18 && dow == DayOfWeek.Sunday)); case 5: return((day == 9 && dow != DayOfWeek.Saturday) || (day == 10 && dow == DayOfWeek.Sunday) || day == 15); case 6: return(day == 29); case 7: return(((day == 3 && dow != DayOfWeek.Saturday) || (day == 4 && dow == DayOfWeek.Sunday)) || day == 9); case 9: return(day > 24); case 10: if (day < 4) { return(JewishDateCalculations.IsShortKislev(year) || (day < 3)); } else { return(day == 10); } case 11: return(day == 15); case 12: case 13: if (month == 12 && JewishDateCalculations.IsJewishLeapYear(year)) { return(day.In(14, 15)); } else { return ((day == 11 && dow == DayOfWeek.Thursday) || (day == 13 && dow != DayOfWeek.Saturday) || (day.In(14, 15))); } default: return(false); } }
/// <summary> /// Gets a list of special days and information about the given Jewish Date /// </summary> /// <param name="jDate"></param> /// <param name="inIsrael"></param> /// <returns></returns> /// <remarks>We use an ArrayList rather than a generic List to accommodate /// the .NET Micro framework which does not support generic lists. /// For regular projects just use as follows: GetHolidays(jDate, inIsrael).Cast<JewishCalendar.SpecialDay>() /// </remarks> public static ArrayList GetHolidays(JewishDate jDate, bool inIsrael) { var list = new ArrayList(); int jYear = jDate.Year; int jMonth = jDate.Month; int jDay = jDate.Day; DayOfWeek dayOfWeek = jDate.DayOfWeek; bool isLeapYear = JewishDateCalculations.IsJewishLeapYear(jYear); DateTime secDate = jDate.GregorianDate; if (dayOfWeek == DayOfWeek.Friday) { list.Add(new SpecialDay("Erev Shabbos", "ערב שבת", SpecialDayTypes.Information | SpecialDayTypes.HasCandleLighting)); } else if (dayOfWeek == DayOfWeek.Saturday) { AddShabbosSpecialDays(jDate, inIsrael, list, isLeapYear); } AddRoshChodeshSpecialDays(list, jYear, jMonth, jDay, isLeapYear); //V'sain Tal U'Matar in Chutz La'aretz is according to the secular date if (secDate.Month == 12 && secDate.Day.In(5, 6) && !inIsrael) { bool nextYearIsLeap = JewishDateCalculations.IsJewishLeapYear(jYear + 1); if (((secDate.Day == 5 && !nextYearIsLeap)) || (secDate.Day == 6 && nextYearIsLeap)) { list.Add(new SpecialDay("V'sain Tal U'Matar", "ותן טל ומטר")); } } switch (jMonth) { case 1: //Nissan AddNissanSpecialDays(inIsrael, list, jDay, dayOfWeek); break; case 2: //Iyar AddIyarSpecialDays(list, jDay, dayOfWeek); break; case 3: //Sivan AddSivanSpecialDays(inIsrael, list, jDay, dayOfWeek); break; case 4: //Tamuz AddTamuzSpecialDays(list, jDay, dayOfWeek); break; case 5: //Av AddAvSpecialDays(list, jDay, dayOfWeek); break; case 6: //Ellul AddEllulSpecialDays(list, jDay, dayOfWeek); break; case 7: //Tishrei AddTishreiSpecialDays(inIsrael, list, jDay, dayOfWeek); break; case 8: //Cheshvan AddCheshvanSpecialDays(inIsrael, list, jDay, dayOfWeek); break; case 9: //Kislev AddKislevSpecialDays(list, jDay); break; case 10: //Teves AddTevesSpecialDays(list, jYear, jDay); break; case 11: //Shvat AddShvatSpecialDays(list, jDay); break; case 12: //Adars case 13: AddAdarSpecialDays(list, jMonth, jDay, dayOfWeek, isLeapYear); break; } if ((jMonth == 1 && jDay > 15) || jMonth == 2 || (jMonth == 3 && jDay < 6)) { int dayOfSefirah = jDate.GetDayOfOmer(); if (dayOfSefirah > 0) { list.Add(new SpecialDay("Sefiras Ha'omer - Day " + dayOfSefirah.ToString(), "ספירת העומר - יום " + dayOfSefirah.ToString())); } } //Remove any candle lighting added by a YomTov from Shabbos.... if (dayOfWeek == DayOfWeek.Saturday) { foreach (SpecialDay sd in list) { if (sd.DayType.IsSpecialDayType(SpecialDayTypes.HasCandleLighting)) { sd.DayType = (SpecialDayTypes)(sd.DayType - SpecialDayTypes.HasCandleLighting); } } } return(list); }