forked from Giannoudis/TimePeriodLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Days.cs
64 lines (54 loc) · 2.27 KB
/
Days.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
// -- FILE ------------------------------------------------------------------
// name : Days.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 Days : DayTimeRange
{
// ----------------------------------------------------------------------
public Days( DateTime moment, int count ) :
this( moment, count, new TimeCalendar() )
{
} // Days
// ----------------------------------------------------------------------
public Days( DateTime moment, int count, ITimeCalendar calendar ) :
this( calendar.GetYear( moment ), calendar.GetMonth( moment ), calendar.GetDayOfMonth( moment ), count, calendar )
{
} // Days
// ----------------------------------------------------------------------
public Days( int startYear, int startMonth, int startDay, int dayCount ) :
this( startYear, startMonth, startDay, dayCount, new TimeCalendar() )
{
} // Days
// ----------------------------------------------------------------------
public Days( int startYear, int startMonth, int startDay, int dayCount, ITimeCalendar calendar ) :
base( startYear, startMonth, startDay, dayCount, calendar )
{
} // Days
// ----------------------------------------------------------------------
public ITimePeriodCollection GetDays()
{
TimePeriodCollection days = new TimePeriodCollection();
DateTime startDay = new DateTime( StartYear, StartMonth, StartDay );
for ( int i = 0; i < DayCount; i++ )
{
days.Add( new Day( startDay.AddDays( i ), Calendar ) );
}
return days;
} // GetDays
// ----------------------------------------------------------------------
protected override string Format( ITimeFormatter formatter )
{
return formatter.GetCalendarPeriod( StartDayName, EndDayName,
formatter.GetShortDate( Start ), formatter.GetShortDate( End ), Duration );
} // Format
} // class Days
} // namespace Itenso.TimePeriod
// -- EOF -------------------------------------------------------------------