구 MiniHomepy/Experience
해당월이 몇주까지 있는지 알아내기
aromacrony
2009. 5. 26. 17:29
wkstart --주시작하는 기준요일
public int Weeks(int year, int month, DayOfWeek wkstart)
{
DateTime first = new DateTime(year, month, 1);
int firstwkday = (int)first.DayOfWeek;
int otherwkday = (int)wkstart;
int offset = ((otherwkday + 7) - firstwkday) % 7;
double weeks = (double)(DateTime.DaysInMonth(year, month) - offset) / 7d; return (int)Math.Ceiling(weeks);
}