How to determine the day to day of the week

// Kim Larsen is calculated based on the date of judgment day of the week

void CalculateWeekDay(int y, int m,int d){

if(m==1||m==2) m+=12,y--;

int iWeek = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4-y / 100 + y / 400)% 7;

switch(iWeek){

Case 0: printf ( "Monday \ the n-"); BREAK;

Case 1: printf ( "Tuesday \ the n-"); BREAK;

Case 2: printf ( "Wednesday \ the n-"); BREAK;
Case 3: printf ( "Thursday \ the n-"); BREAK;
Case 4: printf ( "Friday \ the n-"); BREAK;
Case 5: printf ( "Saturday \ the n-"); BREAK;
Case 6: printf ( "Sunday \ the n-"); BREAK;
}
 
}
Where: January and February last year as a ten and eleven in March, April, for example: If it is then converted into 2004-1-10: 2003-13-10 be substituted into the formula

Guess you like

Origin www.cnblogs.com/ttct/p/12391376.html