///<summary>Finds the שבת of the given פרשה.</summary> ///<param name="hebrewYear">The Hebrew year to look in.</param> ///<param name="parshaIndex">The index within the Parshiyos collection of the single פרשה to find.</param> ///<returns>The שבת of the פרשה.</returns> public static HebrewDate Findפרשה(int hebrewYear, int parshaIndex) { if (parshaIndex < 0 || parshaIndex > Parshiyos.Count) { throw new ArgumentOutOfRangeException("parshaIndex"); } if (parshaIndex > 52) { throw new ArgumentOutOfRangeException("parshaIndex", "Cannot search for double פרשה."); } var roshHashana = new HebrewDate(hebrewYear, HebrewMonth.תשרי, 1); var array = parshaIndices[roshHashana]; var weekNumber = Array.IndexOf(array, parshaIndex); //If this year doesn't have the פרשה separately, find the double פרשה. //First, find the index in Parshiyos of the double פרשה's name. //Then, locate that index in the year's array. if (weekNumber == -1) { weekNumber = Array.IndexOf(array, Enumerable.Range(53, 7).First(i => Parshiyos[i].Contains(Parshiyos[parshaIndex]))); } //TODO: Years without וילך //Four year types don't have פרשת וילך. (See below) //Right now, I return פרשת וילך of the previous (!) year //(weekNumber becomes -1 because the double פרשה wasn't //found, and, coincidentally, the last week of the previous //year has וילך for all of these ParshaArrayKeys) //Maybe I should throw, maybe I should return next year, //maybe I should leave as is. //These are the troublesome ParshaArrayKeys: //True, חסר, Thursday //False, כסדרן, Thursday //False, חסר, Saturday //False, מלא, Thursday //Round ראש השנה to the next שבת before adding weeks. return(roshHashana + (6 - (int)roshHashana.DayOfWeek + weekNumber * 7)); }
internal HebrewDayInfo(HebrewDate date) { Date = date; }
///<summary>Creates a HebrewDateEventArgs from a Hebrew date.</summary> public HebrewDateEventArgs(HebrewDate date) { Date = date; }
} //Implicit cast ///<summary>Gets the last week day preceding a Hebrew date.</summary> ///<param name="date">The date.</param> ///<param name="dayOfWeek">The day of week to return.</param> ///<returns>The last dayOfWeek day preceding date, or date if it is on dayOfWeek.</returns> public static HebrewDate Last(this HebrewDate date, DayOfWeek dayOfWeek) { return(date.EnglishDate.Last(dayOfWeek)); }
///<summary>Gets the first week day following a Hebrew date.</summary> ///<param name="date">The date.</param> ///<param name="dayOfWeek">The day of week to return.</param> ///<returns>The first dayOfWeek day following date, or date if it is on dayOfWeek.</returns> public static HebrewDate Next(this HebrewDate date, DayOfWeek dayOfWeek) { return(date.EnglishDate.Next(dayOfWeek)); } //Implicit cast
public string this[HebrewDate roshHashana, int weekOfYear] { get { return(this[roshHashana.IsLeapYear, roshHashana.YearType, roshHashana.DayOfWeek, weekOfYear]); } }
public int[] this[HebrewDate roshHashana] { get { return(this[roshHashana.IsLeapYear, roshHashana.YearType, roshHashana.DayOfWeek]); } }