首页 > 代码库 > 判断时间点是否在工作日时间段区间内
判断时间点是否在工作日时间段区间内
#region //获取当前周几 private readonly string _strWorkingDayAm = "08:30";//工作时间上午08:00 private readonly string _strWorkingDayPm = "17:30"; private readonly string _strRestDay = "6,7";//周几休息日 周六周日为 6,7 private TimeSpan _dspWorkingDayAm;//工作时间上午08:00 private TimeSpan _dspWorkingDayPm; private string m_GetWeekNow() { string strWeek = DateTime.Now.DayOfWeek.ToString(); switch (strWeek) { case "Monday": return "1"; case "Tuesday": return "2"; case "Wednesday": return "3"; case "Thursday": return "4"; case "Friday": return "5"; case "Saturday": return "6"; case "Sunday": return "7"; } return "0"; } /// <summary> /// 判断是否在工作日内 /// </summary> /// <returns></returns> private bool m_IsWorkingDay() { string strWeekNow = this.m_GetWeekNow();//当前周几 ////判断是否有休息日 string[] RestDay = _strRestDay.Split(‘,‘); if (RestDay.Contains(strWeekNow)) { return false; } //判断当前时间是否在工作时间段内 _dspWorkingDayAm = DateTime.Parse(_strWorkingDayAm).TimeOfDay; _dspWorkingDayPm = DateTime.Parse(_strWorkingDayPm).TimeOfDay; TimeSpan dspNow = DateTime.Now.TimeOfDay; if (dspNow > _dspWorkingDayAm && dspNow < _dspWorkingDayPm) { return true; } return false; } #endregion
判断时间点是否在工作日时间段区间内
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。