Пример #1
0
 /// <summary>
 /// Given an scriptural month number and a year in which it occurs, this method returns
 /// the equivalent scriptural month number.
 /// </summary>
 /// <remarks>
 /// No validation is performed in this method: an input month number of 13 in a non-leap-year
 /// will return a result of 7.
 /// </remarks>
 /// <param name="year">Year during which the month occurs.</param>
 /// <param name="month">Civil month number.</param>
 /// <returns>The scriptural month number.</returns>
 internal static int ScripturalToCivil(int year, int month)
 {
     if (month >= 7)
     {
         return(month - 6);
     }
     return(HebrewScripturalCalculator.IsLeapYear(year) ? month + 7 : month + 6);
 }
        public void DaysInYear()
        {
            var bcl     = new HebrewCalendar();
            var minYear = bcl.GetYear(bcl.MinSupportedDateTime);
            var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime);

            for (int year = minYear; year <= maxYear; year++)
            {
                Assert.AreEqual(bcl.GetDaysInYear(year), HebrewScripturalCalculator.DaysInYear(year));
            }
        }
Пример #3
0
        /// <summary>
        /// Given a civil month number and a year in which it occurs, this method returns
        /// the equivalent scriptural month number.
        /// </summary>
        /// <remarks>
        /// No validation is performed in this method: an input month number of 13 in a non-leap-year
        /// will return a result of 7.
        /// </remarks>
        /// <param name="year">Year during which the month occurs.</param>
        /// <param name="month">Civil month number.</param>
        /// <returns>The scriptural month number.</returns>
        internal static int CivilToScriptural(int year, int month)
        {
            if (month < 7)
            {
                return(month + 6);
            }
            bool leapYear = HebrewScripturalCalculator.IsLeapYear(year);

            if (month == 7) // Adar II (13) or Nisan (1) depending on whether it's a leap year.
            {
                return(leapYear ? 13 : 1);
            }
            return(leapYear ? month - 7 : month - 6);
        }
        public void DaysInMonth()
        {
            var bcl = new HebrewCalendar();
            // Not all months in the min/max years are supported
            var minYear = bcl.GetYear(bcl.MinSupportedDateTime) + 1;
            var maxYear = bcl.GetYear(bcl.MaxSupportedDateTime) - 1;

            for (int year = minYear; year <= maxYear; year++)
            {
                int months = bcl.GetMonthsInYear(year);
                for (int month = 1; month <= months; month++)
                {
                    int scripturalMonth = HebrewMonthConverter.CivilToScriptural(year, month);
                    int bclDays         = bcl.GetDaysInMonth(year, month);
                    int nodaDays        = HebrewScripturalCalculator.DaysInMonth(year, scripturalMonth);
                    Assert.AreEqual(bclDays, nodaDays);
                }
            }
        }
Пример #5
0
 public void ScripturalGetDaysFromStartOfYearToStartOfMonth_InvalidForCoverage()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => HebrewScripturalCalculator.GetDaysFromStartOfYearToStartOfMonth(5502, 0));
 }