Does the primary certificate have five Friday, five Saturday, and five Sundays?

Source: Internet
Author: User
/// <Summary>
/// Whether the primary certificate has five Friday, five Saturday, and five Sundays
/// The year of the next occurrence
/// </Summary>
/// <Param name = "ARGs"> </param>
Static void main (string [] ARGs)
{
// Current time
Datetime dtnow = datetime. now;
// The current time is smaller than the maximum value
While (dtnow <datetime. maxvalue)
{
// The month must be 31 days before the month to add one
Datetime nextmonth = dtnow. addmonths (1 );
// The first day of the month in the next month is a week.
Datetime firstdayofnextmonth = new datetime (nextmonth. Year, nextmonth. month, 1 );
// Determine whether the first day of the month is 31 days and the first day of the month must be Friday.
If (datetime. daysinmonth (nextmonth. Year, nextmonth. month) = 31 & firstdayofnextmonth. dayofweek = dayofweek. Friday)
{
Console. writeline ("the next generation is at: {0}", firstdayofnextmonth );
Break;
}
Dtnow = nextmonth;
}

Console. Readline ();
}

/// <Summary>
/// Last year of occurrence
/// </Summary>
/// <Param name = "ARGs"> </param>
// Static void main (string [] ARGs)
//{
/// // Current time
/// Datetime dtnow = datetime. now;
/// // The current time is smaller than the maximum value
//// While (datetime. minvalue <= dtnow)
////{
//// The month must be 31 days before the first day of the month
/// Datetime nextmonth = dtnow. addmonths (-1 );
///// The first day of the month of the next year is a shard.
/// Datetime firstdayofnextmonth = new datetime (nextmonth. Year, nextmonth. month, 1 );
///// Determine whether the first day of the month is 31 days and the first day of the month must be Friday.
/// If (datetime. daysinmonth (nextmonth. Year, nextmonth. month) = 31 & firstdayofnextmonth. dayofweek = dayofweek. Friday)
////{
/// Console. writeline ("Last generated at: {0}", firstdayofnextmonth );
//// Break;
////}
/// Dtnow = nextmonth;
////}

//// Console. Readline ();
//}

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.