is there a formula to calculate recurrence
I'm using ASP.Net MVC2. I would like to know if there is there a formula to calculate recurre开发者_StackOverflownce date? So from my client side I'm selecting dates and using ajax.post to send to the controller. My expecting result would be like so for example:
maxdate is September 30th currentdate is today duration is 3 days for every week
so output would be aug12-aug14 aug19-aug21 aug26-28 until the end of september
Enumerable.Range(0, int.MaxValue)
.Select(i => new
{
start = DateTime.Today.AddDays(7*i),
end = DateTime.Today.AddDays(7*i + 2)
})
.TakeWhile(d => d.end <= new DateTime(2010, 9, 30))
Unless you're looking for the dates in between start and end inclusive:
Enumerable.Range(0, int.MaxValue)
.SelectMany(i => new[]
{
DateTime.Today.AddDays(7*i),
DateTime.Today.AddDays(7*i + 1),
DateTime.Today.AddDays(7*i + 2)
})
.TakeWhile(d => d <= new DateTime(2010, 9, 30))
精彩评论