'congruence'에 해당되는 글 1건

  1. 2012.11.20 요일 계산
카테고리 없음2012. 11. 20. 02:46

년도, 월, 일 을 가지고 요일을 계산한다.


/**
	Zeller's congruence
	@param day the day of the month
	@param month the month
	@oaran year the year
	return the weekday (0 = Monday, 1 = Tuesday, ..., 6 = Sunday)
*/
int zeller(int day, int month, int year)
{
	int modifiedMonth[] = { 0,					//	not used
							13, 14, 3, 4,		//	month : 1 ~ 4
							5, 6, 7, 8,			//	month : 5 ~ 8
							9, 10, 11, 12 };	//	month : 9 ~ 12
	int w;
	int mm = modifiedMonth[month];

	w = ( day + 5
		+ ( 26 * (mm + 1) ) / 10
		+ ( 5 * (year % 100) ) / 4
		+ ( 21 * (year / 100) ) / 4 ) % 7;

	return w;
}



Posted by 쿨한넘