-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass
39 lines (32 loc) · 1.07 KB
/
class
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
public static int CountOffDays (DateTime start,DateTime end)
{
int res = 0;
DateTime dt;
dt = start;
while (dt <= end)
{
if (dt.DayOfWeek == DayOfWeek.Friday || dt.DayOfWeek == DayOfWeek.Saturday)
{
res = 1 + res;
}
dt = dt.AddDays(1);
}
return res;
}
public static DateTime[] OffDays(DateTime start, DateTime end)
{
//int ii = CountOffDays(start,end);
DateTime[] res = new DateTime[CountOffDays(start, end)];
DateTime dt;int i = 0;
dt = start;
while (dt <= end)
{
if (dt.DayOfWeek == DayOfWeek.Friday || dt.DayOfWeek == DayOfWeek.Saturday)
{
res[i] = dt;
i = i + 1;
}
dt = dt.AddDays(1);
}
return res;
}