示例#1
0
        /// <summary>
        /// Returns the molad for the given year and month
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        public static Molad GetMolad(int month, int year)
        {
            int totalMonths, partsElapsed, hoursElapsed, parts, monthAdj;

            monthAdj = month - 7;
            if (monthAdj < 0)
            {
                monthAdj += JewishDateCalculations.MonthsInJewishYear(year);
            }

            totalMonths = monthAdj + 235 * ((year - 1) / 19) + 12 * ((year - 1) % 19) +
                          ((((year - 1) % 19) * 7) + 1) / 19;
            partsElapsed = 204 + (793 * (totalMonths % 1080));
            hoursElapsed = 5 + (12 * totalMonths) + 793 * (totalMonths / 1080) + partsElapsed / 1080 - 6;
            parts        = (partsElapsed % 1080) + 1080 * (hoursElapsed % 24);

            return(new Molad
            {
                JewishDate = new JewishDate((1 + (29 * totalMonths)) + (hoursElapsed / 24)),
                Time = new TimeOfDay {
                    Hour = hoursElapsed % 24, Minute = (parts % 1080) / 18
                },
                Chalakim = parts % 18
            });
        }
示例#2
0
        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();
        }
示例#3
0
        /// <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 void SetSecularDate()
        {
            this._displayingSecularDate = this._displayingJewishDate.GregorianDate;

            /*-------------------------------------------------------------------------------------------------------------------------------
             * The zmanim shown will always be for the Gregorian Date that starts at midnight of the current Jewish Date.
             * We use the JewishDateCalculations.GetGregorianDateFromJewishDate function
             * which gets the Gregorian Date that will be at midnight of the given Jewish day.
             * ----------------------------------------------------------------------------------------------------------------------------------*/
            this._secularDateAtMidnight = JewishDateCalculations.GetGregorianDateFromJewishDate(this._displayingJewishDate);
        }
示例#5
0
        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);
        }
        private void DisplayHolidays(StringBuilder html)
        {
            var shkia = this._dailyZmanim.ShkiaAtElevation;

            if (this._holidays.Count() > 0)
            {
                foreach (var h in this._holidays)
                {
                    html.AppendFormat("<div class=\"padWidth\">{0}", h.NameEnglish);
                    if (h.NameEnglish == "Shabbos Mevarchim")
                    {
                        var nextMonth = this._displayingJewishDate + 12;
                        html.AppendFormat(" - Chodesh {0}", nextMonth.MonthName);

                        var molad = Molad.GetMolad(nextMonth.Month, nextMonth.Year);
                        var dim   = JewishDateCalculations.DaysInJewishMonth(this._displayingJewishDate.Year, this._displayingJewishDate.Month);
                        var dow   = dim - this._displayingJewishDate.Day;
                        if (dim == 30)
                        {
                            dow--;
                        }
                        html.AppendFormat("<div>Molad: {0}</div>", molad.ToString(this._dailyZmanim.ShkiaAtElevation));
                        html.AppendFormat("<div>Rosh Chodesh: {0}{1}</div>",
                                          Utils.DaysOfWeek[dow], (dim == 30 ? ", " + Utils.DaysOfWeek[(dow + 1) % 7] : ""));
                    }
                    html.Append("</div>");

                    if (h.NameEnglish.Contains("Sefiras Ha'omer"))
                    {
                        var dayOfOmer = this._displayingJewishDate.GetDayOfOmer();
                        html.AppendFormat("<div><a onclick=\"javacript:window.external.showSefirah({0}, false);return false;\" class=\"tahoma nine steelBlue pointer\">{1}</a></div>",
                                          dayOfOmer, Utils.GetOmerNusach(dayOfOmer, Properties.Settings.Default.Nusach));
                    }

                    if (h.DayType.IsSpecialDayType(SpecialDayTypes.EruvTavshilin))
                    {
                        html.Append("<div class=\"padWidth eight bold crimson\">Eiruv Tavshilin</div>");
                    }
                }
            }
            html.Append("<table>");
            if (shkia != TimeOfDay.NoValue &&
                this._holidays.Any(h => h.DayType.IsSpecialDayType(SpecialDayTypes.HasCandleLighting)))
            {
                this.AddLine(html, "Candle Lighting", (shkia - this._dailyZmanim.Location.CandleLighting).ToString(), wideDescription: false);
                html.Append("<tr><td class=\"nobg\" colspan=\"3\">&nbsp;</td></tr>");
            }
        }
