zoukankan      html  css  js  c++  java
  • C# 获取当年的周六周日

     public void GetWMDay()
            {
                List<string> list = new List<string>();
                string year = "2019";
                DateTime counYear = Convert.ToDateTime(year + "-01-01"); //
                DateTime nestYear = counYear.AddYears(1);
    
                for (DateTime i = counYear; i < nestYear; i = i.AddDays(1))
                {
                    if ((int)i.DayOfWeek == 0)
                    {  // 周日    to do   }
    
                        list.Add("周日" + i.ToShortDateString());
                    }
                    else if ((int)i.DayOfWeek == 6)
                    {   //周六  to do  }       
                        list.Add("周六" + i.ToShortDateString());
                    }
                }
    
                MessageBox.Show("完成");
            }
      /// <summary>
            /// 获得指定年,月 的周六和周日的   年月日
            /// </summary>
            /// <param name="year"></param>
            /// <returns></returns>
            public List<DateTime> GetWMDay(int year,int month)
            {
                List<DateTime> list = new List<DateTime>();
                DateTime counYear = Convert.ToDateTime(string.Format("{0}-{1}-01",year,month)); 
                DateTime nestYear = counYear.AddMonths(1);
                for (DateTime i = counYear; i < nestYear; i = i.AddDays(1))
                {
                    if ((int)i.DayOfWeek == 0)
                    {  // 周日    to do   }
    
                        list.Add(i);
                    }
                    else if ((int)i.DayOfWeek == 6)
                    {   //周六  to do  }       
                        list.Add(i);
                    }
                }
                return list;
            }
  • 相关阅读:
    转:PCIe基础知识
    转:HDMI介绍与流程
    Java EJB JBoss
    冒泡排序
    多线程
    快排
    Talk is cheap,show me the code
    oracle union
    Oracle 【to_number】【instr】
    DB 【ACID】
  • 原文地址:https://www.cnblogs.com/enych/p/10210405.html
Copyright © 2011-2022 走看看