private void Calculate() { if(CalendarType.FarthestInTime(date1, date2) == 1) differenceLabel.Text = CalendarType.daysBetween(date2, date1).ToString() + " days"; else differenceLabel.Text = CalendarType.daysBetween(date1, date2).ToString() + " days"; }
public void checkIfTimerPassed() { if (currentCalendar.activeCampaign != null) { foreach (Timer t in currentCalendar.activeCampaign.timers) { t.AdjustForPause(currentCalendar.calendar); // If paused, adjust timer // If the current date is same date a timer (0 means same date) if (CalendarType.FarthestInTime(t.returnDateString(), currentCalendar.calendar.ToString()) == 0) { if (MessageBox.Show(this, t.message + "\n\nCreate a note?", "Timer Reached", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { new EditNotesDialog(new Note(t.returnDateString(), AlertScope.campaign, t.message, currentCalendar.activeCampaign), currentCalendar).ShowDialog(this); } // Remove, then restart updating (can't remove and iterate) currentCalendar.activeCampaign.timers.Remove(t); checkIfTimerPassed(); return; } else if (CalendarType.FarthestInTime(t.returnDateString(), currentCalendar.calendar.ToString()) < 0) { if (MessageBox.Show(this, t.message + " (" + CalendarType.returnGivenDateWithWeekday(t.returnDateString()) + ")" + "\n\nCreate a note?", "Timer Passed", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { new EditNotesDialog(new Note(t.returnDateString(), AlertScope.campaign, t.message, currentCalendar.activeCampaign), currentCalendar).ShowDialog(this); } if (MessageBox.Show(this, "Go to date? (" + CalendarType.returnGivenDateWithWeekday(t.returnDateString()) + ")", "Go to date", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { currentCalendar.calendar.setDate(t.returnDateString()); } // Remove, then restart updating (can't remove and iterate) currentCalendar.activeCampaign.timers.Remove(t); checkIfTimerPassed(); return; } } } }
// Returns 1 if x happened after y, -1 if y happened after x, 0 if same date public static int compareNotes(Note x, Note y) { return(CalendarType.FarthestInTime(x.date, y.date)); }