Hi

Im using codewarrior 6.3

and a MC9s08QE32

When I do the following

cX = cM * 2;

cY = cX + (((cM+1)*3)/5);

cX = cY + ((sTime.cYear-i)/4);

cY = cX - ((sTime.cYear-i)/100);

cX = cY + ((sTime.cYear-i)/400);

cY = (cX + (sTime.cYear-i));

cX = cY + 2;

cX %= 7;

sTime.cDayofWeek = (char)cX;

where cY,cX and stime.cYear are all interger (unsigned for cyear)

Im using debugger with a openbdm

those two line doesnt change variable content

cY = (cX + (sTime.cYear-i));

cX = cY + 2;

but cX %=7 does work (but the final result is wrong due to 2 addition failing to add

can someone point me what im doing wrong there?

answered myself

declared long int and it work now

int is not 16 bit???

BTW this is zeller's congruence

cM = sTime.cMonth;

//Day of week

if(cM == 1)

{

cM = 13;

i++;

}

else if(sTime.cMonth == 2)

{

cM = 14;

i++;

}

cX = sTime.cDay;

cX += (long int)(((cM+1)*26)/10);

cX += sTime.cYear-i;

cX += (long int)((sTime.cYear-i)/4);

cX += (long int)(((sTime.cYear-i)/100)*6);

cX += (long int)((sTime.cYear-i)/400);

cX %= 7;

sTime.cDayofWeek = (char)cX;

it could be a little more compressed but it work and easy to debug