一个mtk中的函数,
根据输入的年月日,可以自动计算出星期几,可以单独在VC上进行试验:
/*****************************************************************************
* FUNCTION
* applib_dt_dow
* DESCRIPTION
* Function to compute current day of week.
* PARAMETERS
* y [IN] Year of the date to be computed. (example, 2004)
* m [IN] Month of the date to be computed
* d [IN] Day of the date to be computed
* RETURNS
* kal_uint8 index of day of week
*****************************************************************************/
kal_uint8 applib_dt_dow(kal_uint16 y, kal_uint8 m, kal_uint8 d)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (m < 3)
{
m += 13;
y--;
}
else
{
m++;
}
return (d + 26 * m / 10 + y + y / 4 - y / 100 + y / 400 + 6) % 7;
}
阅读(2274) | 评论(0) | 转发(0) |