public bool DividesDates(Date first, Date last)
{
int multiplier = this.multiplier;
Period period = this.period;
if (period == Period.TERM)
return (multiplier == 1);
if (period == Period.WEEK) {
period = Period.DAY;
multiplier *= 7;
}
if (period == Period.YEAR) {
if (first.Month != last.Month) return (false);
if (first.DayOfMonth != last.DayOfMonth) return (false);
return (((last.Year - first.Year) % multiplier) == 0);
}
if (period == Period.MONTH) {
if (first.DayOfMonth != last.DayOfMonth) return (false);
return ((((last.Year - first.Year) * 12 + last.Month - first.Month) % multiplier) == 0);
}
return (((last.GetHashCode () - first.GetHashCode ()) % multiplier) == 0);
}