/*************************************** ****************
**
** Function: Specify the input date as the day of the week (0 indicates Sunday, and the remaining value is 1-6)
** Date: 2006-6-16
**
**
**************************************** ****************/
Int cmy33dlg: sw_weekday (INT year, int month, int Day)
{
Int dayofweek;
/* The following four statements are used to calculate the number of weeks of the input date, which is the core part of the program and indispensable */
Dayofweek = year> 0? (5 + (Year + 1) + (year-1)/4-(year-1)/100 + (year-1)/400) % 7
: (5 + year/4-year/100 + year/400) % 7;
Dayofweek = month> 2? (Dayofweek + 2 * (month + 1) + 3 * (month + 1)/5) % 7
: (Dayofweek + 2 * (month + 2) + 3 * (month + 2)/5) % 7;
If (Year % 4 = 0 & year % 100! = 0) | year % 400 = 0) & month> 2)
{
Dayofweek = (dayofweek + 1) % 7;
}
Dayofweek = (dayofweek + day) % 7;
Cstring strtemp;
Switch (dayofweek)
{
Case 0:
Strtemp = "Today is Sunday ";
Break;
Case 1:
Strtemp = "Today is Monday ";
Break;
Case 2:
Strtemp = "Today is Tuesday ";
Break;
Case 3:
Strtemp = "Today is Wednesday ";
Break;
Case 4:
Strtemp = "Today is Thursday ";
Break;
Case 5:
Strtemp = "Today is Friday ";
Break;
Case 6:
Strtemp = "Today is Saturday ";
Break;
Default:
Strtemp = "Please check whether the input is complete! ";
Break;
}
MessageBox (strtemp );
Return dayofweek;
}
// Function: Call the sw_weekday () function to check the day of the week.
Void cmy33dlg: onbtnweek ()
{
Updatedata ();
Int year, month, day;
If (m_editstryear! = "" & M_editstrmonth! = "" & M_editstrday! = "")
{
Year = atoi (m_editstryear); // m_eidtstryear indicates the variable name in the editing box.
Month = atoi (m_editstrmonth );
Day = atoi (m_editstrday );
}
Sw_weekday (year, month, day); // call the function for calculating the day of the week
Updatedata (false );
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.