1
我正在使用ASP.Net MVC2。我想知道是否有計算重複日期的公式?所以從我的客戶端我選擇日期並使用ajax.post發送給控制器。我期待的結果將是,像這樣的例子:是否有計算復發的公式
的maxDate是當今 持續時間爲每週1天9月30日 的currentdate是
所以輸出將 aug12-aug14 aug19-aug21 aug26-28直到九月底
我正在使用ASP.Net MVC2。我想知道是否有計算重複日期的公式?所以從我的客戶端我選擇日期並使用ajax.post發送給控制器。我期待的結果將是,像這樣的例子:是否有計算復發的公式
的maxDate是當今 持續時間爲每週1天9月30日 的currentdate是
所以輸出將 aug12-aug14 aug19-aug21 aug26-28直到九月底
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))
除非你在開始和結束(含)之間尋找日期:
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))