zoukankan      html  css  js  c++  java
  • 判断时间点是否在工作日时间段区间内

          #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 
  • 相关阅读:
    imac 截图

    [Python] 安装及环境配置
    冒泡算法
    [转载]分页+双向排序(jquery + ashx)
    【转载】jQuery最佳实践
    【转载】星级评分jQuery插件
    ie浏览器模式判断语句
    jQuery面向对象定制业务框架开发
    【转载】jQuery设计思想
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/6230048.html
Copyright © 2011-2022 走看看