Esempio n. 1
0
        public CalendarTimesViewModel getViewModel()
        {
            JewishCalendar cal = new JewishCalendar();
            //create the view model
            CalendarTimesViewModel vm = new CalendarTimesViewModel();
            DateTime date             = calModel.date.GetValueOrDefault();

            vm.DafYomiBavli         = cal.GetDafYomiBavli(date);
            vm.DayOfChanukah        = cal.GetDayOfChanukah(date);
            vm.DayOfOmer            = cal.GetDayOfOmer(date);
            vm.isChanukah           = cal.IsChanukah(date);
            vm.isCholHamoed         = cal.IsCholHamoed(date, calModel.isIsrael);
            vm.isErevRoshChodesh    = cal.IsErevRoshChodesh(date);
            vm.isErevYomTov         = cal.IsErevYomTov(date, calModel.isIsrael);
            vm.isRoshChodesh        = cal.IsRoshChodesh(date);
            vm.isTaanis             = cal.IsTaanis(date, calModel.isIsrael);
            vm.isYomTov             = cal.IsYomTov(date, calModel.isIsrael);
            vm.isYomTovIssurMelacha = cal.IsYomTovAssurBemelacha(date, calModel.isIsrael);
            vm.JewishHoliday        = cal.GetJewishHoliday(date, calModel.isIsrael);
            vm.JewishMonth          = cal.GetJewishMonth(date);
            vm.JewishYearType       = cal.GetJewishYearType(date);
            return(vm);
        }
Esempio n. 2
0
 public void Setup()
 {
     jewishCalendar    = new JewishCalendar();
     gregorianCalendar = new GregorianCalendar();
 }
Esempio n. 3
0
        public JewishCalendar.Parsha Israel(int year, int month, int day)
        {
            var jewishCalendar = new JewishCalendar();

            return(jewishCalendar.GetParshah(new DateTime(year, month, day), true));
        }
Esempio n. 4
0
        //Todo:
        //Add logic for parshios finding. Generate the year types
        //Check if YomTov
        //Check if Special Shabbos
        //Return TorahReading/TorahPortion

        /// <summary>
        /// Gets the TorahPortion that is read on that week's Shabbos. If, however, a YomTov falls on the Shabbos, and the Parsha gets postponed, it returns null.
        /// </summary>
        /// <param name="Date">Jewish Date in that week</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(JewishDate Date, bool inIsrael)
        {
            HebrewCalendar hebCal = new HebrewCalendar();

            Date = Date.FindNextDay(DayOfWeek.Saturday); //Assign Date to the following Shabbos

            int week = hebCal.GetWeekOfYear(Date, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);

            int  rhStartDay = (int)JewishCalendar.GetRHDayOfWeek(Date) + 1;
            int  addedDays  = Convert.ToInt32(!JewishCalendar.IsCheshvanShort(Date.Year)) + Convert.ToInt32(JewishCalendar.IsKislevLong(Date.Year));//Either 0,1 or 2
            bool isLeap     = JewishCalendar.IsLeapYear(Date);

            if (!isLeap)
            {
                switch (rhStartDay)
                {
                case 2:
                    if (addedDays == 0 || (addedDays == 2 && inIsrael))
                    {
                        return(MonShort_MonLongIsrael_TueNormalIsrael[week - 1]);
                    }
                    else
                    {
                        return(MonLong_TueNormal[week - 1]);
                    }
                    break;

                case 3:
                    if (inIsrael)
                    {
                        return(MonShort_MonLongIsrael_TueNormalIsrael[week - 1]);
                    }
                    else
                    {
                        return(MonLong_TueNormal[week - 1]);
                    }
                    break;

                case 5:
                    if (addedDays == 1)
                    {
                        return(inIsrael ? ThuNormalIsrael[week - 1] : ThuNormal[week - 1]);
                    }
                    else
                    {
                        return(ThuLong[week - 1]);
                    }
                    break;

                case 7:
                    if (addedDays == 0)
                    {
                        return(SatShort[week - 1]);
                    }
                    else
                    {
                        return(SatLong[week - 1]);
                    }
                    break;

                default:
                    throw new NotSupportedException("This type of year doesn't exist: " + rhStartDay + ", " + addedDays + ", " + isLeap);
                    break;
                }
            }
            else
            {
                switch (rhStartDay)
                {
                case 2:
                    if (addedDays == 0)
                    {
                        return(inIsrael ? MonShortLeapIsrael[week - 1] : MonShortLeap[week - 1]);
                    }
                    else
                    {
                        return(inIsrael ? MonLongLeapIsrael_TueNormalLeapIsrael[week - 1] : MonLongLeap_TueNormalLeap[week - 1]);
                    }
                    break;

                case 3:
                    return(inIsrael ? MonLongLeapIsrael_TueNormalLeapIsrael[week - 1] : MonLongLeap_TueNormalLeap[week - 1]);

                    break;

                case 5:
                    if (addedDays == 0)
                    {
                        return(ThuShortLeap[week - 1]);
                    }
                    else
                    {
                        return(ThuLongLeap[week - 1]);
                    }
                    break;

                case 7:
                    if (addedDays == 0 || (addedDays == 2 && inIsrael))
                    {
                        return(SatShortLeap_SatLongLeapIsrael[week - 1]);
                    }
                    else
                    {
                        return(SatLongLeap[week - 1]);
                    }
                    break;

                default:
                    throw new NotSupportedException("This type of year doesn't exist: " + rhStartDay + ", " + addedDays + ", " + isLeap);
                    break;
                }
            }
        }
Esempio n. 5
0
        public void OutsideIsraelList(ParshaMap parshaMap)
        {
            var jewishCalendar = new JewishCalendar();

            Assert.That(jewishCalendar.GetParshah(DateTime.Parse(parshaMap.Date)), Is.EqualTo(parshaMap.Name));
        }