zoukankan      html  css  js  c++  java
  • asp.net 取当前第几周

     ///   <summary>  
        ///   返回一个数组长度为3的字符串数组  
        ///   </summary>  
        ///   <returns>GetWeekDay[0]=周次;GetWeekDay[1]=该周第一天;GetWeekDay[2]=该周最后一天</returns>  
        public string[] GetWeekDay()
        {
            string[] inti = new string[3];
            DateTime day = DateTime.Parse(DateTime.Today.Year + "-1-1");
            System.DayOfWeek dateTime = day.DayOfWeek;
            int DayCount = DateTime.Today.DayOfYear;
            int i = (DayCount + aa(dateTime) - 2) / 7 + 1;
            inti[0] = i.ToString();

            inti[1] = day.AddDays(DayCount - 1).ToString("yyyy年MM月dd日");
            inti[2] = day.AddDays(DayCount + 5).ToString("yyyy年MM月dd日");
            Response.Write("第"+i+"周"); 
         
            return inti;
        }

        private int aa(System.DayOfWeek weekday)
        {
            switch (weekday.ToString())
            {
                case "Sunday":
                    return 1;
                case "Monday":
                    return 2;
                case "Tuesday":
                    return 3;
                case "Wednesday":
                    return 4;
                case "Thursday":
                    return 5;
                case "Friday":
                    return 6;
                case "Saturday":
                    return 0;
                default:
                    return 8;
            }

        }

  • 相关阅读:
    函数式编程的基础
    monad
    Overview of Polymorphism -多态的分类
    浅谈Overload和Override的区别
    Polymorphism (computer science)
    Type inference
    Ad hoc polymorphism
    trait 和abstract的区别在哪里
    Type class-Typeclass-泛型基础上的二次抽象---随意多态
    泛型中的类型约束和类型推断
  • 原文地址:https://www.cnblogs.com/sherry/p/1228761.html
Copyright © 2011-2022 走看看