public static CountWeekends ( this startTime, System.DateTime endTime ) : int | ||
startTime | this | The start time. |
endTime | System.DateTime | The end time. |
return | int |
public static int CountWeekends(this DateTime startTime, DateTime endTime)
{
TimeSpan ts = endTime - startTime;
int count = 0;
for (int i = 0; i < ts.Days; i++)
{
DateTime dt = startTime.AddDays(i);
if (IsWeekEnd(dt))
count++;
}
return count;
}