} // IsSameQuarter // ---------------------------------------------------------------------- public static bool IsSameQuarter(YearMonth yearStartMonth, DateTime left, DateTime right) { int leftYear = TimeTool.GetYearOf(yearStartMonth, left); int rightYear = TimeTool.GetYearOf(yearStartMonth, right); if (leftYear != rightYear) { return(false); } return(TimeTool.GetQuarterOfMonth(yearStartMonth, (YearMonth)left.Month) == TimeTool.GetQuarterOfMonth(yearStartMonth, (YearMonth)right.Month)); } // IsSameQuarter
} // 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
} // IsSameYear // ---------------------------------------------------------------------- public static bool IsSameYear(YearMonth yearStartMonth, DateTime left, DateTime right) { return(TimeTool.GetYearOf(yearStartMonth, left) == TimeTool.GetYearOf(yearStartMonth, right)); } // IsSameYear
} // Quarter // ---------------------------------------------------------------------- public Quarter(DateTime moment, ITimeCalendar calendar) : this(TimeTool.GetYearOf(calendar.YearBaseMonth, calendar.GetYear(moment), calendar.GetMonth(moment)), TimeTool.GetQuarterOfMonth(calendar.YearBaseMonth, (YearMonth)moment.Month), calendar) { } // Quarter
} // Years // ---------------------------------------------------------------------- public Years(DateTime moment, int count, ITimeCalendar calendar) : this(TimeTool.GetYearOf(calendar.YearBaseMonth, calendar.GetYear(moment), calendar.GetMonth(moment)), count, calendar) { } // Years
} // Halfyear // ---------------------------------------------------------------------- public Halfyear(DateTime moment, ITimeCalendar calendar) : this(TimeTool.GetYearOf(calendar.YearBaseMonth, calendar.GetYear(moment), calendar.GetMonth(moment)), TimeTool.GetHalfyearOfMonth(calendar.YearBaseMonth, (YearMonth)calendar.GetMonth(moment)), calendar) { } // Halfyear
} // Halfyears // ---------------------------------------------------------------------- public Halfyears(DateTime moment, YearHalfyear startHalfyear, int count, ITimeCalendar calendar) : this(TimeTool.GetYearOf(calendar.YearBaseMonth, calendar.GetYear(moment), calendar.GetMonth(moment)), startHalfyear, count, calendar) { } // Halfyears
} // Quarters // ---------------------------------------------------------------------- public Quarters(DateTime moment, YearQuarter startYearQuarter, int count, ITimeCalendar calendar) : this(TimeTool.GetYearOf(calendar.YearBaseMonth, calendar.GetYear(moment), calendar.GetMonth(moment)), startYearQuarter, count, calendar) { } // Quarters