Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <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]);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns a String of the Omer day in the form &#x5DC;&#x5F4;&#x5D2; &#x5D1;&#x05E2;&#x05D5;&#x05DE;&#x5E8; 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 &#x5D1;&#x5F3; prefix that would output &#x5D1;&#x05E2;&#x05D5;&#x05DE;&#x5E8;, but this
        ///         can be set via the <seealso cref="#setHebrewOmerPrefix(String)"/> method to use a &#x5DC; and output
        ///         &#x5DC;&#x5F4;&#x5D2; &#x5DC;&#x05E2;&#x05D5;&#x05DE;&#x5E8;. </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);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// If the formatter is set to format in Hebrew, returns a string of the current parsha(ios) in Hebrew for example
        /// &#x05D1;&#x05E8;&#x05D0;&#x05E9;&#x05D9;&#x05EA; or &#x05E0;&#x05D9;&#x05E6;&#x05D1;&#x05D9;&#x05DD;
        /// &#x05D5;&#x05D9;&#x05DC;&#x05DA; 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 &#x05D1;&#x05E8;&#x05D0;&#x05E9;&#x05D9;&#x05EA; or
        ///         &#x05E0;&#x05D9;&#x05E6;&#x05D1;&#x05D9;&#x05DD; &#x05D5;&#x05D9;&#x05DC;&#x05DA; 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]);
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
 /// <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];
 }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
 /// <summary>
 /// If the formatter is set to format in Hebrew, returns a string of the current parsha(ios) in Hebrew for example
 /// &#x05D1;&#x05E8;&#x05D0;&#x05E9;&#x05D9;&#x05EA; or &#x05E0;&#x05D9;&#x05E6;&#x05D1;&#x05D9;&#x05DD;
 /// &#x05D5;&#x05D9;&#x05DC;&#x05DA; 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 &#x05D1;&#x05E8;&#x05D0;&#x05E9;&#x05D9;&#x05EA; or
 ///         &#x05E0;&#x05D9;&#x05E6;&#x05D1;&#x05D9;&#x05DD; &#x05D5;&#x05D9;&#x05DC;&#x05DA; 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];
 }
Exemplo n.º 10
0
 /// <summary>
 /// Returns a String of the Omer day in the form &#x5DC;&#x5F4;&#x5D2; &#x5D1;&#x05E2;&#x05D5;&#x05DE;&#x5E8; 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 &#x5D1;&#x5F3; prefix that would output &#x5D1;&#x05E2;&#x05D5;&#x05DE;&#x5E8;, but this
 ///         can be set via the <seealso cref="#setHebrewOmerPrefix(String)"/> method to use a &#x5DC; and output
 ///         &#x5DC;&#x5F4;&#x5D2; &#x5DC;&#x05E2;&#x05D5;&#x05DE;&#x5E8;. </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;
         }
     }
 }
Exemplo n.º 11
0
        /// <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;
        }