} // Round // ---------------------------------------------------------------------- private int CalcYears() { if (TimeCompare.IsSameMonth(date1, date2)) { return(0); } int compareDay = date2.Day; int compareDaysPerMonth = calendar.GetDaysInMonth(Year1, Month2); if (compareDay > compareDaysPerMonth) { compareDay = compareDaysPerMonth; } DateTime compareDate = new DateTime(Year1, Month2, compareDay, date2.Hour, date2.Minute, date2.Second, date2.Millisecond); if (date2 > date1) { if (compareDate < date1) { compareDate = compareDate.AddYears(1); } } else { if (compareDate > date1) { compareDate = compareDate.AddYears(-1); } } return(Year2 - calendar.GetYear(compareDate)); } // CalcYears
} // CalcYears // ---------------------------------------------------------------------- private int CalcQuarters() { if (TimeCompare.IsSameMonth(date1, date2)) { return(0); } int year1 = TimeTool.GetYearOf(yearBaseMonth, Year1, Month1); YearQuarter quarter1 = TimeTool.GetQuarterOfMonth(yearBaseMonth, (YearMonth)Month1); int year2 = TimeTool.GetYearOf(yearBaseMonth, Year2, Month2); YearQuarter quarter2 = TimeTool.GetQuarterOfMonth(yearBaseMonth, (YearMonth)Month2); return (((year2 * TimeSpec.QuartersPerYear) + quarter2) - ((year1 * TimeSpec.QuartersPerYear) + quarter1)); } // CalcQuarters