• 判断时间点是否在工作日时间段区间内


          #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 
  • 相关阅读:
    责任链模式(Chain of Responsibility)
    模板模式(Template Method)
    组合模式(Composite Pattern)
    原型模式(Prototype Pattern)
    策略模式(Strategy Pattern)
    状态模式(State Pattern)
    增删改查
    安卓sql
    安卓第三次作业
    安卓第四周作业
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/6230048.html
Copyright © 2020-2023  润新知