-
Notifications
You must be signed in to change notification settings - Fork 0
/
Holiday.cs
144 lines (128 loc) · 6.66 KB
/
Holiday.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interweb.CalendarCalculator
{
/******************************************************************************************************************
* This class holds the whole structure of a holiday
*
* Basic structure of a holiday formula: "type:modifier"
* Basic rule: The Fixed holiday type "F" needs day and month modifier seperated by ".",
* all others an int offset value.
*
* F:25.12 => Fixed holiday on 25 Dec.
* E:-49 => Floating holiday 49 days before Easter Sunday
* E:1 => Floating holiday 1 day after Easter Sunday
* E:0 => Easter Sunday
* MD:0 => Mothers Day
* AD:0 => 4th Advdent
* AD:-7 => 3rd Advent
* RP:0 => RepentanceAndPrayer (German "Buß und Bettag")
*
* Last update: 15.05.2010
******************************************************************************************************************/
//-----------------------------------------------------------------------------------------------------------------
public class Holiday
//-----------------------------------------------------------------------------------------------------------------
{
int _holidayID;
string _holidayName;
string _holidayFormulaType;
int _holidayFormulaOffset;
int _holidayFormulaDay;
int _holidayFormulaMonth;
int _holidayDuration;
DateTime _holidayValidFrom;
DateTime _holidayValidTo;
//-----------------------------------------------------------------------------------------------------------------
public Holiday(int holidayID, string holidayName, string holidayFormula, int holidayDuration, DateTime holidayValidFrom, DateTime holidayValidTo)
//-----------------------------------------------------------------------------------------------------------------
{
string[] formula = holidayFormula.Trim().ToUpper().Split(':');
string[] dayAndMonth;
this._holidayID = holidayID;
this._holidayName = holidayName;
this._holidayDuration = holidayDuration;
this._holidayValidFrom = holidayValidFrom;
this._holidayValidTo = holidayValidTo;
this._holidayFormulaType = formula[0];
if (this._holidayFormulaType == "F")
{
dayAndMonth = formula[1].Split('.');
this._holidayFormulaOffset = 0;
this._holidayFormulaDay = int.Parse(dayAndMonth[0]);
this._holidayFormulaMonth = int.Parse(dayAndMonth[1]);
}
else
{
this._holidayFormulaOffset = int.Parse( formula[1] );
this._holidayFormulaDay = 0;
this._holidayFormulaMonth = 0;
}
}
//-----------------------------------------------------------------------------------------------------------------
public int HolidayID
//-----------------------------------------------------------------------------------------------------------------
{
get { return( this._holidayID ); }
}
//-----------------------------------------------------------------------------------------------------------------
public string HolidayName
//-----------------------------------------------------------------------------------------------------------------
{
get { return( this._holidayName ); }
}
//-----------------------------------------------------------------------------------------------------------------
public string HolidayFormulaType
//-----------------------------------------------------------------------------------------------------------------
{
get { return( this._holidayFormulaType ); }
}
//-----------------------------------------------------------------------------------------------------------------
public int HolidayFormulaOffset
//-----------------------------------------------------------------------------------------------------------------
{
get { return (this._holidayFormulaOffset); }
}
//-----------------------------------------------------------------------------------------------------------------
public int HolidayFormulaDay
//-----------------------------------------------------------------------------------------------------------------
{
get { return (this._holidayFormulaDay); }
}
//-----------------------------------------------------------------------------------------------------------------
public int HolidayFormulaMonth
//-----------------------------------------------------------------------------------------------------------------
{
get { return (this._holidayFormulaMonth); }
}
//-----------------------------------------------------------------------------------------------------------------
public string HolidayFormula
//-----------------------------------------------------------------------------------------------------------------
{
get { return( this._holidayFormulaType == "F" ?
"F:" + this._holidayFormulaDay.ToString() + "." + this._holidayFormulaMonth.ToString() :
this._holidayFormulaType + ":" + this._holidayFormulaOffset.ToString() );
}
}
//-----------------------------------------------------------------------------------------------------------------
public int HolidayDuration
//-----------------------------------------------------------------------------------------------------------------
{
get { return( this._holidayDuration ); }
}
//-----------------------------------------------------------------------------------------------------------------
public DateTime HolidayValidFrom
//-----------------------------------------------------------------------------------------------------------------
{
get { return this._holidayValidFrom; }
}
//-----------------------------------------------------------------------------------------------------------------
public DateTime HolidayValidTo
//-----------------------------------------------------------------------------------------------------------------
{
get { return( this._holidayValidTo ); }
}
}
}