/// <summary> /// Returns a string of the current Hebrew month such as "Tishrei". Returns a string of the current Hebrew month such /// as "אדר ב׳". /// </summary> /// <param name="jewishDate"> /// the JewishDate to format </param> /// <returns> the formatted month name </returns> /// <seealso cref= #isHebrewFormat() </seealso> /// <seealso cref= #setHebrewFormat(boolean) </seealso> /// <seealso cref= #getTransliteratedMonthList() </seealso> /// <seealso cref= #setTransliteratedMonthList(String[]) </seealso> public virtual string formatMonth(DateTime dt) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int month = jewishDate.getJewishMonth(); JewishCalendar.JewishMonth month = jewishCalendar.GetJewishMonth(dt); bool isLeapYear = jewishCalendar.IsLeapYearFromDateTime(dt); if (HebrewFormat) { if (isLeapYear && month == JewishCalendar.JewishMonth.ADAR) { return(hebrewMonths[13] + (useGershGershayim ? GERESH : "")); // return Adar I, not Adar in a leap year } else if (isLeapYear && month == JewishCalendar.JewishMonth.ADAR_II) { return(hebrewMonths[12] + (useGershGershayim ? GERESH : "")); } else { return(hebrewMonths[(int)month - 1]); } } else { if (isLeapYear && month == JewishCalendar.JewishMonth.ADAR) { return(transliteratedMonths[13]); // return Adar I, not Adar in a leap year } else { return(transliteratedMonths[(int)month - 1]); } } }
public virtual string formatRoshChodesh(DateTime dt) { if (!jewishCalendar.IsRoshChodesh(dt)) { return(""); } string formattedRoshChodesh = ""; int dayOfMonth = jewishCalendar.GetDayOfMonth(dt); JewishCalendar.JewishMonth month = jewishCalendar.GetJewishMonth(dt); int year = jewishCalendar.GetYear(dt); bool isLeapYear = jewishCalendar.IsLeapYearFromDateTime(dt); if (dayOfMonth == 30) { if (month < JewishCalendar.JewishMonth.ADAR || (month == JewishCalendar.JewishMonth.ADAR && isLeapYear)) { month++; } // roll to Nissan else { month = JewishCalendar.JewishMonth.NISSAN; } } DateTime updatedDateTime = jewishCalendar.GetJewishDateTime(year, month, dayOfMonth); // This method is only about formatting, so we shouldn't make any changes to the params passed in... formattedRoshChodesh = hebrewFormat ? hebrewHolidays[(int)JewishCalendar.JewishHoliday.ROSH_CHODESH] : transliteratedHolidays[(int)JewishCalendar.JewishHoliday.ROSH_CHODESH]; formattedRoshChodesh += " " + formatMonth(updatedDateTime); return(formattedRoshChodesh); }