根据年份-月份,获得此月份的所有日期

        /// <summary>
        /// 根据年份-月份,获得此月份的所有日期
        /// </summary>
        /// <param name="year">年份</param>
        /// <param name="month">月份</param>
        /// <returns></returns>
        public static ArrayList GetMonth(int year, int month)
        {
            ArrayList arr = new ArrayList();
            var first = new DateTime(year, month, 1);
            var last = new DateTime(month == 12 ? year + 1 : year, month == 12 ? 1 : month + 1, 1);
            var days = last.Subtract(first).Days;
            var prevDays = (int)first.DayOfWeek;
            var nextDays = 7 - (int)last.DayOfWeek;
            var result = new StringBuilder("");
            for (int i = -prevDays; i < prevDays + days + nextDays; i++)
            {
                if (i > -1 && i < days)
                {
                    arr.Add((i + 1).ToString());
                }
            }
            return arr;
        }

posted @ 2011-08-09 19:42  .net|C#|js|jquery|css|div|html  阅读(1186)  评论(0编辑  收藏  举报