示例#7
0
        private void FillJewishMonthsCombo()
        {
            if (this._value == null)
            {
                return;
            }

            this.cmbJMonth.Items.Clear();
            bool m = JewishDateCalculations.IsJewishLeapYear(this._value.Year);

            for (int i = 1; i <= (m ? 13 : 12); i++)
            {
                this.cmbJMonth.Items.Add(new KeyValuePair <int, string>(i,
                                                                        this._language == Languages.Hebrew ? Utils.GetProperMonthNameHeb(this.Value.Year, i) : Utils.GetProperMonthName(this.Value.Year, i)));
            }
        }
示例#8
0
        private void FillJewishDaysCombo()
        {
            if (this._value == null)
            {
                return;
            }

            this.cmbJDay.Items.Clear();

            int d = JewishDateCalculations.DaysInJewishMonth(this._value.Year, this._value.Month);

            for (int i = 1; i <= d; i++)
            {
                this.cmbJDay.Items.Add(new KeyValuePair <int, string>(i,
                                                                      this._language == Languages.Hebrew ? i.ToNumberHeb() : i.ToString()));
            }
        }
示例#9
0
        /// <summary>
        /// Determines if two months match for a yahrtzeit or birthday etc.
        /// </summary>
        /// <param name="occDate"></param>
        /// <param name="currDate"></param>
        /// <returns></returns>
        private static bool IsJewishMonthMatch(JewishDate occDate, JewishDate currDate)
        {
            int occMonth  = occDate.Month,
                currMonth = currDate.Month;

            if (currMonth >= 12 && occMonth >= 12)
            {
                bool isOccLeap  = JewishDateCalculations.IsJewishLeapYear(occDate.Year),
                     isCurrLeap = JewishDateCalculations.IsJewishLeapYear(currDate.Year);

                if (isOccLeap != isCurrLeap)
                {
                    return((isOccLeap && currMonth == 12) ||
                           (isCurrLeap && (occMonth == 12 && currMonth == 13)));
                }
            }

            return(occMonth == currMonth);
        }
        internal void ShowDateData()
        {
            this.Cursor = Cursors.WaitCursor;
            var showSeconds     = Properties.Settings.Default.ShowSeconds;
            var dy              = DafYomi.GetDafYomi(this._displayingJewishDate);
            var netzshkia       = this._dailyZmanim.NetzShkiaAtElevation;
            var netzshkiaMishor = this._dailyZmanim.NetzShkiaMishor;
            var netz            = this._dailyZmanim.NetzAtElevation;
            var shkia           = this._dailyZmanim.ShkiaAtElevation;
            var netzMishor      = this._dailyZmanim.NetzMishor;
            var shkiaMishor     = this._dailyZmanim.ShkiaMishor;
            var chatzos         = this._dailyZmanim.Chatzos;
            var shaaZmanis      = this._dailyZmanim.ShaaZmanis;
            var shaaZmanis90    = this._dailyZmanim.ShaaZmanisMga;
            var html            = new StringBuilder();

            html.AppendFormat("<div class=\"padWidth royalBlue bold\">{0}</div>",
                              this._displayingJewishDate.ToLongDateStringHeb());
            html.AppendFormat("<div class=\"padWidth lightSteelBlue\">{0}</div>",
                              this._displayingSecularDate.ToString("D", Program.HebrewCultureInfo));

            //If the secular day is a day behind as day being displayed is todays date and it is after sunset,
            //the user may get confused as the secular date for today and tomorrow will be the same.
            //So we esplain'in it to them...
            if (this._secularDateAtMidnight.Date != this._displayingSecularDate.Date)
            {
                html.Append("<div class=\"padWidth rosyBrown seven italic\">שים לב: תאריך הלועזי מתחיל בשעה 0:00</div>");
            }

            this.DisplayDateDiff(html);

            html.Append("<br />");
            if (this._holidays.Count() > 0)
            {
                foreach (var h in this._holidays)
                {
                    html.AppendFormat("<div class=\"padWidth\">{0}", h.NameHebrew);
                    if (h.NameEnglish == "Shabbos Mevarchim")
                    {
                        var nextMonth = this._displayingJewishDate + 12;
                        html.AppendFormat(" - חודש {0}", Utils.GetProperMonthNameHeb(nextMonth.Year, nextMonth.Month));

                        var molad = Molad.GetMolad(nextMonth.Month, nextMonth.Year);
                        var dim   = JewishDateCalculations.DaysInJewishMonth(this._displayingJewishDate.Year, this._displayingJewishDate.Month);
                        var dow   = dim - this._displayingJewishDate.Day;
                        if (dim == 30)
                        {
                            dow--;
                        }
                        html.AppendFormat("<div>המולד: {0}</div>", molad.ToStringHeb(this._dailyZmanim.ShkiaAtElevation));
                        html.AppendFormat("<div>ראש חודש: {0}{1}</div>",
                                          Utils.JewishDOWNames[dow], (dim == 30 ? ", " + Utils.JewishDOWNames[(dow + 1) % 7] : ""));
                    }
                    html.Append("</div>");
                    if (h.NameEnglish.Contains("Sefiras Ha'omer"))
                    {
                        var dayOfOmer = this._displayingJewishDate.GetDayOfOmer();
                        html.AppendFormat("<div><a onclick=\"javacript:window.external.showSefirah({0}, true);return false;\" class=\"nine bluoid pointer\">{1}</a></div>",
                                          dayOfOmer, Utils.GetOmerNusach(dayOfOmer, Properties.Settings.Default.Nusach));
                    }

                    if (h.DayType.IsSpecialDayType(SpecialDayTypes.EruvTavshilin))
                    {
                        html.Append("<div class=\"padWidth crimson bold\">עירוב תבשילין</div>");
                    }
                }
            }

            html.Append("<table>");

            if (shkia != TimeOfDay.NoValue &&
                this._holidays.Any(h => h.DayType.IsSpecialDayType(SpecialDayTypes.HasCandleLighting)))
            {
                this.AddLine(html, "הדלקת נרות", (shkia - this._dailyZmanim.Location.CandleLighting).ToString24H(showSeconds),
                             wideDescription: false);
                html.Append("<tr><td class=\"nobg\" colspan=\"3\">&nbsp;</td></tr>");
            }

            this.AddLine(html, "פרשת השבוע",
                         string.Join(" ", Sedra.GetSedra(this._displayingJewishDate, this._dailyZmanim.Location.IsInIsrael).Select(i => i.nameHebrew)),
                         wideDescription: false);
            if (dy != null)
            {
                this.AddLine(html, "דף יומי", dy.ToStringHeb(), wideDescription: false);
            }

            html.Append("</table><br />");
            html.AppendFormat("<div class=\"padBoth lightSteelBlueBG ghostWhite nine bold clear\">זמני היום ב{0}</div>",
                              this._dailyZmanim.Location.NameHebrew);
            html.Append("<table>");

            if (netz == TimeOfDay.NoValue)
            {
                this.AddLine(html, "הנץ החמה", "השמש אינו עולה", bold: true, emphasizeValue: true);
            }
            else
            {
                if (this._displayingJewishDate.Month == 1 && this._displayingJewishDate.Day == 14)
                {
                    this.AddLine(html, "סו\"ז אכילת חמץ", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 4D)).ToString24H(showSeconds),
                                 bold: true);
                    this.AddLine(html, "סו\"ז שריפת חמץ", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 5D)).ToString24H(showSeconds),
                                 bold: true);
                    html.Append("<br />");
                }

                this.AddLine(html, "עלות השחר - 90", (netzMishor - 90).ToString24H(showSeconds));
                this.AddLine(html, "עלות השחר - 72", (netzMishor - 72).ToString24H(showSeconds));

                if (netz == netzMishor)
                {
                    this.AddLine(html, "הנץ החמה", netz.ToString24H(showSeconds), bold: true, emphasizeValue: true);
                }
                else
                {
                    this.AddLine(html, "הנה\"ח <span class=\"reg lightSteelBlue\">...מ " + this._dailyZmanim.Location.Elevation.ToString() + " מטר</span>",
                                 netz.ToString24H(showSeconds));
                    this.AddLine(html, "הנה\"ח <span class=\"reg lightSteelBlue\">...גובה פני הים</span>",
                                 netzMishor.ToString24H(showSeconds), bold: true, emphasizeValue: true);
                }
                this.AddLine(html, "סוזק\"ש - מג\"א", this._dailyZmanim.GetZman(ZmanType.KShmMga).ToString24H(showSeconds));
                this.AddLine(html, "סוזק\"ש - הגר\"א", this._dailyZmanim.GetZman(ZmanType.KshmGra).ToString24H(showSeconds));
                this.AddLine(html, "סוז\"ת - מג\"א", this._dailyZmanim.GetZman(ZmanType.TflMga).ToString24H(showSeconds));
                this.AddLine(html, "סוז\"ת - הגר\"א", this._dailyZmanim.GetZman(ZmanType.TflGra).ToString24H(showSeconds));
            }
            if (netz != TimeOfDay.NoValue && shkia != TimeOfDay.NoValue)
            {
                this.AddLine(html, "חצות היום והלילה", chatzos.ToString24H(showSeconds));
                this.AddLine(html, "מנחה גדולה", this._dailyZmanim.GetZman(ZmanType.MinchaG).ToString24H(showSeconds));
                this.AddLine(html, "מנחה קטנה", this._dailyZmanim.GetZman(ZmanType.MinchaK).ToString24H(showSeconds));
                this.AddLine(html, "פלג המנחה", this._dailyZmanim.GetZman(ZmanType.MinchaPlg).ToString24H(showSeconds));
            }
            if (shkia == TimeOfDay.NoValue)
            {
                this.AddLine(html, "שקיעת החמה", "השמש אינו שוקע", bold: true, emphasizeValue: true);
            }
            else
            {
                if (shkia == shkiaMishor)
                {
                    this.AddLine(html, "שקיעת החמה", shkia.ToString24H(showSeconds), bold: true, emphasizeValue: true);
                }
                else
                {
                    this.AddLine(html, "שקה\"ח <span class=\"reg lightSteelBlue\">...גובה פני הים</span>", shkiaMishor.ToString24H(showSeconds));
                    this.AddLine(html, "שקה\"ח <span class=\"reg lightSteelBlue\">...מ " + this._dailyZmanim.Location.Elevation.ToString() + " מטר</span>",
                                 shkia.ToString24H(showSeconds), bold: true, emphasizeValue: true);
                }

                this.AddLine(html, "צאת הכוכבים 45", (shkia + 45).ToString24H(showSeconds));
                this.AddLine(html, "רבינו תם", (shkia + 72).ToString24H(showSeconds));
                this.AddLine(html, "72 דקות זמניות", (shkia + (int)(shaaZmanis * 1.2)).ToString24H(showSeconds));
                this.AddLine(html, "72 דקות זמניות לחומרה", (shkia + (int)(shaaZmanis90 * 1.2)).ToString24H(showSeconds));
            }
            html.Append("</table>");
            this.webBrowser1.DocumentText = Properties.Resources.InfoHTMLHeb
                                            .Replace("{{BODY}}", html.ToString());

            this.tableLayoutPanel1.Controls.Clear();
            foreach (UserOccasion occ in this._occasions)
            {
                this.AddOccasion(occ);
            }

            var bg = (from o in this._occasions
                      where o.BackColor != Color.Empty
                      select o.BackColor).FirstOrDefault();

            this.tableLayoutPanel1.BackColor = (bg != Color.Empty ? bg.Color : Color.GhostWhite);

            this.Cursor = Cursors.Default;
        }
