double Calendar::Years(const Calendar & calendar) { Calendar * prior = this; Calendar * after = (Calendar*)&calendar; if (calendar < (*this)) { prior = (Calendar*)&calendar; after = this; } double years = prior->CalendarMonthsRemaining()/Time::MonthsPerYear; years += ((prior->Year+1)<after->Year)?after->Year-(prior->Year+1):0; if (prior->Year == after->Year) years -= after->CalendarMonthsRemaining()/Time::MonthsPerYear; else years += after->CalendarMonths()/Time::MonthsPerYear; return (calendar < (*this))?years:-years; }
double Calendar::Months(const Calendar & calendar) { Calendar * prior = this; Calendar * after = (Calendar*)&calendar; if (calendar < (*this)) { prior = (Calendar*)&calendar; after = this; } double months = prior->CalendarMonthsRemaining(); for (int year=prior->Year+1;year<after->Year;++year) months += Time::MonthsPerYear; if (prior->Year == after->Year) months -= after->CalendarMonthsRemaining(); else months += after->CalendarMonths(); return (calendar < (*this))?months:-months; }