日期:2014-05-17 浏览次数:20455 次
/// <summary>
/// 获取startdate到enddate之间的时长,剔除8-12 14-18这2个时间段。返回总秒
/// </summary>
/// <param name="startdate"></param>
/// <param name="enddate"></param>
/// <returns></returns>
public static string getShiChang(string startdate, string enddate)
{
DateTime startTime = Convert.ToDateTime(startdate);
DateTime endTime = Convert.ToDateTime(enddate);
TimeSpan ts = new TimeSpan();
double shichang = 0;
double shichang1 = 0;
double shichang2 = 0;
double shichang3 = 0;
//如果是周六周天,则所有时间都是有效时间
if (startTime.DayOfWeek.ToString("d") == "0" || startTime.DayOfWeek.ToString("d") == "6")
{
ts = endTime - startTime;
shichang1 = ts.TotalSeconds;
}
else
{
DateTime sys_startdate = Convert.ToDateTime(startTime.ToString("yyyy-MM-dd") + " " + "8:0:0");
DateTime sys_enddate = Convert.ToDateTime(endTime.ToString("yyyy-MM-dd") + " " + "12:0:0");