• 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;
            }

        }

  • 相关阅读:
    广播BroadcastReceiver(2)
    hunnu11544:小明的烦恼——找字符串
    Systemd启动图形界面过程
    大数据.......
    2014百度之星第一题Energy Conversion
    基于zookeeper简单实现分布式锁
    LeetCode OJ 215. Kth Largest Element in an Array 堆排序求解
    Leetcode
    Linux文件系统(七)---系统调用之open操作(一)
    Go语言Slice操作.
  • 原文地址:https://www.cnblogs.com/sherry/p/1228761.html
Copyright © 2020-2023  润新知