Пример #1
0
        public static bool IsRoshChodesh(JewishDate date)
        {
            //Rosh Hashana isn't considered a Rosh Chodesh
            if (date.Day == 30 || (date.Day == 1 && date.Month != (int)Months.Tishrei))
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Returns the first occurrence of the specified <see cref="System.DayOfWeek"/> after the <see cref="JewishDate"/>.
        /// If the <see cref="JewishDate"/> falls on the specified <see cref="System.DayOfWeek"/> then no days are added.
        /// </summary>
        /// <param name="day">The day of the week to search for</param>
        /// <returns>The <see cref="JewishDate"/> that matches the <paramref name="day"/>, could be the original <see cref="JewishDate"/></returns>
        public JewishDate FindNextDay(DayOfWeek day)
        {
            JewishDate result = this;

            while (result.DayOfWeek != day)
            {
                result = result.Add(new TimeSpan(1, 0, 0, 0));
            }

            return(result);
        }
Пример #3
0
        public static IList <SpecialDates> GetDayInfo(JewishDate date, bool inIsrael)
        {
            IList <SpecialDates> specialDates = new List <SpecialDates>();

            int year  = date.Year;
            int month = date.Month;
            int day   = date.Day;

            bool isShabbos          = IsShabbos(date);
            bool isYesterdayShabbos = IsYesterdayShabbos(date);
            bool isCheshvanShort    = IsCheshvanShort(year);
            bool isKislevLong       = IsKislevLong(year);
            bool isLeapYear         = IsLeapYear(year);

            if (!isLeapYear && month > 6)
            {
                //This is to keep it in-line with the enum Months. If it is a leap year Nissan = 7, if it isn't it's 6. This lines them up
                month++;
            }


            switch ((Months)month)
            {
            case Months.Tishrei:
                if (day == 1 || day == 2)
                {
                    specialDates.Add(SpecialDates.RoshHashana);
                }
                else if ((day == 3 && !isShabbos) || (day == 4 && isYesterdayShabbos))
                {
                    specialDates.Add(SpecialDates.FastOfGedalia);
                }
                else if (day == 10)
                {
                    specialDates.Add(SpecialDates.YomKippur);
                }
                else if ((day > 14 && day < 22))
                {
                    specialDates.Add(SpecialDates.Sukkos);
                }
                else if (day == 22 && !inIsrael)
                {
                    specialDates.Add(SpecialDates.ShminiAtzeres);
                }
                else if ((day == 22 && inIsrael) || (day == 23 && !inIsrael))
                {
                    specialDates.Add(SpecialDates.SimchasTorah);
                }
                break;

            case Months.Cheshvan:
                break;

            case Months.Kislev:
                if (day > 24)
                {
                    specialDates.Add(SpecialDates.Chanukah);
                }
                break;

            case Months.Teves:
                if (day < 3 || (day == 3 && !isKislevLong))
                {
                    specialDates.Add(SpecialDates.Chanukah);
                }
                else if (day == 10)
                {
                    specialDates.Add(SpecialDates.TenthOfTeves);
                }
                break;

            case Months.Shvat:
                if (day == 15)
                {
                    specialDates.Add(SpecialDates.TuBishvat);
                }
                break;

            case Months.AdarI:
                if (!isLeapYear)
                {
                    if ((day == 11 && IsShabbos(date.Add(new TimeSpan(2, 0, 0, 0)))) || (day == 13 && !isShabbos))
                    {
                        specialDates.Add(SpecialDates.FastOfEsther);
                    }
                    else if (day == 14)
                    {
                        specialDates.Add(SpecialDates.Purim);
                    }
                    else if (day == 15)
                    {
                        specialDates.Add(SpecialDates.ShushanPurim);
                    }
                }
                else
                {
                    if (day == 14)
                    {
                        specialDates.Add(SpecialDates.PurimKatan);
                    }
                }
                break;

            case Months.AdarII:
                if ((day == 11 && IsShabbos(date.Add(new TimeSpan(2, 0, 0, 0)))) || (day == 13 && !isShabbos))
                {
                    specialDates.Add(SpecialDates.FastOfEsther);
                }
                else if (day == 14)
                {
                    specialDates.Add(SpecialDates.Purim);
                }
                else if (day == 15)
                {
                    specialDates.Add(SpecialDates.ShushanPurim);
                }
                break;

            case Months.Nissan:
                if ((day == 14 && !isShabbos) || (day == 12 && IsShabbos(date.Add(new TimeSpan(2, 0, 0, 0)))))
                {
                    specialDates.Add(SpecialDates.FastOfTheFirstborn);
                }
                else if ((day > 14 && day < 22) || (day == 22 && !inIsrael))
                {
                    specialDates.Add(SpecialDates.Pesach);
                }
                break;

            case Months.Iyar:
                if (day == 14)
                {
                    specialDates.Add(SpecialDates.PesachSheni);
                }
                else if (day == 18)
                {
                    specialDates.Add(SpecialDates.LagBaomer);
                }
                break;

            case Months.Sivan:
                if (day == 6 || (day == 7 && !inIsrael))
                {
                    specialDates.Add(SpecialDates.Shovuos);
                }
                break;

            case Months.Tamuz:
                if ((day == 17 && !isShabbos) || (day == 18 && isYesterdayShabbos))
                {
                    specialDates.Add(SpecialDates.SeventeenthOfTamuz);
                }
                break;

            case Months.Av:
                if ((day == 9 && !isShabbos) || (day == 10 && isYesterdayShabbos))
                {
                    specialDates.Add(SpecialDates.NinthOfAv);
                }
                else if (day == 15)
                {
                    specialDates.Add(SpecialDates.TuBeAv);
                }
                break;

            case Months.Elul:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(month), month, null);
            }

            //Check if Rosh Chodesh
            if (IsRoshChodesh(date))
            {
                specialDates.Add(SpecialDates.RoshChodesh);
            }

            return(specialDates);
        }
Пример #4
0
        /// <summary>
        /// Returns what day of the week the first day of Pesach falls on, used to calculate the parshios
        /// </summary>
        /// <param name="Date">A date within the respective year, doesn't have to be Pesach</param>
        /// <returns>The day of the week that first day of Pesach falls on</returns>
        public static DayOfWeek GetPesachDayOfWeek(JewishDate Date)
        {
            HebrewCalendar hebCal = new HebrewCalendar();

            return(hebCal.GetDayOfWeek(new JewishDate(Date.Year, IsLeapYear(Date) ? 8 : 7, 15)));
        }
Пример #5
0
 /// <summary>
 /// Returns what day of the week Rosh Hashanah of that year fell on.
 /// </summary>
 /// <param name="Date">A date within the respective year, doesn't have to be Rosh Hashanah</param>
 /// <returns>The day of the week that Rosh Hashanah fell on</returns>
 public static DayOfWeek GetRHDayOfWeek(JewishDate Date)
 {
     return(GetRHDayOfWeek(Date.Year));
 }
Пример #6
0
 public static bool IsYesterdayShabbos(JewishDate date)
 {
     return(IsShabbos(date.Subtract(new TimeSpan(1, 0, 0, 0))));
 }
Пример #7
0
 public static bool IsShabbos(JewishDate date)
 {
     return(date.DayOfWeek == DayOfWeek.Saturday);
 }
Пример #8
0
 public static bool IsLeapYear(JewishDate date)
 {
     return(IsLeapYear(date.Year));
 }