设:bufTime.year = 18, bufTime.mon = 11, bufTime.day = 4算出的w的值等于2,正确值应该是0。不知是什么原因,望大侠们指点,先谢谢了!
void RefreshTimeShow()
{
unsigned int d, m, y, w;
ShowBcdByte(16, 0, bufTime.year); //Year
ShowBcdByte(48, 0, bufTime.mon); //Month
ShowBcdByte(80, 0, bufTime.day); //Date
ShowBcdByte(0, 2, bufTime.hour); //Hour
ShowBcdByte(32, 2, bufTime.min); //Minutes
ShowBcdByte(64, 2, bufTime.sec); //Seconds
d = bufTime.day;
m = bufTime.mon;
y = 2000 + bufTime.year;
if(m == 1 || m == 2)
{
m += 12;
y--;
}
w = (d + 1 + 2*m + 3*(m+1)/5 + y + y/4 - y/100 + y/400)%7;
bufTime.week = (unsigned char)w;
ShowBcdByte(32, 4, bufTime.week);
}
|