Algorithm As follows:
Kemlerson Formula
W = (D + 2 * m + 3 * (m + 1)/5 + Y/4-y/100 + Y/400) mod 7
In the formula, D indicates the number of days in the date, M indicates the number of months, and y indicates the number of years.
Note: There is a difference between the formula and other formulas:
The year and month are regarded as the 13 and 14 months of the previous year. For example, if the year-1-10 is used, the formula is converted to 2003-13-10.
CodeAs follows:
// Y-year, M-month, and 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/4-y/100 + Y/400) % 7;
String weekstr = "";
Switch (week)
{
Case 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 (maid, 9 );