public static YearAndHalfyear PreviousHalfyear(HalfyearKind startHalfyearKind) { int year; HalfyearKind halfyear; PreviousHalfyear(startHalfyearKind, out year, out halfyear); return new YearAndHalfyear(year, halfyear); }
public static DateTime EndTimeOfHalfyear(this int year, HalfyearKind halfyearKind, int yearStartMonth = TimeSpec.CalendarYearStartMonth) { return (StartTimeOfHalfyear(new DateTime(year, TimeSpec.MonthsPerHalfyear * (int)halfyearKind + 1, 1), yearStartMonth) .AddMonths(TimeSpec.MonthsPerYear) .Add(TimeSpec.MinNegativeDuration)); }
public static void AddHalfyear(int startYear, HalfyearKind startHalfyearKind, int count, out int year, out HalfyearKind halfyear) { int offsetYear = (Math.Abs(count) / TimeSpec.HalfyearsPerYear) + 1; int startHalfyearCount = ((startYear + offsetYear) * TimeSpec.HalfyearsPerYear) + ((int)startHalfyearKind - 1); int targetHalfyearCount = startHalfyearCount + count; year = (targetHalfyearCount / TimeSpec.HalfyearsPerYear) - offsetYear; halfyear = (HalfyearKind)((targetHalfyearCount % TimeSpec.HalfyearsPerYear) + 1); }
public static YearAndHalfyear PreviousHalfyear(HalfyearKind startHalfyearKind) { int year; HalfyearKind halfyear; PreviousHalfyear(startHalfyearKind, out year, out halfyear); return(new YearAndHalfyear(year, halfyear)); }
public static YearAndHalfyear AddHalfyear(this HalfyearKind startHalfyearKind, int startYear, int count) { int year; HalfyearKind halfyear; AddHalfyear(startYear, startHalfyearKind, count, out year, out halfyear); return(new YearAndHalfyear(year, halfyear)); }
private static TimeRange GetPeriodOf(int baseMonth, int year, HalfyearKind halfyear, int halfyearCount) { halfyearCount.ShouldBePositive("halfyearCount"); var yearStart = new DateTime(year, baseMonth, 1); var start = yearStart.AddMonths(((int)halfyear - 1) * TimeSpec.MonthsPerHalfyear); var end = start.AddMonths(halfyearCount * TimeSpec.MonthsPerHalfyear); return(new TimeRange(start, end)); }
protected HalfyearTimeRange(int startYear, HalfyearKind startHalfyearKind, int halfyearCount, ITimeCalendar calendar) : base(GetPeriodOf(calendar.YearBaseMonth, startYear, startHalfyearKind, halfyearCount), calendar) { StartYear = startYear; StartHalfyear = startHalfyearKind; HalfyearCount = halfyearCount; var endYearAndHalfyear = TimeTool.AddHalfyear(startHalfyearKind, startYear, halfyearCount - 1); EndYear = endYearAndHalfyear.Year ?? StartYear; EndHalfyear = endYearAndHalfyear.Halfyear ?? StartHalfyear; }
public static int[] GetMonthsOfHalfyear(this HalfyearKind halfyear) { switch (halfyear) { case HalfyearKind.First: return(TimeSpec.FirstHalfyearMonths); case HalfyearKind.Second: return(TimeSpec.SecondHalfyearMonths); } throw new InvalidOperationException("Invalid year halfyear " + halfyear); }
/// <summary> /// 지정한 달력 기준으로 지정된 년도의 반기(전반기/후반기)의 기간 /// </summary> public static TimeSpan Halfyear(int year, HalfyearKind halfyear = HalfyearKind.First, Calendar calendar = null) { calendar = calendar ?? CurrentCalendar; var halfyearMonths = TimeTool.GetMonthsOfHalfyear(halfyear); var duration = TimeSpec.NoDuration; foreach (var halfyearMonth in halfyearMonths) { duration = duration.Add(Month(year, halfyearMonth, calendar)); } return(duration); }
/// <summary> /// 지정한 년도의 반기를 표현하는 문자열을 반환합니다. /// </summary> /// <param name="year"></param> /// <param name="halfyear"></param> /// <returns></returns> public string GetHalfYearOfYearName(int year, HalfyearKind halfyear) { switch (YearKind) { case YearKind.CalendarYear: return(TimeStrings.CalendarHalfyearOfYearName(halfyear, year)); case YearKind.FiscalYear: return(TimeStrings.FiscalHalfyearOfYearName(halfyear, year)); case YearKind.SchoolYear: return(TimeStrings.SchoolHalfyearOfYearName(halfyear, year)); default: return(TimeStrings.SystemHalfyearOfYearName(halfyear, year)); } }
public void SingleHalfyearsTest() { const int startYear = 2004; const HalfyearKind startHalfyear = HalfyearKind.Second; var halfyears = new HalfyearRangeCollection(startYear, startHalfyear, 1); halfyears.YearBaseMonth.Should().Be(1); halfyears.HalfyearCount.Should().Be(1); halfyears.StartHalfyear.Should().Be(startHalfyear); halfyears.StartYear.Should().Be(startYear); halfyears.EndYear.Should().Be(startYear); halfyears.EndHalfyear.Should().Be(HalfyearKind.Second); var halfyearList = halfyears.GetHalfyears().ToList(); halfyearList.Count.Should().Be(1); halfyearList[0].IsSamePeriod(new HalfyearRange(2004, HalfyearKind.Second)).Should().Be.True(); }
public void SecondCalendarHalfyearsTest() { const int startYear = 2004; const HalfyearKind startHalfyear = HalfyearKind.Second; const int halfyearCount = 3; var halfyears = new HalfyearRangeCollection(startYear, startHalfyear, halfyearCount); halfyears.YearBaseMonth.Should().Be(1); halfyears.HalfyearCount.Should().Be(halfyearCount); halfyears.StartHalfyear.Should().Be(startHalfyear); halfyears.StartYear.Should().Be(startYear); halfyears.EndYear.Should().Be(2005); halfyears.EndHalfyear.Should().Be(HalfyearKind.Second); var halfyearList = halfyears.GetHalfyears().ToList(); halfyearList.Count.Should().Be(halfyearCount); Assert.IsTrue(halfyearList[0].IsSamePeriod(new HalfyearRange(2004, HalfyearKind.Second))); Assert.IsTrue(halfyearList[1].IsSamePeriod(new HalfyearRange(2005, HalfyearKind.First))); Assert.IsTrue(halfyearList[2].IsSamePeriod(new HalfyearRange(2005, HalfyearKind.Second))); }
public static void AddHalfyear(HalfyearKind startHalfyearKind, int count, out int year, out HalfyearKind halfyear) { AddHalfyear(0, startHalfyearKind, count, out year, out halfyear); }
public static void NextHalfyear(HalfyearKind startHalfyearKind, out int year, out HalfyearKind halfyear) { AddHalfyear(startHalfyearKind, 1, out year, out halfyear); }
public HalfyearRange(int year, HalfyearKind halfyear) : this(year, halfyear, new TimeCalendar()) {}
public static void PreviousHalfyear(HalfyearKind startHalfyearKind, out int year, out HalfyearKind halfyear) { AddHalfyear(startHalfyearKind, -1, out year, out halfyear); }
public static string SystemHalfyearName(HalfyearKind halfyear) { return(Format(SystemHalfYearNameFormat, (int)halfyear)); }
public static YearAndHalfyear AddHalfyear(this HalfyearKind startHalfyearKind, int count) { return(AddHalfyear(startHalfyearKind, 0, count)); }
public HalfyearRangeCollection(int year, HalfyearKind halfyear, int halfyearCount, ITimeCalendar calendar) : base(year, halfyear, halfyearCount, calendar) {}
public HalfyearRange(int year, HalfyearKind halfyear) : this(year, halfyear, new TimeCalendar()) { }
public static string SystemHalfyearName(HalfyearKind halfyear) { return Format(SystemHalfYearNameFormat, (int)halfyear); }
public static string CalendarHalfyearOfYearName(HalfyearKind halfyear, int year) { return Format(CalendarHalfyearOfYearNameFormat, (int)halfyear, year); }
public HalfyearRange(int year, HalfyearKind halfyear, ITimeCalendar calendar) : base(year, halfyear, 1, calendar) {}
private static TimeRange GetPeriodOf(int baseMonth, int year, HalfyearKind halfyear, int halfyearCount) { halfyearCount.ShouldBePositive("halfyearCount"); var yearStart = new DateTime(year, baseMonth, 1); var start = yearStart.AddMonths(((int)halfyear - 1) * TimeSpec.MonthsPerHalfyear); var end = start.AddMonths(halfyearCount * TimeSpec.MonthsPerHalfyear); return new TimeRange(start, end); }
public HalfyearRangeCollection(int year, HalfyearKind halfyear, int halfyearCount) : this(year, halfyear, halfyearCount, new TimeCalendar()) { }
public static string CalendarHalfyearOfYearName(HalfyearKind halfyear, int year) { return(Format(CalendarHalfyearOfYearNameFormat, (int)halfyear, year)); }
public HalfyearRangeCollection(int year, HalfyearKind halfyear, int halfyearCount, ITimeCalendar calendar) : base(year, halfyear, halfyearCount, calendar) { }
public static DateTime StartTimeOfHalfyear(this int year, HalfyearKind halfyearKind, int yearStartMonth = TimeSpec.CalendarYearStartMonth) { return(StartTimeOfHalfyear(new DateTime(year, TimeSpec.MonthsPerHalfyear * (int)halfyearKind + 1, 1), yearStartMonth)); }
public HalfyearRange(int year, HalfyearKind halfyear, ITimeCalendar calendar) : base(year, halfyear, 1, calendar) { }
public static int StartMonthOfHalfyear(this HalfyearKind half) { return(((int)half - 1) * TimeSpec.MonthsPerHalfyear + 1); }
public static string FiscalHalfyearName(HalfyearKind halfyear) { return(Format(FiscalHalfYearNameFormat, (int)halfyear)); }
public static string SchoolHalfyearOfYearName(HalfyearKind halfyear, int year) { return(Format(SchoolHalfyearOfYearNameFormat, (int)halfyear, year)); }
public static DateTime StartTimeOfHalfyear(this int year, HalfyearKind halfyearKind, int yearStartMonth = TimeSpec.CalendarYearStartMonth) { return StartTimeOfHalfyear(new DateTime(year, TimeSpec.MonthsPerHalfyear * (int)halfyearKind + 1, 1), yearStartMonth); }
public static int EndMonthOfHalfyear(this HalfyearKind half) { return(half.StartMonthOfHalfyear() + TimeSpec.MonthsPerHalfyear - 1); }
public static string FiscalHalfyearName(HalfyearKind halfyear) { return Format(FiscalHalfYearNameFormat, (int)halfyear); }
public static DateTime EndTimeOfHalfyear(this int year, HalfyearKind halfyearKind, int yearStartMonth = TimeSpec.CalendarYearStartMonth) { return StartTimeOfHalfyear(new DateTime(year, TimeSpec.MonthsPerHalfyear * (int)halfyearKind + 1, 1), yearStartMonth) .AddMonths(TimeSpec.MonthsPerYear) .Add(TimeSpec.MinNegativeDuration); }
public static string SchoolHalfyearOfYearName(HalfyearKind halfyear, int year) { return Format(SchoolHalfyearOfYearNameFormat, (int)halfyear, year); }
public HalfyearRangeCollection(int year, HalfyearKind halfyear, int halfyearCount) : this(year, halfyear, halfyearCount, new TimeCalendar()) {}