直接给函数,根据年、月、日计算星期。绝对好使!
u8 RTC_Get_Week(u16 year,u8 month,u8 day)
{
static u8 no_leap_year[12]={6,2,2,5,0,3,5,1,4,6,2,4}; //非闰年
static u8 leap_year[12]={5,1,2,5,0,3,5,1,4,6,2,4}; //闰年
u8 temp2;
u8 yearL;
yearL=year0;
yearL=(yearL/4+yearL)%7;
temp2=Is_Leap_Year(year)?leap_year[month-1]:no_leap_year[month-1];
return ((day+temp2+yearL)%7);
} |