private static void AddTevesSpecialDays(ArrayList list, int jYear, int jDay) { if (JewishDateCalculations.IsShortKislev(jYear)) { if (jDay == 1) { list.Add(new SpecialDay("Chanuka - Six Candles", "'חנוכה - נר ו", SpecialDayTypes.MinorYomtov)); } else if (jDay == 2) { list.Add(new SpecialDay("Chanuka - Seven Candles", "'חנוכה - נר ז", SpecialDayTypes.MinorYomtov)); } else if (jDay == 3) { list.Add(new SpecialDay("Chanuka - Eight Candles", "'חנוכה - נר ח", SpecialDayTypes.MinorYomtov)); } } else { if (jDay == 1) { list.Add(new SpecialDay("Chanuka - Seven Candles", "'חנוכה - נר ז", SpecialDayTypes.MinorYomtov)); } else if (jDay == 2) { list.Add(new SpecialDay("Chanuka - Eight Candles", "'חנוכה - נר ח", SpecialDayTypes.MinorYomtov)); } } if (jDay == 10) { list.Add(new SpecialDay("Fast - 10th of Teves", "צום עשרה בטבת", SpecialDayTypes.FastDay)); } }
/// <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); } }