public static Dictionary<DateTime, DateTime> GetGroupWeek(DateTime startTime, DateTime endTime)
{
Dictionary<DateTime, DateTime> timeDic = new Dictionary<DateTime, DateTime>();
while (DateTime.Compare(startTime, endTime) <= 0)
{
int week = (int)startTime.DayOfWeek;
if (week == 0) week = 7; //周日
DateTime beginDate = startTime.AddDays(-(week - 1));
DateTime endDate = beginDate.AddDays(6);
timeDic.Add(beginDate, endDate);
startTime = endDate.AddDays(1);
}
return timeDic;
}
关注公众:CANSLIM交易
回复:周分割代码
下载源代码