forked from Giannoudis/TimePeriodLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHalfyears.cs
67 lines (57 loc) · 2.53 KB
/
Halfyears.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// -- FILE ------------------------------------------------------------------
// name : Halfyears.cs
// project : Itenso Time Period
// created : Jani Giannoudis - 2011.02.18
// language : C# 4.0
// environment: .NET 2.0
// copyright : (c) 2011-2012 by Itenso GmbH, Switzerland
// --------------------------------------------------------------------------
using System;
namespace Itenso.TimePeriod
{
// ------------------------------------------------------------------------
public sealed class Halfyears : HalfyearTimeRange
{
// ----------------------------------------------------------------------
public Halfyears( DateTime moment, YearHalfyear startHalfyear, int count ) :
this( moment, startHalfyear, count, new TimeCalendar() )
{
} // 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
// ----------------------------------------------------------------------
public Halfyears( int startYear, YearHalfyear startHalfyear, int halfyearCount ) :
this( startYear, startHalfyear, halfyearCount, new TimeCalendar() )
{
} // Halfyears
// ----------------------------------------------------------------------
public Halfyears( int startYear, YearHalfyear startHalfyear, int halfyearCount, ITimeCalendar calendar ) :
base( startYear, startHalfyear, halfyearCount, calendar )
{
} // Halfyears
// ----------------------------------------------------------------------
public ITimePeriodCollection GetHalfyears()
{
TimePeriodCollection halfyears = new TimePeriodCollection();
for ( int i = 0; i < HalfyearCount; i++ )
{
int year;
YearHalfyear halfyear;
TimeTool.AddHalfyear( BaseYear, StartHalfyear, i, out year, out halfyear );
halfyears.Add( new Halfyear( year, halfyear, Calendar ) );
}
return halfyears;
} // GetHalfyears
// ----------------------------------------------------------------------
protected override string Format( ITimeFormatter formatter )
{
return formatter.GetCalendarPeriod( StartHalfyearOfYearName, EndHalfyearOfYearName,
formatter.GetShortDate( Start ), formatter.GetShortDate( End ), Duration );
} // Format
} // class Halfyears
} // namespace Itenso.TimePeriod
// -- EOF -------------------------------------------------------------------