/// <summary> /// Return the next occurrence (from the current system date) of this UserOccasion /// </summary> /// <returns></returns> public DateTime GetUpcomingOccurence() { DateTime now = DateTime.Now; DateTime retVal = now; JewishDate todayJd = new JewishDate(now); switch (this.UserOccasionType) { case UserOccasionTypes.OneTime: //return setting date retVal = this.JewishDate.GregorianDate; break; case UserOccasionTypes.HebrewDateRecurringYearly: var jdYearly = new JewishDate(todayJd.Year, this.JewishDate.Month, this.JewishDate.Day); while (jdYearly.GregorianDate < now) { jdYearly = jdYearly.AddYears(1); } retVal = jdYearly.GregorianDate; break; case UserOccasionTypes.HebrewDateRecurringMonthly: var jdMonthly = new JewishDate(todayJd.Year, todayJd.Month, this.JewishDate.Day); while (jdMonthly.GregorianDate < now) { jdMonthly = jdMonthly.AddMonths(1); } retVal = jdMonthly.GregorianDate; break; case UserOccasionTypes.SecularDateRecurringYearly: retVal = new DateTime(now.Year, this.SecularDate.Month, this.SecularDate.Day, now.Hour, now.Minute, now.Second, now.Millisecond); while (retVal < now) { retVal = retVal.AddYears(1); } break; case UserOccasionTypes.SecularDateRecurringMonthly: retVal = new DateTime(now.Year, now.Month, this.SecularDate.Day, now.Hour, now.Minute, now.Second, now.Millisecond); while (retVal < now) { retVal = retVal.AddMonths(1); } break; } return(retVal); }
private void FillDateCombos() { this.cmbMonth.ValueMember = "Key"; this.cmbMonth.DisplayMember = "Value"; this.cmbYear.ValueMember = "Key"; this.cmbYear.DisplayMember = "Value"; var now = new JewishDate(); var monthToDisplay = now.Day > 12 ? now.AddMonths(1) : now; KeyValuePair <int, string> month = new KeyValuePair <int, string>(); KeyValuePair <int, string> year = new KeyValuePair <int, string>(); for (int i = monthToDisplay.Year - 2; i <= monthToDisplay.Year + 2; i++) { var kvp = new KeyValuePair <int, string>(i, Utils.ToNumberHeb(i % 1000)); this.cmbYear.Items.Add(kvp); if (i == monthToDisplay.Year) { year = kvp; } } for (int i = 1; i <= 13; i++) { var kvp = new KeyValuePair <int, string>(i, Utils.JewishMonthNamesHebrew[i]); this.cmbMonth.Items.Add(kvp); if (i == monthToDisplay.Month) { month = kvp; } } this.cmbMonth.SelectedItem = month; this.cmbYear.SelectedItem = year; this.jdpFrom.Value = now; this.jdpTo.Value = monthToDisplay; }