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

    #region


    //获取当前周几

    private string _strWorkingDayAM = "08:30";//工作时间上午08:00
    private string _strWorkingDayPM = "17:30";
    private 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;
    }
    //初始化默认值
    private void m_InitWorkingDay()
    {
    dspWorkingDayAM = DateTime.Parse(_strWorkingDayAM).TimeOfDay;
    dspWorkingDayPM = DateTime.Parse(_strWorkingDayPM).TimeOfDay;

    }


    #endregion

  • 相关阅读:
    【转】一个lucene的官网例子
    mongodb(回滚)
    mongodb( 实现join)
    JSON.stringify && JSON.parse
    js下的面向对象
    node(规则引擎)
    objective-c(内存管理)
    STM32F0xx_USART收发配置详细过程
    STM32F0xx_GPIO配置详细过程
    STM32F0_新建软件工程详细过程
  • 原文地址:https://www.cnblogs.com/waitingfor/p/4571530.html
Copyright © 2011-2022 走看看