示例#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
            });
        }