/// <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 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))); } }
/// <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); }