基姆拉尔森计算公式(求某年某月某日星期几)



string CaculateWeekDay(int y,int m, int d)
{
if(m==1||m==2) {
m+=12;
y--;
}
int week=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;
string weekstr="";
switch(week)
{
case 1: weekstr="星期一"; break;
case 2: weekstr="星期二"; break;
case 3: weekstr="星期三"; break;
case 4: weekstr="星期四"; break;
case 5: weekstr="星期五"; break;
case 6: weekstr="星期六"; break;
case 0: weekstr="星期日"; break;
}
return weekstr;
}
posted @ 2015-03-15 16:41  冷夏的博客园  阅读(377)  评论(0编辑  收藏  举报