private void NavigateToMonth(JewishDate jd) { int day = 0; if (this._selectedDay != null) { day = this._selectedDay.Day; } this.DisplayedJewishMonth = jd; if (day > 0) { if (day == 30 && JewishDateCalculations.DaysInJewishMonth( this._displayedJewishMonth.Year, this._displayedJewishMonth.Month) == 29) { day = 29; } this.SelectSingleDay(new JewishDate(this._displayedJewishMonth.Year, this._displayedJewishMonth.Month, day)); } this.EnableArrows(); }
/// <summary> /// Returns the number of times this occasions has occurred by the given date. /// </summary> /// <param name="jd"></param> /// <returns></returns> public int GetNumberAnniversary(JewishDate jd) { switch (this.UserOccasionType) { case UserOccasionTypes.HebrewDateRecurringYearly: return(jd.Year - this.JewishDate.Year); case UserOccasionTypes.HebrewDateRecurringMonthly: var months = 0; //Add up all the months for all the intervening years for (var year = this.JewishDate.Year; year < jd.Year; year++) { months += JewishDateCalculations.IsJewishLeapYear(year) ? 13 : 12; } //Add or subtract months from the current year months += jd.Month - this.JewishDate.Month; return(months); case UserOccasionTypes.SecularDateRecurringYearly: return(jd.GregorianDate.Year - this.SecularDate.Year); case UserOccasionTypes.SecularDateRecurringMonthly: //Add all the months for all the years months = (jd.GregorianDate.Year - this.SecularDate.Year) * 12; //Add or subtract months from the current year months += (jd.GregorianDate.Month - this.SecularDate.Month); return(months); } return(0); }
private static void DoJD() { var a = new JewishDate(); var b = a > jdDate; var c = a + 1; var d = a == c; }
/// <summary> /// Returns an array of Perek number/s for the given Jewish Date and location. /// If the given day does not have Pirkei Avos, an empty array is returned. /// </summary> /// <param name="jDate"></param> /// <param name="inIsrael"></param> /// <returns>An array of integers representing the Perek/Prakim of the given Shabbos. /// If the given day does not have Pirkei Avos, an empty array is returned. /// </returns> public static int[] GetPirkeiAvos(JewishDate jDate, bool inIsrael) { if (jDate.DayOfWeek != System.DayOfWeek.Saturday) { return(new int[] { }); } int jYear = jDate.Year, jMonth = jDate.Month, jDay = jDate.Day; //Pirkei Avos is from after Pesach until Rosh Hashana if ((jMonth == 1 && jDay > (inIsrael ? 21 : 22)) || //All Shabbosim through Iyar, Sivan, Tamuz, Av - besides for the day/s of Shavuos and Tisha B'Av ((jMonth > 1 && jMonth < 6 && (!((jMonth == 3 && jDay == 6) || (!inIsrael && jMonth == 3 && jDay == 7))) && (!(jMonth == 5 && jDay == 9))))) { return(new int[] { GetSinglePerek(jDate, inIsrael) }); } //Ellul can have multiple prakim else if (jMonth == 6) { return(GetEllulPrakim(jDate, inIsrael)); } //No Pirkei Avos else { return(new int[] { }); } }
private void frmMonthlyEnglish_Load(object sender, EventArgs e) { Program.SetDoubleBuffered(this.pnlMain); this.printDocument1.DefaultPageSettings.Landscape = true; this.InitLocation(); if (this._todayJewishDate == null) { this.SetToday(); } if (this._selectedDay == null) { this._selectedDay = this._todayJewishDate; } if (this._displayedJewishMonth == null) { this.DisplayedJewishMonth = this._todayJewishDate; } else { this.SetCaptionText(); } this.llSefira.Visible = this._displayedJewishMonth.Month.In(1, 2); this._loading = false; this.EnableArrows(); }
/// <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(JewishDate jewishDate) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int month = jewishDate.getJewishMonth(); int month = jewishDate.JewishMonth; if (HebrewFormat) { if (jewishDate.JewishLeapYear && month == JewishDate.ADAR) { return(hebrewMonths[13] + (useGershGershayim ? GERESH : "")); // return Adar I, not Adar in a leap year } else if (jewishDate.JewishLeapYear && month == JewishDate.ADAR_II) { return(hebrewMonths[12] + (useGershGershayim ? GERESH : "")); } else { return(hebrewMonths[month - 1]); } } else { if (jewishDate.JewishLeapYear && month == JewishDate.ADAR) { return(transliteratedMonths[13]); // return Adar I, not Adar in a leap year } else { return(transliteratedMonths[month - 1]); } } }
private string GetDayOfWeekString(JewishDate jd, Location location) { string dow = ""; if (this.rbDOWJewishNum.Checked) { dow = (jd.DayInWeek + 1).ToNumberHeb(); } else if (this.rbDowNum.Checked) { dow = (jd.DayInWeek + 1).ToString(); } else if (this.rbDayOfWeekFull.Checked) { if (jd.DayOfWeek == DayOfWeek.Saturday) { dow = "ש\"ק"; if (!SpecialDay.IsMajorYomTov(jd, location)) { dow += " " + string.Join(" - ", Sedra.GetSedra(jd, location.IsInIsrael) .Select(i => i.nameHebrew)); } } else { dow = Utils.JewishDOWNamesShort[jd.DayInWeek]; } } else if (this.rbDOWEnglish.Checked) { if (jd.DayOfWeek == DayOfWeek.Saturday) { dow = "Shabbos"; if (!SpecialDay.IsMajorYomTov(jd, location)) { dow += " " + string.Join(" - ", Sedra.GetSedra(jd, location.IsInIsrael) .Select(i => i.nameEng)); } } else { dow = jd.DayOfWeek.ToString().Substring(0, 3); } } if (this.choiceDayDetails.ChoiceOneSelected) { string holidayText = Zmanim.GetHolidaysText( Zmanim.GetHolidays(jd, location.IsInIsrael), " - ", !this.rbDOWEnglish.Checked); if (!string.IsNullOrWhiteSpace(holidayText)) { dow += " - " + holidayText; } } return(dow); }
private void GoToDate(DateTime date) { this._displayingSecularDate = date; this._displayingJewishDate = new JewishDate(date); this.SetSecularDate(); this._dailyZmanim = new DailyZmanim(this._secularDateAtMidnight, Program.CurrentLocation); this.ShowCurrentDateZmanimData(); }
/// <summary> /// Gets the TorahPortion that is read on that week's Shabbos. If, however, a YomTov falls on the Shabbos, and the Parsha gets pushed off, it returns null. /// </summary> /// <param name="Year">That Jewish year</param> /// <param name="Week">The number of the week starting from Rosh Hashanah</param> /// <param name="inIsrael">A boolean value indicating the user's location, this has an effect on the Parsha</param> /// <returns>The Torah portion that is read that Shabbos</returns> public TorahPortion?GetTorahPortion(int Year, int Week, bool inIsrael) { HebrewCalendar hebCal = new HebrewCalendar(); JewishDate date = hebCal.AddWeeks(new JewishDate(Year, 1, 1), Week - 1); return(GetTorahPortion(date, inIsrael)); }
private void rbInIsrael_CheckedChanged(object sender, EventArgs e) { if (!this._loading) { this.SetLocationDataSource(); } //Location was changed, so we may need to re-do the zmanim this.CurrentJewishDate = new JewishDate(this._currentDate, (JewishCalendar.Location) this.cmbLocation.SelectedItem); }
/// <summary> /// Formats the Jewish date. If the formatter is set to Hebrew, it will format in the form, "day Month year" for /// example כ״א שבט תשכ״ט, and the format /// "21 Shevat, 5729" if not. /// </summary> /// <param name="jewishDate"> /// the JewishDate to be formatted </param> /// <returns> the formatted date. If the formatter is set to Hebrew, it will format in the form, "day Month year" for /// example כ״א שבט תשכ״ט, and the format /// "21 Shevat, 5729" if not. </returns> public virtual string format(JewishDate jewishDate) { if (HebrewFormat) { return(formatHebrewNumber(jewishDate.JewishDayOfMonth) + " " + formatMonth(jewishDate) + " " + formatHebrewNumber(jewishDate.JewishYear)); } else { return(jewishDate.JewishDayOfMonth + " " + formatMonth(jewishDate) + ", " + jewishDate.JewishYear); } }
private void SetToday() { if (Program.WeAreHere(this._currentLocation)) { this._todayJewishDate = new JewishDate(this._currentLocation); } else { this._todayJewishDate = new JewishDate(); } }
private void cmbLocation_SelectedIndexChanged(object sender, EventArgs e) { if (!this._loading) { var location = (JewishCalendar.Location) this.cmbLocation.SelectedItem; //If the location changed, the Jewish date may change as well this.CurrentJewishDate = new JewishDate(this._currentDate, location); Properties.Settings.Default.LocationName = location.Name; Properties.Settings.Default.Save(); } }
public frmDailyInfoEng(JewishDate jd, Location location) { this._displayingJewishDate = jd; this._dailyZmanim = new DailyZmanim(jd.GregorianDate, location); this._holidays = Zmanim.GetHolidays(jd, location.IsInIsrael).Cast <SpecialDay>(); this._occasions = UserOccasionColection.FromSettings(jd); InitializeComponent(); this._lblOccasionFont = new Font(this.Font, FontStyle.Bold); this.webBrowser1.ObjectForScripting = new ScriptingObject(); }
private void button3_Click(object sender, EventArgs e) { if (this._currentJewishDate.Year != this._todayJewishDate.Year || this._currentJewishDate.Month != this._todayJewishDate.Month) { this.CurrentJewishDate = this._selectedDay = this._todayJewishDate; } else { this.SelectToday(); } }
private void ClearSelectedDay() { if (this._selectedDay != null) { var sdi = this._singleDateInfoList.FirstOrDefault(t => t.JewishDate == this._selectedDay); this._selectedDay = null; if (sdi != null && this._displayedJewishMonth.Year == sdi.JewishDate.Year && this._displayedJewishMonth.Month == sdi.JewishDate.Month) { this.RedrawSingleDay(sdi); } } }
private void Hagim() { string value; HebrewDateFormatter hdf = new HebrewDateFormatter(); JewishDate jd = new JewishDate(); JewishCalendar jc = new JewishCalendar(); jd.resetDate(); hdf.HebrewFormat = true; jc.InIsrael = false; value = hdf.formatYomTov(jc); lblHolides.Text = value; }
/// <summary> /// show full date and year in the application /// </summary> public void showDate() { string value; HebrewDateFormatter hdf = new HebrewDateFormatter(); JewishDate jd = new JewishDate(); JewishCalendar jc = new JewishCalendar(); jd.resetDate(); hdf.HebrewFormat = true; jc.InIsrael = true; value = jc.GregorianDayOfMonth.ToString() + "/" + jc.GregorianMonth.ToString() + "/" + jc.GregorianYear.ToString(); ILDate.Text = value; }
/// <summary> /// Formats the day of week. If <seealso cref="#isHebrewFormat() Hebrew formatting"/> is set, it will display in the format /// ראשון etc. If Hebrew formatting is not in use it will return it in the format /// of Sunday etc. There are various formatting options that will affect the output. /// </summary> /// <param name="jewishDate"> </param> /// <returns> the formatted day of week </returns> /// <seealso cref= #isHebrewFormat() </seealso> /// <seealso cref= #isLongWeekFormat() </seealso> public virtual string formatDayOfWeek(JewishDate jewishDate) { if (hebrewFormat) { StringBuilder sb = new StringBuilder(); sb.Append(longWeekFormat ? hebrewDaysOfWeek[jewishDate.DayOfWeek - 1] : formatHebrewNumber(jewishDate.DayOfWeek)); return(sb.ToString()); } else { return(jewishDate.DayOfWeek == 7 ? TransliteratedShabbosDayOfWeek : jewishDate.Time.ToString("dddd")); } }
public frmDailyInfoHeb(JewishDate jd, Location location) { this._displayingJewishDate = jd; this.SetSecularDate(); this._dailyZmanim = new DailyZmanim(this._secularDateAtMidnight, location); this._holidays = Zmanim.GetHolidays(jd, location.IsInIsrael).Cast <SpecialDay>(); this._occasions = UserOccasionColection.FromSettings(jd); InitializeComponent(); this._lblOccasionFont = new Font(this.tableLayoutPanel1.Font, FontStyle.Bold); this.webBrowser1.ObjectForScripting = new ScriptingObject(); }
private void SetValueFromCombos() { int year = ((KeyValuePair <int, string>) this.cmbJYear.SelectedItem).Key, month = ((KeyValuePair <int, string>) this.cmbJMonth.SelectedItem).Key, day = ((KeyValuePair <int, string>) this.cmbJDay.SelectedItem).Key; if (day == 30 && JewishDateCalculations.DaysInJewishMonth(year, month) == 29) { day = 29; } this.Value = new JewishDate(year, month, day); }
/// <summary> /// Return the next occurrence (from the current system date) of this UserOccasion /// </summary> /// <returns></returns> public DateTime GetUpcomingOccurence() { DateTime now = DateTime.Now; DateTime retVal = now; JewishDate todayJd = new JewishDate(now); switch (this.UserOccasionType) { case UserOccasionTypes.OneTime: //return setting date retVal = this.JewishDate.GregorianDate; break; case UserOccasionTypes.HebrewDateRecurringYearly: var jdYearly = new JewishDate(todayJd.Year, this.JewishDate.Month, this.JewishDate.Day); while (jdYearly.GregorianDate < now) { jdYearly = jdYearly.AddYears(1); } retVal = jdYearly.GregorianDate; break; case UserOccasionTypes.HebrewDateRecurringMonthly: var jdMonthly = new JewishDate(todayJd.Year, todayJd.Month, this.JewishDate.Day); while (jdMonthly.GregorianDate < now) { jdMonthly = jdMonthly.AddMonths(1); } retVal = jdMonthly.GregorianDate; break; case UserOccasionTypes.SecularDateRecurringYearly: retVal = new DateTime(now.Year, this.SecularDate.Month, this.SecularDate.Day, now.Hour, now.Minute, now.Second, now.Millisecond); while (retVal < now) { retVal = retVal.AddYears(1); } break; case UserOccasionTypes.SecularDateRecurringMonthly: retVal = new DateTime(now.Year, now.Month, this.SecularDate.Day, now.Hour, now.Minute, now.Second, now.Millisecond); while (retVal < now) { retVal = retVal.AddMonths(1); } break; } return(retVal); }
public void Pharsha() { string value, value2; HebrewDateFormatter hdf = new HebrewDateFormatter(); JewishCalendar jc = new JewishCalendar(); JewishDate jd = new JewishDate(); jc.InIsrael = false; hdf.HebrewFormat = false; value = hdf.formatParsha(jc); lblPharsha.Text = value; value2 = jc.ParshaIndex.ToString(); lblIsHead.Text = value2; }
/// <summary> /// Gets all occasions and events for the given Jewish Date /// </summary> /// <param name="currDate"></param> /// <returns></returns> public static UserOccasionColection FromSettings(JewishDate currDate) { var col = new UserOccasionColection(); col.AddRange(from uo in Properties.Settings.Default.UserOccasions where (uo.UserOccasionType == UserOccasionTypes.OneTime && (uo.JewishDate == currDate || uo.SecularDate.Date == currDate.GregorianDate.Date)) || ((uo.JewishDate == null || uo.JewishDate <= currDate) && ( (uo.UserOccasionType == UserOccasionTypes.HebrewDateRecurringYearly && (uo.JewishDate.Day == currDate.Day && IsJewishMonthMatch(uo.JewishDate, currDate))) || (uo.UserOccasionType == UserOccasionTypes.HebrewDateRecurringMonthly && (uo.JewishDate.Day == currDate.Day)) || (uo.UserOccasionType == UserOccasionTypes.SecularDateRecurringYearly && (uo.SecularDate.Day == currDate.GregorianDate.Day && uo.SecularDate.Month == currDate.GregorianDate.Month)) || (uo.UserOccasionType == UserOccasionTypes.SecularDateRecurringMonthly && (uo.SecularDate.Day == currDate.GregorianDate.Day)))) select uo); return(col); }
/// <summary> /// show to current day /// </summary> private void ShowDay() { //Thread.CurrentThread.CurrentCulture = new CultureInfo("he-IL"); //string day = "dddd"; //lblShowDay.Text = DateTime.Now.ToString(day); /*******************************************************************/ string value1, value2; HebrewDateFormatter hdf = new HebrewDateFormatter(); JewishDate jd = new JewishDate(); JewishCalendar jc = new JewishCalendar(); hdf.HebrewFormat = false; jc.InIsrael = true; //hdf.LongWeekFormat = true; value1 = hdf.formatDayOfWeek(jd); //value2 = jd.DayOfWeek.ToString(); if (value1 == "Sunday") { value1 = "ראשון"; } if (value1 == "Monday") { value1 = "שני"; } if (value1 == "Tuesday") { value1 = "שלישי"; } if (value1 == "Wednesday") { value1 = "רביעי"; } if (value1 == "Thursday") { value1 = "חמישי"; } if (value1 == "Friday") { value1 = "שישי"; } if (value1 == "Saturday") { value1 = "שבת"; } lblShowDay.Text = value1; /*******************************************************************/ }
private void SetZmanim() { this.timer1.Stop(); this._jdate = new JewishDate(this._today); var ns = Zmanim.GetNetzShkia(DateTime.Now, this._location); this._netzSeconds = ns[0].TotalSeconds; this._shkiaSeconds = ns[1].TotalSeconds; var totalDaySeconds = this._shkiaSeconds - this._netzSeconds; this._zmaniosDaytimeSecondsPerHour = totalDaySeconds / 12d; this._zmaniosDaytimeSecondsPerMinute = totalDaySeconds / 720d; this._zmaniosDaytimeSecondsPerSecond = totalDaySeconds / 43200d; var totalNightSeconds = 86400 - totalDaySeconds; this._zmaniosNighttimeSecondsPerHour = totalNightSeconds / 12d; this._zmaniosNighttimeSecondsPerMinute = totalNightSeconds / 720d; this._zmaniosNighttimeSecondsPerSecond = totalNightSeconds / 43200d; var nowSeconds = DateTime.Now.TimeOfDay.TotalSeconds; this.richTextBox1.Clear(); this.richTextBox1.Text += $@"{this._jdate.ToLongDateString()} {this._today.ToLongDateString()} Hanetz Hachama: {ns[0].ToString24H(true)} Shkias Hachama: {ns[1].ToString24H(true)} Hour Zmanios Day: {this._zmaniosDaytimeSecondsPerHour / 60:N2} minutes Hour Zmanios Night: {this._zmaniosNighttimeSecondsPerHour / 60:N2} minutes"; if (this._netzSeconds <= nowSeconds && this._shkiaSeconds > nowSeconds) { //DayTime this.timer1.Interval = Convert.ToInt32(this._zmaniosDaytimeSecondsPerSecond * 1000); } else { this.timer1.Interval = Convert.ToInt32(this._zmaniosNighttimeSecondsPerSecond * 1000); } this.timer1.Start(); }
private void SelectSingleDay(JewishDate jd) { if (this._selectedDay != jd) { if (this._displayedJewishMonth.Year == jd.Year && this._displayedJewishMonth.Month == jd.Month) { var sdi = this._singleDateInfoList.FirstOrDefault(t => t.JewishDate == jd); if (sdi != null) { this.SelectSingleDay(sdi); } } this.jewishDatePicker1.Value = jd; this._selectedDay = jd; } }
private void button3_Click(object sender, EventArgs e) { var sdi = this._singleDateInfoList.FirstOrDefault(d => d.JewishDate == this._todayJewishDate); if (sdi != null) { this.SelectSingleDay(sdi); } else { this._selectedDay = this._todayJewishDate; this.DisplayedJewishMonth = this._todayJewishDate; } this.EnableArrows(); }
/// <summary> /// Gets the single Perek for a typical Summer Shabbos day. /// </summary> /// <param name="jDate"></param> /// <param name="inIsrael"></param> /// <returns></returns> private static int GetSinglePerek(JewishDate jDate, bool inIsrael) { int jYear = jDate.Year, jMonth = jDate.Month, jDay = jDate.Day; //Save the first day of Pesach. Most subsequent calls will be for the same year and location. if (_savedPesachDay1 == null || jYear != _savedPesachDay1.Year || _savedInIsrael != inIsrael) { _savedPesachDay1 = new JewishDate(jYear, 1, 15); _savedInIsrael = inIsrael; } //How many days after the first day of pesach was the first shabbos after pesach int firstShabbosInterval = 13 - _savedPesachDay1.DayInWeek; //If we are in Chu"l and peash was on shabbos, then Achron shel pesach was also on Shabbos if (!inIsrael && _savedPesachDay1.DayOfWeek == System.DayOfWeek.Saturday) { firstShabbosInterval += 7; } //What number shabbos after pesach is the current date int currentShabbosNumber = (jMonth == 1 && jDay == (firstShabbosInterval + 15) ? 1 : ((jDate.AbsoluteDate - (_savedPesachDay1.AbsoluteDate + firstShabbosInterval)) / 7) + 1); int perekAvos = currentShabbosNumber % 6; if (perekAvos == 0) { perekAvos = 6; } //If the second day of Shavuos was on Shabbos, we missed a week. //The second day of Pesach is always the same day as the first day of Shavuos. //So if Pesach was on Thursday, Shavuos will be on Friday and Shabbos in Chu"l. //Pesach can never come out on Friday, so in E. Yisroel Shavuos is never on Shabbos. if ((!inIsrael) && _savedPesachDay1.DayOfWeek == System.DayOfWeek.Thursday && (jMonth > 3 || (jMonth == 3 && jDay > 6))) { perekAvos = (perekAvos == 1 ? 6 : perekAvos - 1); } //If Tisha B'Av was on Shabbos, we missed a week. The first day of Pesach is always the same day of the week as Tisha b'av. if (_savedPesachDay1.DayOfWeek == System.DayOfWeek.Saturday && (jMonth > 5 || (jMonth == 5 && jDay > 9))) { perekAvos = (perekAvos == 1 ? 6 : perekAvos - 1); } return(perekAvos); }
private string getFromToHeaderText() { string text = ""; JewishDate from = this.jdpFrom.Value, to = this.jdpTo.Value; text = Utils.ToNumberHeb(from.Day) + " " + Utils.JewishMonthNamesHebrew[from.Month] + " " + Utils.ToNumberHeb(from.Year % 1000) + " - " + Utils.ToNumberHeb(to.Day) + " " + Utils.JewishMonthNamesHebrew[to.Month] + " " + Utils.ToNumberHeb(to.Year % 1000); return(text); }
/// <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(JewishDate jewishDate) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int month = jewishDate.getJewishMonth(); int month = jewishDate.JewishMonth; if (HebrewFormat) { if (jewishDate.JewishLeapYear && month == JewishDate.ADAR) { return hebrewMonths[13] + (useGershGershayim ? GERESH : ""); // return Adar I, not Adar in a leap year } else if (jewishDate.JewishLeapYear && month == JewishDate.ADAR_II) { return hebrewMonths[12] + (useGershGershayim ? GERESH : ""); } else { return hebrewMonths[month - 1]; } } else { if (jewishDate.JewishLeapYear && month == JewishDate.ADAR) { return transliteratedMonths[13]; // return Adar I, not Adar in a leap year } else { return transliteratedMonths[month - 1]; } } }
/// <summary> /// Formats the Jewish date. If the formatter is set to Hebrew, it will format in the form, "day Month year" for /// example כ״א שבט תשכ״ט, and the format /// "21 Shevat, 5729" if not. /// </summary> /// <param name="jewishDate"> /// the JewishDate to be formatted </param> /// <returns> the formatted date. If the formatter is set to Hebrew, it will format in the form, "day Month year" for /// example כ״א שבט תשכ״ט, and the format /// "21 Shevat, 5729" if not. </returns> public virtual string format(JewishDate jewishDate) { if (HebrewFormat) { return formatHebrewNumber(jewishDate.JewishDayOfMonth) + " " + formatMonth(jewishDate) + " " + formatHebrewNumber(jewishDate.JewishYear); } else { return jewishDate.JewishDayOfMonth + " " + formatMonth(jewishDate) + ", " + jewishDate.JewishYear; } }
/// <summary> /// Formats the day of week. If <seealso cref="#isHebrewFormat() Hebrew formatting"/> is set, it will display in the format /// ראשון etc. If Hebrew formatting is not in use it will return it in the format /// of Sunday etc. There are various formatting options that will affect the output. /// </summary> /// <param name="jewishDate"> </param> /// <returns> the formatted day of week </returns> /// <seealso cref= #isHebrewFormat() </seealso> /// <seealso cref= #isLongWeekFormat() </seealso> public virtual string formatDayOfWeek(JewishDate jewishDate) { if (hebrewFormat) { StringBuilder sb = new StringBuilder(); sb.Append(longWeekFormat ? hebrewDaysOfWeek[jewishDate.DayOfWeek - 1] : formatHebrewNumber(jewishDate.DayOfWeek)); return sb.ToString(); } else { return jewishDate.DayOfWeek == 7 ? TransliteratedShabbosDayOfWeek : jewishDate.Time.ToString("dddd"); } }
/// <summary> /// Returns the kviah in the traditional 3 letter Hebrew format where the first letter represents the day of week of /// Rosh Hashana, the second letter represents the lengths of Cheshvan and Kislev ({@link JewishDate#SHELAIMIM /// Shelaimim} , <seealso cref="JewishDate#KESIDRAN Kesidran"/> or <seealso cref="JewishDate#CHASERIM Chaserim"/>) and the 3rd letter /// represents the day of week of Pesach. For example 5729 (1969) would return בשה (Rosh Hashana on /// Monday, Shelaimim, and Pesach on Thursday), while 5771 (2011) would return השג (Rosh Hashana on /// Thursday, Shelaimim, and Pesach on Tuesday). /// </summary> /// <param name="jewishYear"> /// the Jewish year </param> /// <returns> the Hebrew String such as בשה for 5729 (1969) and השג for 5771 /// (2011). </returns> public virtual string getFormattedKviah(int jewishYear) { JewishDate jewishDate = new JewishDate(jewishYear, JewishDate.TISHREI, 1); // set date to Rosh Hashana int kviah = jewishDate.CheshvanKislevKviah; int roshHashanaDayOfweek = jewishDate.DayOfWeek; string returnValue = formatHebrewNumber(roshHashanaDayOfweek); returnValue += (kviah == JewishDate.CHASERIM ? "\u05D7" : kviah == JewishDate.SHELAIMIM ? "\u05E9" : "\u05DB"); jewishDate.setJewishDate(jewishYear, JewishDate.NISSAN, 15); // set to Pesach of the given year int pesachDayOfweek = jewishDate.DayOfWeek; returnValue += formatHebrewNumber(pesachDayOfweek); returnValue = returnValue.Replace(GERESH, ""); // geresh is never used in the kviah format // boolean isLeapYear = JewishDate.isJewishLeapYear(jewishYear); // for efficiency we can avoid the expensive recalculation of the pesach day of week by adding 1 day to Rosh // Hashana for a 353 day year, 2 for a 354 day year, 3 for a 355 or 383 day year, 4 for a 384 day year and 5 for // a 385 day year return returnValue; }