#region Get week name in year
public string GetWeekName(string dd) //得到當前日期本周的名字
{
int FirstSaturday=0;
string t1 = Convert.ToDateTime(dd).Year.ToString()+"/1/1";
DateTime dt1 = Convert.ToDateTime(t1);
for(int i=0;i<7;i++)
{
if(dt1.AddDays(i).DayOfWeek.ToString()=="Saturday")
{
FirstSaturday = i+1;
break;
}
}
int m1 = Convert.ToDateTime(dd).DayOfYear;
int w1 = (m1-FirstSaturday-1)/7;
int a;
string A="";
if(m1<=FirstSaturday)
{
a=1;
}
else if(m1<=FirstSaturday+7)
{
a=2;
}
else
{
a = w1+2;
}
if(a!=1)
{
if(a<10)
{
A="0"+a.ToString();
return "W"+A;
}
else
{
return "W"+a.ToString();
}
}
else
{
string tt = dt1.AddDays(-1).ToShortDateString();
if(dt1.Year>Convert.ToDateTime(tt).Year)
{
if(a<10)
{
return "W"+"0"+a.ToString();
}
else
{
return "W"+a.ToString();
}
}
else
{
return GetWeekName(tt);
}
}
}
#endregion