private int weekNumber()
    {            
        string firstDateText = DateTime.Now.Year.ToString() + "年1月1日";
        DateTime firstDay = Convert.ToDateTime(firstDateText);
        int theday;
        if (firstDay.DayOfWeek == DayOfWeek.Sunday || firstDay.DayOfWeek == DayOfWeek.Monday)
        {
            theday = 0;
        }
        else if (firstDay.DayOfWeek == DayOfWeek.Tuesday)
        {
            theday = 1;
        }
        else if (firstDay.DayOfWeek == DayOfWeek.Wednesday) { theday = 2; }
        else if (firstDay.DayOfWeek == DayOfWeek.Thursday) { theday = 3; }
        else if (firstDay.DayOfWeek == DayOfWeek.Friday)
        {
            theday = 4;
        }
        else
        {
            theday = 5;
        }
        DateTime nowDate = DateTime.Now;
        int weekNum = (nowDate.DayOfYear + theday) / 7 + 1;
        return weekNum;
    }
posted on 2009-11-30 10:44  freedom831215  阅读(247)  评论(0编辑  收藏  举报