下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
protected voID Page_Load(object sender,EventArgs e) { DateTime start = Convert.ToDateTime("2012-12-10"); DateTime end= Convert.ToDateTime("2012-12-18"); TimeSpan span = end - start; //int totleDay=span.Days; //DateTime spanNu = DateTime.Now.Subtract(span); int AllDays=Convert.ToInt32(span.TotalDays)+1;//差距的所有天数 int totleWeek = AllDays / 7;//差别多少周 int yuDay = AllDays % 7; //除了整个星期的天数 int lastDay = 0; if (yuDay == 0) //正好整个周 { lastDay = AllDays - (totleWeek * 2); } else { int weekDay = 0; int enDWeekDay = 0; //多余的天数有几天是周六或者周日 switch (start.DayOfWeek) { case DayOfWeek.Monday: weekDay = 1; break; case DayOfWeek.Tuesday: weekDay = 2; break; case DayOfWeek.Wednesday: weekDay = 3; break; case DayOfWeek.Thursday: weekDay = 4; break; case DayOfWeek.FrIDay: weekDay = 5; break; case DayOfWeek.Saturday: weekDay = 6; break; case DayOfWeek.Sunday: weekDay = 7; break; } if ((weekDay == 6 && yuDay >= 2) || (weekDay == 7 && yuDay >= 1) || (weekDay == 5 && yuDay >= 3) || (weekDay == 4 && yuDay >= 4) || (weekDay == 3 && yuDay >= 5) || (weekDay == 2 && yuDay >= 6) || (weekDay == 1 && yuDay >=7)) { enDWeekDay =2; } if ((weekDay == 6 && yuDay < 1) || (weekDay == 7 && yuDay <5) || (weekDay == 5 && yuDay < 2) || (weekDay == 4 && yuDay < 3) || (weekDay == 3 && yuDay < 4) || (weekDay == 2 && yuDay < 5) || (weekDay == 1 && yuDay < 6)) { enDWeekDay = 1; } lastDay = AllDays - (totleWeek * 2) - enDWeekDay; } lblTime.Text = lastDay.ToString(); }
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的C#取两个时间的时间差并去除周末全部内容,希望文章能够帮你解决C#取两个时间的时间差并去除周末所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)