public virtual string formatRoshChodesh(JewishCalendar jewishCalendar) { if (!jewishCalendar.RoshChodesh) { return(""); } string formattedRoshChodesh = ""; int month = jewishCalendar.JewishMonth; if (jewishCalendar.JewishDayOfMonth == 30) { if (month < JewishCalendar.ADAR || (month == JewishCalendar.ADAR && jewishCalendar.JewishLeapYear)) { month++; } // roll to Nissan else { month = JewishCalendar.NISSAN; } } // This method is only about formatting, so we shouldn't make any changes to the params passed in... jewishCalendar = (JewishCalendar)jewishCalendar.Clone(); jewishCalendar.JewishMonth = month; formattedRoshChodesh = hebrewFormat ? hebrewHolidays[JewishCalendar.ROSH_CHODESH] : transliteratedHolidays[JewishCalendar.ROSH_CHODESH]; formattedRoshChodesh += " " + formatMonth(jewishCalendar); return(formattedRoshChodesh); }
/// <summary> /// Formats the Yom Tov (holiday) in Hebrew or transliterated Latin characters. /// </summary> /// <param name="jewishCalendar"> </param> /// <returns> the formatted holiday or an empty String if the day is not a holiday. </returns> /// <seealso cref= #isHebrewFormat() </seealso> public virtual string formatYomTov(JewishCalendar jewishCalendar) { int index = jewishCalendar.YomTovIndex; if (index == JewishCalendar.CHANUKAH) { int dayOfChanukah = jewishCalendar.DayOfChanukah; return(hebrewFormat ? (formatHebrewNumber(dayOfChanukah) + " " + hebrewHolidays[index]) : (transliteratedHolidays[index] + dayOfChanukah)); } return(index == -1 ? "" : hebrewFormat?hebrewHolidays[index] : transliteratedHolidays[index]); }
/// <seealso cref= Object#equals(Object) </seealso> public virtual bool Equals(object @object) { if (this == @object) { return(true); } if (!(@object is JewishCalendar)) { return(false); } JewishCalendar jewishCalendar = (JewishCalendar)@object; return(AbsDate == jewishCalendar.AbsDate && InIsrael == jewishCalendar.InIsrael); }
/// <summary> /// Returns a String of the Omer day in the form ל״ג בעומר if /// Hebrew Format is set, or "Omer X" or "Lag BaOmer" if not. An empty string if there is no Omer this day. /// </summary> /// <returns> a String of the Omer day in the form or an empty string if there is no Omer this day. The default /// formatting has a ב׳ prefix that would output בעומר, but this /// can be set via the <seealso cref="#setHebrewOmerPrefix(String)"/> method to use a ל and output /// ל״ג לעומר. </returns> /// <seealso cref= #isHebrewFormat() </seealso> /// <seealso cref= #getHebrewOmerPrefix() </seealso> /// <seealso cref= #setHebrewOmerPrefix(String) </seealso> public virtual string formatOmer(JewishCalendar jewishCalendar) { int omer = jewishCalendar.DayOfOmer; if (omer == -1) { return(""); } if (hebrewFormat) { return(formatHebrewNumber(omer) + " " + hebrewOmerPrefix + "\u05E2\u05D5\u05DE\u05E8"); } else { if (omer == 33) // if lag b'omer { return("Lag BaOmer"); } else { return("Omer " + omer); } } }
/// <summary> /// If the formatter is set to format in Hebrew, returns a string of the current parsha(ios) in Hebrew for example /// בראשית or ניצבים /// וילך or an empty string if there are none. If not set to Hebrew, it returns a string /// of the parsha(ios) transliterated into Latin chars. The default uses Ashkenazi pronunciation in typical American /// English spelling, for example Bereshis or Nitzavim Vayeilech or an empty string if there are none. /// </summary> /// <param name="jewishCalendar"> </param> /// <returns> today's parsha(ios) in Hebrew for example, if the formatter is set to format in Hebrew, returns a string /// of the current parsha(ios) in Hebrew for example בראשית or /// ניצבים וילך or an empty string if /// there are none. If not set to Hebrew, it returns a string of the parsha(ios) transliterated into Latin /// chars. The default uses Ashkenazi pronunciation in typical American English spelling, for example /// Bereshis or Nitzavim Vayeilech or an empty string if there are none. </returns> public virtual string formatParsha(JewishCalendar jewishCalendar) { int index = jewishCalendar.ParshaIndex; return(index == -1 ? "" : hebrewFormat?hebrewParshiyos[index] : transliteratedParshios[index]); }
/// <summary> /// Returns the <a href="http://en.wikipedia.org/wiki/Daf_yomi">Daf Yomi</a> <a /// href="http://en.wikipedia.org/wiki/Talmud">Bavli</a> <seealso cref="Daf"/> for a given date. The first Daf Yomi cycle /// started on Rosh Hashana 5684 (September 11, 1923) and calculations prior to this date will result in an /// IllegalArgumentException thrown. For historical calculations (supported by this method), it is important to note /// that a change in length of the cycle was instituted starting in the eighth Daf Yomi cycle beginning on June 24, /// 1975. The Daf Yomi Bavli cycle has a single masechta of the Talmud Yerushalmi - Shekalim as part of the cycle. /// Unlike the Bavli where the number of daf per masechta was standardized since the original <a /// href="http://en.wikipedia.org/wiki/Daniel_Bomberg">Bomberg Edition</a> published from 1520 - 1523, there is no /// uniform page length in the Yerushalmi. The early cycles had the Yerushalmi Shekalim length of 13 days following /// the <a href="http://en.wikipedia.org/wiki/Zhytomyr">Zhytomyr</a> Shas used by <a /// href="http://en.wikipedia.org/wiki/Meir_Shapiro">Rabbi Meir Shapiro</a>. With the start of the eighth Daf Yomi /// cycle beginning on June 24, 1975 the length of the Yerushalmi shekalim was changed from 13 to 22 daf to follow /// the Vilna Shas that is in common use today. /// </summary> /// <param name="calendar"> /// the calendar date for calculation </param> /// <returns> the <seealso cref="Daf"/>. /// </returns> /// <exception cref="IllegalArgumentException"> /// if the date is prior to the September 11, 1923 start date of the first Daf Yomi cycle </exception> public static Daf getDafYomiBavli(JewishCalendar calendar) { /* * The number of daf per masechta. Since the number of blatt in Shekalim changed on the 8th Daf Yomi cycle * beginning on June 24, 1975 from 13 to 22, the actual calculation for blattPerMasechta[4] will later be * adjusted based on the cycle. */ int[] blattPerMasechta = { 64, 157, 105, 121, 22, 88, 56, 40, 35, 31, 32, 29, 27, 122, 112, 91, 66, 49, 90, 82, 119, 119, 176, 113, 24, 49, 76, 14, 120, 110, 142, 61, 34, 34, 28, 22, 4, 10, 4, 73 }; DateTime date = calendar.Time; Daf dafYomi = null; int julianDay = getJulianDay(date); int cycleNo = 0; int dafNo = 0; if (date < dafYomiStartDate) { // TODO: should we return a null or throw an IllegalArgumentException? throw new System.ArgumentException(date + " is prior to organized Daf Yomi Bavli cycles that started on " + dafYomiStartDate); } if (date.Equals(shekalimChangeDate) || date > shekalimChangeDate) { cycleNo = 8 + ((julianDay - shekalimJulianChangeDay) / 2711); dafNo = ((julianDay - shekalimJulianChangeDay) % 2711); } else { cycleNo = 1 + ((julianDay - dafYomiJulianStartDay) / 2702); dafNo = ((julianDay - dafYomiJulianStartDay) % 2702); } int total = 0; int masechta = -1; int blatt = 0; /* Fix Shekalim for old cycles. */ if (cycleNo <= 7) { blattPerMasechta[4] = 13; } else { blattPerMasechta[4] = 22; // correct any change that may have been changed from a prior calculation } /* Finally find the daf. */ for (int j = 0; j < blattPerMasechta.Length; j++) { masechta++; total = total + blattPerMasechta[j] - 1; if (dafNo < total) { blatt = 1 + blattPerMasechta[j] - (total - dafNo); /* Fiddle with the weird ones near the end. */ if (masechta == 36) { blatt += 21; } else if (masechta == 37) { blatt += 24; } else if (masechta == 38) { blatt += 33; } dafYomi = new Daf(masechta, blatt); break; } } return(dafYomi); }
/// <summary> /// Formats the Yom Tov (holiday) in Hebrew or transliterated Latin characters. /// </summary> /// <param name="jewishCalendar"> </param> /// <returns> the formatted holiday or an empty String if the day is not a holiday. </returns> /// <seealso cref= #isHebrewFormat() </seealso> public virtual string formatYomTov(JewishCalendar jewishCalendar) { int index = jewishCalendar.YomTovIndex; if (index == JewishCalendar.CHANUKAH) { int dayOfChanukah = jewishCalendar.DayOfChanukah; return hebrewFormat ? (formatHebrewNumber(dayOfChanukah) + " " + hebrewHolidays[index]) : (transliteratedHolidays[index] + dayOfChanukah); } return index == -1 ? "" : hebrewFormat ? hebrewHolidays[index] : transliteratedHolidays[index]; }
public virtual string formatRoshChodesh(JewishCalendar jewishCalendar) { if (!jewishCalendar.RoshChodesh) { return ""; } string formattedRoshChodesh = ""; int month = jewishCalendar.JewishMonth; if (jewishCalendar.JewishDayOfMonth == 30) { if (month < JewishCalendar.ADAR || (month == JewishCalendar.ADAR && jewishCalendar.JewishLeapYear)) { month++; } // roll to Nissan else { month = JewishCalendar.NISSAN; } } // This method is only about formatting, so we shouldn't make any changes to the params passed in... jewishCalendar = (JewishCalendar)jewishCalendar.Clone(); jewishCalendar.JewishMonth = month; formattedRoshChodesh = hebrewFormat ? hebrewHolidays[JewishCalendar.ROSH_CHODESH] : transliteratedHolidays[JewishCalendar.ROSH_CHODESH]; formattedRoshChodesh += " " + formatMonth(jewishCalendar); return formattedRoshChodesh; }
/// <summary> /// If the formatter is set to format in Hebrew, returns a string of the current parsha(ios) in Hebrew for example /// בראשית or ניצבים /// וילך or an empty string if there are none. If not set to Hebrew, it returns a string /// of the parsha(ios) transliterated into Latin chars. The default uses Ashkenazi pronunciation in typical American /// English spelling, for example Bereshis or Nitzavim Vayeilech or an empty string if there are none. /// </summary> /// <param name="jewishCalendar"> </param> /// <returns> today's parsha(ios) in Hebrew for example, if the formatter is set to format in Hebrew, returns a string /// of the current parsha(ios) in Hebrew for example בראשית or /// ניצבים וילך or an empty string if /// there are none. If not set to Hebrew, it returns a string of the parsha(ios) transliterated into Latin /// chars. The default uses Ashkenazi pronunciation in typical American English spelling, for example /// Bereshis or Nitzavim Vayeilech or an empty string if there are none. </returns> public virtual string formatParsha(JewishCalendar jewishCalendar) { int index = jewishCalendar.ParshaIndex; return index == -1 ? "" : hebrewFormat ? hebrewParshiyos[index] : transliteratedParshios[index]; }
/// <summary> /// Returns a String of the Omer day in the form ל״ג בעומר if /// Hebrew Format is set, or "Omer X" or "Lag BaOmer" if not. An empty string if there is no Omer this day. /// </summary> /// <returns> a String of the Omer day in the form or an empty string if there is no Omer this day. The default /// formatting has a ב׳ prefix that would output בעומר, but this /// can be set via the <seealso cref="#setHebrewOmerPrefix(String)"/> method to use a ל and output /// ל״ג לעומר. </returns> /// <seealso cref= #isHebrewFormat() </seealso> /// <seealso cref= #getHebrewOmerPrefix() </seealso> /// <seealso cref= #setHebrewOmerPrefix(String) </seealso> public virtual string formatOmer(JewishCalendar jewishCalendar) { int omer = jewishCalendar.DayOfOmer; if (omer == -1) { return ""; } if (hebrewFormat) { return formatHebrewNumber(omer) + " " + hebrewOmerPrefix + "\u05E2\u05D5\u05DE\u05E8"; } else { if (omer == 33) // if lag b'omer { return "Lag BaOmer"; } else { return "Omer " + omer; } } }
/// <summary> /// Returns the <a href="http://en.wikipedia.org/wiki/Daf_yomi">Daf Yomi</a> <a /// href="http://en.wikipedia.org/wiki/Talmud">Bavli</a> <seealso cref="Daf"/> for a given date. The first Daf Yomi cycle /// started on Rosh Hashana 5684 (September 11, 1923) and calculations prior to this date will result in an /// IllegalArgumentException thrown. For historical calculations (supported by this method), it is important to note /// that a change in length of the cycle was instituted starting in the eighth Daf Yomi cycle beginning on June 24, /// 1975. The Daf Yomi Bavli cycle has a single masechta of the Talmud Yerushalmi - Shekalim as part of the cycle. /// Unlike the Bavli where the number of daf per masechta was standardized since the original <a /// href="http://en.wikipedia.org/wiki/Daniel_Bomberg">Bomberg Edition</a> published from 1520 - 1523, there is no /// uniform page length in the Yerushalmi. The early cycles had the Yerushalmi Shekalim length of 13 days following /// the <a href="http://en.wikipedia.org/wiki/Zhytomyr">Zhytomyr</a> Shas used by <a /// href="http://en.wikipedia.org/wiki/Meir_Shapiro">Rabbi Meir Shapiro</a>. With the start of the eighth Daf Yomi /// cycle beginning on June 24, 1975 the length of the Yerushalmi shekalim was changed from 13 to 22 daf to follow /// the Vilna Shas that is in common use today. /// </summary> /// <param name="calendar"> /// the calendar date for calculation </param> /// <returns> the <seealso cref="Daf"/>. /// </returns> /// <exception cref="IllegalArgumentException"> /// if the date is prior to the September 11, 1923 start date of the first Daf Yomi cycle </exception> public static Daf getDafYomiBavli(JewishCalendar calendar) { /* * The number of daf per masechta. Since the number of blatt in Shekalim changed on the 8th Daf Yomi cycle * beginning on June 24, 1975 from 13 to 22, the actual calculation for blattPerMasechta[4] will later be * adjusted based on the cycle. */ int[] blattPerMasechta = { 64, 157, 105, 121, 22, 88, 56, 40, 35, 31, 32, 29, 27, 122, 112, 91, 66, 49, 90, 82, 119, 119, 176, 113, 24, 49, 76, 14, 120, 110, 142, 61, 34, 34, 28, 22, 4, 10, 4, 73 }; DateTime date = calendar.Time; Daf dafYomi = null; int julianDay = getJulianDay(date); int cycleNo = 0; int dafNo = 0; if (date < dafYomiStartDate) { // TODO: should we return a null or throw an IllegalArgumentException? throw new System.ArgumentException(date + " is prior to organized Daf Yomi Bavli cycles that started on " + dafYomiStartDate); } if (date.Equals(shekalimChangeDate) || date > shekalimChangeDate) { cycleNo = 8 + ((julianDay - shekalimJulianChangeDay) / 2711); dafNo = ((julianDay - shekalimJulianChangeDay) % 2711); } else { cycleNo = 1 + ((julianDay - dafYomiJulianStartDay) / 2702); dafNo = ((julianDay - dafYomiJulianStartDay) % 2702); } int total = 0; int masechta = -1; int blatt = 0; /* Fix Shekalim for old cycles. */ if (cycleNo <= 7) { blattPerMasechta[4] = 13; } else { blattPerMasechta[4] = 22; // correct any change that may have been changed from a prior calculation } /* Finally find the daf. */ for (int j = 0; j < blattPerMasechta.Length; j++) { masechta++; total = total + blattPerMasechta[j] - 1; if (dafNo < total) { blatt = 1 + blattPerMasechta[j] - (total - dafNo); /* Fiddle with the weird ones near the end. */ if (masechta == 36) { blatt += 21; } else if (masechta == 37) { blatt += 24; } else if (masechta == 38) { blatt += 33; } dafYomi = new Daf(masechta, blatt); break; } } return dafYomi; }