The algorithm is as follows:
Kelason Calculation Formula
W = (D 2 * m 3 * (m 1) / 5 Y Y / 4-Y / 100 Y / 400) MOD 7 D represents the number of days in the date, and M represents the number of months, Y indicates the number of years.
Note: There is a place different from other formulas in the formula:
Despect in January and February as the last year of the last year of the last year, the example: If it is 2004-10, it is converted to: 2003-13-10 to enter the formula calculation. The code is as follows: // Y-year, M-month, D-date String Caculateweekday (int y, int m, int d) {if (m == 1) m = 13; if (m == 2) m = 14 ; Int week = (D 2 * m 3 * (m 1) / 5 y y / 4-y / 100 y / 400)% 7; string weekstr = ""; switch (week) {cas 1: Weekstr = "Monday"; Break; Case 2: Weekstr = "Tuesday"; Break; Case 3: Weekstr = "Wednesday"; Break; Case 4: Weekstr = "Thursday"; Break; Case 5: Weekstr = " Friday "; Break; Case 6: weekstr =" Saturday "; Break; Case 7: Weekstr =" Sunday "; Break;
Return weekstr;} Call method: label2.text = CaculateweekDay (2004, 12, 9);