public static GetMonthsOfQuarter ( this quarter ) : int[] | ||
quarter | this | |
Résultat | int[] |
public void GetMonthsOfQuarterTest() { Assert.AreEqual(TimeSpec.FirstQuarterMonths, TimeTool.GetMonthsOfQuarter(QuarterKind.First)); Assert.AreEqual(TimeSpec.SecondQuarterMonths, TimeTool.GetMonthsOfQuarter(QuarterKind.Second)); Assert.AreEqual(TimeSpec.ThirdQuarterMonths, TimeTool.GetMonthsOfQuarter(QuarterKind.Third)); Assert.AreEqual(TimeSpec.FourthQuarterMonths, TimeTool.GetMonthsOfQuarter(QuarterKind.Fourth)); }
/// <summary> /// 지정한 달력 기준으로 지정년도, 분기의 기간을 구합니다. /// </summary> /// <param name="calendar"></param> /// <param name="year"></param> /// <param name="quarter"></param> /// <returns></returns> public static TimeSpan Quarter(int year, QuarterKind quarter = QuarterKind.First, Calendar calendar = null) { calendar = calendar ?? CurrentCalendar; var quarterMonths = TimeTool.GetMonthsOfQuarter(quarter); var duration = TimeSpec.NoDuration; foreach (var quarterMonth in quarterMonths) { duration = duration.Add(Month(year, quarterMonth, calendar)); } return(duration); }