Zeller公式用于计算给定日期是星期几。
1 //根据日期计算星期几
2
3 int SDGSELFLocalTime::CalWhatDay(ST_LOCALDATE& l_stDate)
4 {
5 int year = l_stDate.m_nYear;
6 int month = l_stDate.m_nMonth;
7 int day = l_stDate.m_nDay;
8 if (month < 3)
9 {
10 year -= 1;
11 month += 12;
12 }
13 int c = int(year / 100) , y = year - 100 * c;
14 int w = int(c / 4) - 2*c +y +int(y/4) +(26 * (month + 1)/10) + day - 1;
15 w = (w % 7 + 7) % 7;
16 return w;
17 }
时间: 2024-10-17 04:40:34