One week starts from Sunday
Datetime mdatetime = new datetime (year,); // year is the year required
Int firstweekfirstday = convert. toint32 (mdtime. dayofweek); // the day of the week on the first day of the year
Days = (double) (6-firstweekfirstday );
Datetime secondweekfisrtday = mdtime. adddays (days); Second Monday
Fisrtday = mdatetime. adddays (week * 7); // The first day of week n
Lastday = mdatetime. adddays (week * 7 + 6); // The last day of week n
One week starts from Monday
Datetime mdatetime = new datetime (year,); // year is the year required
Int firstweekfirstday = convert. toint32 (mdtime. dayofweek); // the day of the week on the first day of the year
Days = (double) (7-firstweekfirstday );
Datetime secondweekfisrtday = mdtime. adddays (days); Second Monday
Fisrtday = mdatetime. adddays (week * 7); // The first day of week n
Lastday = mdatetime. adddays (week * 7 + 6); // The last day of week n
Javascript:
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> new document </title>
<Script language = "JavaScript" type = "text/JavaScript">
Function showdatecount (year, weeknum ){
VaR date = new date (year, 0, (7 * weeknum ));
VaR FD = new date (date. getyear (), (date. getmonth (), (date. getdate ()-date. getday () + 1 ))
VaR Monday = FD. getyear () + "-" + (FD. getmonth () + 1) + "-" + FD. getdate () // the first day of a week
VaR LD = new date (date. getyear (), (date. getmonth (), (date. getdate ()-date. getday () + 7 ))
VaR Sunday = lD. getyear () + "-" + (LD. getmonth () + 1) + "-" + LD. getdate () // the last day of the week
Alert (Year + "year" + weeknum + "Week" + Monday + "to" + Sunday)
}
</SCRIPT>
<Meta name = "generator" content = "editplus">
<Meta name = "author" content = "">
<Meta name = "keywords" content = "">
<Meta name = "Description" content = "">
</Head>
<Body>
<Input type = "text" value = "2007" size = "20" name = "year"> year <input type = "text" name = "weeknum" value = "30 "size =" 20 ">
<Input type = "button" name = "go" value = "click" onclick = "showdatecount (Year. Value, weeknum. Value)">
</Body>
</Html>
C #
// Monthcalendar1 is a calendar control.
System. Globalization. chineselunisolarcalendar c = new chineselunisolarcalendar ();
Private void monthcalendar1_datechanged (Object sender, daterangeeventargs E)
{
Datetime myselectdate = E. end;
Txt_nonglidate.text = string. format (cultureinfo. installeduiculture, "{0}-{1}-{2}", C. getyear (myselectdate), C. getmonth (myselectdate), C. getdayofmonth (myselectdate ));
}