打印本文 打印本文 关闭窗口 关闭窗口
如何计算某一年一共有多少周
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2113  更新时间:2009/6/9 2:34:27  文章录入:mintao  责任编辑:mintao

//strYear 年份
public   int  GetWeek(string strYear)
        {
           
string   returnStr="";
           
            System.DateTime   fDt
=DateTime.Parse(strYear+"-01-01");
           
int   k=Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
            if(k==1)
            {
               
int countDay = fDt.AddYears(1).AddDays(-1).DayOfYear;
               
int countWeek = countDay/7+1;
               
return countWeek;
               
            }
           
else
            {
               
int countDay = fDt.AddYears(1).AddDays(-1).DayOfYear;
               
int countWeek = countDay/7+2;
               
return countWeek;
            }
           
        }

此文引用www.csdn.net会员贴子!

打印本文 打印本文 关闭窗口 关闭窗口