示例#11
0
        /// <summary>
        /// Gets the DafYomi for the given day
        /// </summary>
        /// <param name="absoluteDate"></param>
        /// <returns></returns>
        private static Daf GetSingleDaf(int absoluteDate)
        {
            int dafcnt = 40;
            int cno, dno, osday, nsday, total, count, j, blatt;

            osday = JewishDateCalculations.GetAbsoluteFromGregorianDate(1923, 9, 11);
            nsday = JewishDateCalculations.GetAbsoluteFromGregorianDate(1975, 6, 24);

            /*  No cycle, new cycle, old cycle */
            if (absoluteDate < osday)
            {
                return(null); /* daf yomi hadn't started yet */
            }

            if (absoluteDate >= nsday)
            {
                cno = 8 + ((absoluteDate - nsday) / 2711);
                dno = (absoluteDate - nsday) % 2711;
            }
            else
            {
                cno = 1 + ((absoluteDate - osday) / 2702);
                dno = (absoluteDate - osday) / 2702;
            }

            /* Find the daf taking note that the cycle changed slightly after cycle 7. */
            total = blatt = 0;
            count = -1;

            /* Fix Shekalim for old cycles */
            if (cno <= 7)
            {
                masechtaList[4].Dappim = 13;
            }
            else
            {
                masechtaList[4].Dappim = 22;
            }

            /* Find the daf */
            j = 0;
            while (j < dafcnt)
            {
                count++;
                total = total + masechtaList[j].Dappim - 1;
                if (dno < total)
                {
                    blatt = (masechtaList[j].Dappim + 1) - (total - dno);
                    /* fiddle with the weird ones near the end */
                    switch (count)
                    {
                    case 36:
                        blatt += 21;
                        break;

                    case 37:
                        blatt += 24;
                        break;

                    case 38:
                        blatt += 33;
                        break;

                    default:
                        break;
                    }
                    /* Bailout */
                    j = 1 + dafcnt;
                }
                j++;
            }

            return(new Daf(masechtaList[count], blatt));
        }