public Interval Plus(Interval other)
{
// One of the Intervals is zero length?
if (multiplier == 0) return (other);
if (other.multiplier == 0) return (this);
// Both Intervals have the same unit?
if (period == other.period)
return (new Interval (multiplier + other.multiplier, period));
// Otherwise check for equivalences
if ((period == Period.YEAR) && (other.period == Period.MONTH))
return (new Interval (12 * multiplier + other.multiplier, Period.MONTH));
if ((period == Period.MONTH) && (other.period == Period.YEAR))
return (new Interval (multiplier + 12 * other.multiplier, Period.MONTH));
if ((period == Period.WEEK) && (other.period == Period.DAY))
return (new Interval (7 * multiplier + other.multiplier, Period.DAY));
if ((period == Period.DAY) && (other.period == Period.WEEK))
return (new Interval (multiplier + 7 * other.multiplier, Period.DAY));
throw new ArgumentException ("Intervals cannot be combined");
}