/// <summary>
/// 求某年有多少周
/// 返回 int
/// </summary>
/// <param name="year"></param>
/// <returns>int 周数</returns>
public static int GetYearWeekCount(DateTime year)
{
string returnStr = "";
System.DateTime fDt = DateTime.Parse(string.Format("{0}/01/01", year.Year));
DateTime lDt=fDt.AddYears(1).AddDays(-1);
int k = Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
int days = lDt.DayOfYear;//365/366
int c= (days - 1 - (7 - k)) % 7;
int countWeek =(c==0?1:2)+ (days - 1 - (7 - k==0?7:k)) / 7;
return countWeek;
}
public static int CalcYearWeekCount(DateTime year)
{
System.DateTime fDt = DateTime.Parse(string.Format("{0}/01/01", year.Year));
DateTime lDt = fDt.AddYears(1).AddDays(-1);
int days = lDt.DayOfYear;
int weekCount = 0;
int firstDay = 0;
for (int i = 0; i < days; i++)
{
firstDay = Convert.ToInt32(fDt.DayOfWeek);
if (firstDay==0)
{
weekCount++;
}
fDt=fDt.AddDays(1);
}
if (firstDay>0)
{
weekCount = weekCount + 1;
}
return weekCount;
}