//Octavalent Extension Methods
//http://sdfasdf.codeplex.com/
//Library of extension methods for .Net create by Octavalent (www.octavalent.nl)
using System;
public static class DateTimeExtensions
{
public static DateTime AddBusinessDays(this DateTime date, int days)
{
int sign = Math.Sign(days);
int unsignedDays = Math.Abs(days);
for (int i = 0; i < unsignedDays; i++)
{
do
{
date = date.AddDays(sign);
} while (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday);
}
return date;
}
}
|